kdeui: remove unused virtual KMainWindow::queryExit() method

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-03-13 07:36:14 +02:00
parent 22c93570a2
commit 3c110d1c62
6 changed files with 6 additions and 110 deletions

View file

@ -172,10 +172,9 @@ public:
/** /**
* Returns true if the application is currently saving its session * Returns true if the application is currently saving its session
* data (most probably before KDE logout). This is intended for use * data (most probably before KDE logout). This is intended for use
* mainly in KMainWindow::queryClose() and KMainWindow::queryExit(). * mainly in KMainWindow::queryClose().
* *
* @see KMainWindow::queryClose * @see KMainWindow::queryClose
* @see KMainWindow::queryExit
*/ */
bool sessionSaving() const; bool sessionSaving() const;

View file

@ -30,13 +30,13 @@
base. base.
KSessionManager makes it possible to provide implementations for KSessionManager makes it possible to provide implementations for
QApplication::commitData() and QApplication::saveState(), without QApplication::commitData() and QApplication::saveState(), without
subclassing KApplication. KMainWindow internally makes use of this. subclassing KApplication. KMainWindow internally makes use of this.
You don't need to do anything with this class when using You don't need to do anything with this class when using
KMainWindow. Instead, use KMainWindow::saveProperties(), KMainWindow. Instead, use KMainWindow::saveProperties(),
KMainWindow::readProperties(), KMainWindow::queryClose(), KMainWindow::readProperties(), KMainWindow::queryClose(),
KMainWindow::queryExit() and friends. and friends.
@short Highlevel access to session management. @short Highlevel access to session management.
@author Matthias Ettrich <ettrich@kde.org> @author Matthias Ettrich <ettrich@kde.org>

View file

@ -93,23 +93,17 @@ class MyMainWindow : public KMainWindow
{ {
public: public:
MyMainWindow() : KMainWindow(), MyMainWindow() : KMainWindow(),
m_queryClosedCalled( false ), m_queryClosedCalled( false )
m_queryExitCalled( false )
{ {
} }
/*reimp*/ bool queryClose() { /*reimp*/ bool queryClose() {
m_queryClosedCalled = true; m_queryClosedCalled = true;
return true; return true;
} }
/*reimp*/ bool queryExit() {
m_queryExitCalled = true;
return true;
}
~MyMainWindow() { ~MyMainWindow() {
s_mainWindowDeleted = true; s_mainWindowDeleted = true;
} }
bool m_queryClosedCalled; bool m_queryClosedCalled;
bool m_queryExitCalled;
void reallyResize(int width, int height) { void reallyResize(int width, int height) {
const QSize oldSize = size(); const QSize oldSize = size();
@ -124,7 +118,6 @@ public:
// Here we test // Here we test
// - that queryClose is called // - that queryClose is called
// - that queryExit is called
// - that autodeletion happens // - that autodeletion happens
void KMainWindow_UnitTest::testDeleteOnClose() void KMainWindow_UnitTest::testDeleteOnClose()
{ {
@ -134,7 +127,6 @@ void KMainWindow_UnitTest::testDeleteOnClose()
QVERIFY( mw->testAttribute( Qt::WA_DeleteOnClose ) ); QVERIFY( mw->testAttribute( Qt::WA_DeleteOnClose ) );
mw->close(); mw->close();
QVERIFY( mw->m_queryClosedCalled ); QVERIFY( mw->m_queryClosedCalled );
QVERIFY( mw->m_queryExitCalled );
qApp->sendPostedEvents( mw, QEvent::DeferredDelete ); qApp->sendPostedEvents( mw, QEvent::DeferredDelete );
QVERIFY( s_mainWindowDeleted ); QVERIFY( s_mainWindowDeleted );
} }

View file

@ -72,8 +72,6 @@
#include <config.h> #include <config.h>
static bool no_query_exit = false;
static KStatusBar *internalStatusBar(KMainWindow *mw) static KStatusBar *internalStatusBar(KMainWindow *mw)
{ {
// Don't use qFindChild here, it's recursive! // Don't use qFindChild here, it's recursive!
@ -160,7 +158,6 @@ public:
// not really a fast method but the only compatible one // not really a fast method but the only compatible one
if ( sm.allowsInteraction() ) { if ( sm.allowsInteraction() ) {
bool canceled = false; bool canceled = false;
::no_query_exit = true;
foreach (KMainWindow *window, KMainWindow::memberList()) { foreach (KMainWindow *window, KMainWindow::memberList()) {
if ( !window->testAttribute( Qt::WA_WState_Hidden ) ) { if ( !window->testAttribute( Qt::WA_WState_Hidden ) ) {
@ -185,18 +182,9 @@ public:
*/ */
} }
} }
::no_query_exit = false;
if (canceled) if (canceled)
return false; return false;
KMainWindow* last = 0;
foreach (KMainWindow *window, KMainWindow::memberList()) {
if ( !window->testAttribute( Qt::WA_WState_Hidden ) ) {
last = window;
}
}
if ( last )
return last->queryExit();
// else // else
return true; return true;
} }
@ -249,7 +237,6 @@ void KMainWindowPrivate::init(KMainWindow *_q)
helpMenu = 0; helpMenu = 0;
//actionCollection()->setWidget( this ); //actionCollection()->setWidget( this );
QObject::connect(qApp, SIGNAL(aboutToQuit()), q, SLOT(_k_shuttingDown()));
QObject::connect(KGlobalSettings::self(), SIGNAL(settingsChanged(int)), QObject::connect(KGlobalSettings::self(), SIGNAL(settingsChanged(int)),
q, SLOT(_k_slotSettingsChanged(int))); q, SLOT(_k_slotSettingsChanged(int)));
@ -264,7 +251,6 @@ void KMainWindowPrivate::init(KMainWindow *_q)
//d->kaccel = actionCollection()->kaccel(); //d->kaccel = actionCollection()->kaccel();
settingsTimer = 0; settingsTimer = 0;
sizeTimer = 0; sizeTimer = 0;
shuttingDown = false;
if ((care_about_geometry = being_first)) { if ((care_about_geometry = being_first)) {
being_first = false; being_first = false;
@ -584,27 +570,9 @@ void KMainWindow::closeEvent ( QCloseEvent *e )
if (queryClose()) { if (queryClose()) {
e->accept(); e->accept();
int not_withdrawn = 0;
foreach (KMainWindow* mw, KMainWindow::memberList()) {
if ( !mw->isHidden() && mw->isTopLevel() && mw != this )
not_withdrawn++;
}
if ( !no_query_exit && not_withdrawn <= 0 ) { // last window close accepted?
if (!( queryExit() && ( !kapp || !kapp->sessionSaving() ) && !d->shuttingDown )) {
// cancel closing, it's stupid to end up with no windows at all....
e->ignore();
}
}
} else e->ignore(); //if the window should not be closed, don't close it } else e->ignore(); //if the window should not be closed, don't close it
} }
bool KMainWindow::queryExit()
{
return true;
}
bool KMainWindow::queryClose() bool KMainWindow::queryClose()
{ {
return true; return true;
@ -1045,21 +1013,6 @@ KStatusBar *KMainWindow::statusBar()
return sb; return sb;
} }
void KMainWindowPrivate::_k_shuttingDown()
{
// Needed for Qt <= 3.0.3 at least to prevent reentrancy
// when queryExit() shows a dialog. Check before removing!
static bool reentrancy_protection = false;
if (!reentrancy_protection)
{
reentrancy_protection = true;
shuttingDown = true;
// call the virtual queryExit
q->queryExit();
reentrancy_protection = false;
}
}
void KMainWindowPrivate::_k_slotSettingsChanged(int category) void KMainWindowPrivate::_k_slotSettingsChanged(int category)
{ {
Q_UNUSED(category); Q_UNUSED(category);

View file

@ -467,54 +467,10 @@ protected:
virtual bool event( QEvent * event ); virtual bool event( QEvent * event );
/** /**
* Reimplemented to call the queryClose() and queryExit() handlers. * Reimplemented to call the queryClose() handlers.
*/ */
virtual void closeEvent ( QCloseEvent *); virtual void closeEvent ( QCloseEvent *);
// KDE4 This seems to be flawed to me. Either the app has only one
// mainwindow, so queryClose() is enough, or if it can have more of them,
// then the windows should take care of themselves, and queryExit()
// would be useful only for the annoying 'really quit' dialog, which
// also doesn't make sense in apps with multiple mainwindows.
// And saving configuration in something called queryExit()? IMHO
// one can e.g. use QCoreApplication::aboutToQuit(), which if nothing else
// has at least better fitting name.
// See also KApplication::sessionSaving().
// This stuff should get changed somehow, so that it at least doesn't
// mess with session management.
/**
Called before the very last window is closed, either by the
user or indirectly by the session manager.
It is not recommended to do any user interaction in this
function other than indicating severe errors. Better ask the
user on queryClose() (see below).
A typical usage of queryExit() is to write configuration data back.
Note that the application may continue to run after queryExit()
(the user may have canceled a shutdown), so you should not do any cleanups
here. The purpose of queryExit() is purely to prepare the application
(with possible user interaction) so it can safely be closed later (without
user interaction).
If you need to do serious things on exit (like shutting a
dial-up connection down), connect to the signal
QCoreApplication::aboutToQuit().
Default implementation returns @p true. Returning @p false will
cancel the exiting. In the latter case, the last window will
remain visible. If KApplication::sessionSaving() is true, refusing
the exit will also cancel KDE logout.
@see queryClose()
@see KApplication::sessionSaving()
@deprecated since 4.14 Do not reimplement queryExit. Either reimplement queryClose
(called for every window) or connect QCoreApplication::aboutToQuit() into a slot
of a non-gui object (not a KMainWindow, it will be deleted before that!).
*/
virtual bool queryExit();
/** /**
Called before the window is closed, either by the user or indirectly by Called before the window is closed, either by the user or indirectly by
the session manager. the session manager.
@ -546,7 +502,6 @@ protected:
its location might not be properly saved. In addition, the session shutdown its location might not be properly saved. In addition, the session shutdown
may be canceled, in which case the document should remain open. may be canceled, in which case the document should remain open.
@see queryExit()
@see KApplication::sessionSaving() @see KApplication::sessionSaving()
*/ */
virtual bool queryClose(); virtual bool queryClose();
@ -670,7 +625,6 @@ protected:
KMainWindowPrivate * const k_ptr; KMainWindowPrivate * const k_ptr;
private: private:
Q_PRIVATE_SLOT(k_func(), void _k_shuttingDown())
Q_PRIVATE_SLOT(k_func(), void _k_slotSettingsChanged(int)) Q_PRIVATE_SLOT(k_func(), void _k_slotSettingsChanged(int))
Q_PRIVATE_SLOT(k_func(), void _k_slotSaveAutoSaveSize()) Q_PRIVATE_SLOT(k_func(), void _k_slotSaveAutoSaveSize())
}; };

View file

@ -46,7 +46,6 @@ public:
bool autoSaveWindowSize:1; bool autoSaveWindowSize:1;
bool care_about_geometry:1; bool care_about_geometry:1;
bool sizeApplied:1; bool sizeApplied:1;
bool shuttingDown:1;
KConfigGroup autoSaveGroup; KConfigGroup autoSaveGroup;
QTimer *settingsTimer; QTimer *settingsTimer;
QTimer *sizeTimer; QTimer *sizeTimer;
@ -57,7 +56,6 @@ public:
QString dbusName; QString dbusName;
bool letDirtySettings; bool letDirtySettings;
void _k_shuttingDown();
// This slot will be called when the style KCM changes settings that need // This slot will be called when the style KCM changes settings that need
// to be set on the already running applications. // to be set on the already running applications.
void _k_slotSettingsChanged(int category); void _k_slotSettingsChanged(int category);