Stop leaking scripting overlay
This commit is contained in:
parent
b05f1d9ca1
commit
958b71afbb
4 changed files with 12 additions and 7 deletions
|
@ -166,6 +166,7 @@ public slots:
|
||||||
void on_mainTabBar_tabBarClicked(int index);
|
void on_mainTabBar_tabBarClicked(int index);
|
||||||
void on_mapViewTab_tabBarClicked(int index);
|
void on_mapViewTab_tabBarClicked(int index);
|
||||||
void onWarpBehaviorWarningClicked();
|
void onWarpBehaviorWarningClicked();
|
||||||
|
void clearOverlay();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_action_Open_Project_triggered();
|
void on_action_Open_Project_triggered();
|
||||||
|
|
|
@ -3081,6 +3081,11 @@ bool MainWindow::askToFixRegionMapEditor() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::clearOverlay() {
|
||||||
|
if (ui->graphicsView_Map)
|
||||||
|
ui->graphicsView_Map->clearOverlayMap();
|
||||||
|
}
|
||||||
|
|
||||||
// Attempt to close any open sub-windows of the main window, giving each a chance to abort the process.
|
// Attempt to close any open sub-windows of the main window, giving each a chance to abort the process.
|
||||||
// Each of these windows is a widget with WA_DeleteOnClose set, so manually deleting them isn't necessary.
|
// Each of these windows is a widget with WA_DeleteOnClose set, so manually deleting them isn't necessary.
|
||||||
// Because they're tracked with QPointers nullifying them shouldn't be necessary either, but it seems the
|
// Because they're tracked with QPointers nullifying them shouldn't be necessary either, but it seems the
|
||||||
|
|
|
@ -29,8 +29,6 @@ void Scripting::stop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scripting::init(MainWindow *mainWindow) {
|
void Scripting::init(MainWindow *mainWindow) {
|
||||||
if (mainWindow->ui->graphicsView_Map)
|
|
||||||
mainWindow->ui->graphicsView_Map->clearOverlayMap();
|
|
||||||
Scripting::stop();
|
Scripting::stop();
|
||||||
instance = new Scripting(mainWindow);
|
instance = new Scripting(mainWindow);
|
||||||
}
|
}
|
||||||
|
@ -50,6 +48,7 @@ Scripting::Scripting(MainWindow *mainWindow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Scripting::~Scripting() {
|
Scripting::~Scripting() {
|
||||||
|
if (mainWindow) mainWindow->clearOverlay();
|
||||||
this->engine->setInterrupted(true);
|
this->engine->setInterrupted(true);
|
||||||
qDeleteAll(this->imageCache);
|
qDeleteAll(this->imageCache);
|
||||||
delete this->engine;
|
delete this->engine;
|
||||||
|
|
|
@ -25,8 +25,9 @@ void GraphicsView::moveEvent(QMoveEvent *event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapView::drawForeground(QPainter *painter, const QRectF&) {
|
void MapView::drawForeground(QPainter *painter, const QRectF&) {
|
||||||
foreach (Overlay * overlay, this->overlayMap)
|
for (auto i = this->overlayMap.constBegin(); i != this->overlayMap.constEnd(); i++) {
|
||||||
overlay->renderItems(painter);
|
i.value()->renderItems(painter);
|
||||||
|
}
|
||||||
|
|
||||||
if (!editor) return;
|
if (!editor) return;
|
||||||
|
|
||||||
|
@ -56,9 +57,8 @@ void MapView::drawForeground(QPainter *painter, const QRectF&) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapView::clearOverlayMap() {
|
void MapView::clearOverlayMap() {
|
||||||
foreach (Overlay * overlay, this->overlayMap) {
|
for (auto i = this->overlayMap.constBegin(); i != this->overlayMap.constEnd(); i++) {
|
||||||
overlay->clearItems();
|
delete i.value();
|
||||||
delete overlay;
|
|
||||||
}
|
}
|
||||||
this->overlayMap.clear();
|
this->overlayMap.clear();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue