Commit bead60e5 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Fix crash when saving a modified document on closing the last window

If we close the last window, but are still saving a document, we'll
crash because the application will be quitting while the saving code
is still going on.

bug:294235
bug:292620
bug:293601
parent 52151af9
......@@ -132,6 +132,7 @@ public:
readOnly = false;
dockWidgetMenu = 0;
dockerManager = 0;
deferredClosingEvent = 0;
}
~KoMainWindowPrivate() {
qDeleteAll(toolbarList);
......@@ -210,6 +211,8 @@ public:
QList<QDockWidget *> dockWidgets;
QList<QDockWidget *> hiddenDockwidgets; // List of dockers hiddent by the call to hideDocker
QCloseEvent *deferredClosingEvent;
};
KoMainWindow::KoMainWindow(const KComponentData &componentData)
......@@ -739,6 +742,10 @@ void KoMainWindow::slotSaveCompleted()
disconnect(pDoc, SIGNAL(completed()), this, SLOT(slotSaveCompleted()));
disconnect(pDoc, SIGNAL(canceled(const QString &)),
this, SLOT(slotSaveCanceled(const QString &)));
if (d->deferredClosingEvent) {
KParts::MainWindow::closeEvent(d->deferredClosingEvent);
}
}
// returns true if we should save, false otherwise.
......@@ -1042,6 +1049,7 @@ void KoMainWindow::closeEvent(QCloseEvent *e)
return;
}
if (queryClose()) {
d->deferredClosingEvent = e;
if (d->docToOpen) {
// The open pane is visible
d->docToOpen->deleteOpenPane(true);
......@@ -1057,9 +1065,9 @@ void KoMainWindow::closeEvent(QCloseEvent *e)
foreach(QDockWidget* dockWidget, d->dockWidgetsMap)
dockWidget->setVisible(d->dockWidgetVisibilityMap.value(dockWidget));
}
KParts::MainWindow::closeEvent(e);
} else
} else {
e->setAccepted(false);
}
}
void KoMainWindow::saveWindowSettings()
......@@ -1140,7 +1148,7 @@ bool KoMainWindow::queryClose()
switch (res) {
case KMessageBox::Yes : {
bool isNative = (d->rootDoc->outputMimeType() == d->rootDoc->nativeFormatMimeType());
if (! saveDocument(!isNative))
if (!saveDocument(!isNative))
return false;
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment