From 71704a410d4acb7eb6894ca42e40a64b48c7aab0 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Thu, 16 May 2024 04:34:48 +0300 Subject: [PATCH] kparts: query the part to close from KParts::MainWindow because KParts::ReadWritePart::closeUrl() is not called from the KParts::ReadWritePart destructor (and even if it is bad stuff may happen) for most rw parts (exception being okular which does its own query, maybe some other parts too) saving was not actually done (e.g. for ark). now the part will be queried to close, if the upload job fails (e.g. because of insufficient access) the application/part will not close (intentionally) tho and no error is reported via message box which is something that needs to be looked into Signed-off-by: Ivailo Monev --- kparts/mainwindow.cpp | 11 +++++++++++ kparts/mainwindow.h | 1 + kparts/part.cpp | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/kparts/mainwindow.cpp b/kparts/mainwindow.cpp index c53b6c49..e9cd17bd 100644 --- a/kparts/mainwindow.cpp +++ b/kparts/mainwindow.cpp @@ -159,6 +159,17 @@ void MainWindow::createShellGUI(bool create) } } +bool MainWindow::queryClose() +{ + // query part first + ReadWritePart* rwpart = qobject_cast(d->m_activePart); + if (rwpart && !rwpart->queryClose()) { + return false; + } + // then KXmlGuiWindow + return KXmlGuiWindow::queryClose(); +} + void KParts::MainWindow::saveNewToolbarConfig() { createGUI(d->m_activePart); diff --git a/kparts/mainwindow.h b/kparts/mainwindow.h index e9ba3854..6d6fc75f 100644 --- a/kparts/mainwindow.h +++ b/kparts/mainwindow.h @@ -80,6 +80,7 @@ protected Q_SLOTS: protected: virtual void createShellGUI(bool create = true); + virtual bool queryClose(); private: MainWindowPrivate* const d; diff --git a/kparts/part.cpp b/kparts/part.cpp index ef6e2ac4..1b92c290 100644 --- a/kparts/part.cpp +++ b/kparts/part.cpp @@ -662,7 +662,7 @@ bool ReadWritePart::queryClose() switch(res) { case KMessageBox::Yes: { - sigQueryClose(&handled,&abortClose); + sigQueryClose(&handled, &abortClose); if (!handled) { if (d->m_url.isEmpty()) { KUrl url = KFileDialog::getSaveUrl(KUrl(), QString(), parentWidget);