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 <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-05-16 04:34:48 +03:00
parent 8c8855d9a6
commit 71704a410d
3 changed files with 13 additions and 1 deletions

View file

@ -159,6 +159,17 @@ void MainWindow::createShellGUI(bool create)
}
}
bool MainWindow::queryClose()
{
// query part first
ReadWritePart* rwpart = qobject_cast<ReadWritePart*>(d->m_activePart);
if (rwpart && !rwpart->queryClose()) {
return false;
}
// then KXmlGuiWindow
return KXmlGuiWindow::queryClose();
}
void KParts::MainWindow::saveNewToolbarConfig()
{
createGUI(d->m_activePart);

View file

@ -80,6 +80,7 @@ protected Q_SLOTS:
protected:
virtual void createShellGUI(bool create = true);
virtual bool queryClose();
private:
MainWindowPrivate* const d;

View file

@ -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);