kdelibs/kdelibs-4.1.0-kde#167826.patch
2008-08-01 14:05:20 +00:00

71 lines
3.0 KiB
Diff

diff -up kdelibs-4.1.0/kdecore/kernel/kglobal.cpp.kde#167826 kdelibs-4.1.0/kdecore/kernel/kglobal.cpp
--- kdelibs-4.1.0/kdecore/kernel/kglobal.cpp.kde#167826 2008-05-21 06:08:57.000000000 -0500
+++ kdelibs-4.1.0/kdecore/kernel/kglobal.cpp 2008-08-01 08:15:52.000000000 -0500
@@ -251,11 +251,14 @@ QString KGlobal::caption()
/**
* This counter indicates when to quit the application.
- * It starts at 1, is decremented in KMainWindow when the last window is closed, but
- * is incremented by operations that should outlive the last window closed
- * (e.g. a file copy for a file manager, or 'compacting folders on exit' for a mail client).
+ * It starts at 0, is incremented by KMainWindow, systray icons, running jobs, etc.
+ * and decremented again when those things are destroyed.
+ * This mechanism allows dialogs and jobs to outlive the last window closed
+ * e.g. a file copy for a file manager, or 'compacting folders on exit' for a mail client,
+ * the job progress widget with "keep open" checked, etc.
*/
-static int s_refCount = 1;
+static int s_refCount = 0;
+static bool s_allowQuit = false;
void KGlobal::ref()
{
@@ -267,9 +270,14 @@ void KGlobal::deref()
{
--s_refCount;
//kDebug() << "KGlobal::deref() : refCount = " << s_refCount;
- if (s_refCount <= 0) {
+ if (s_refCount <= 0 && s_allowQuit) {
QCoreApplication::instance()->quit();
}
}
+void KGlobal::setAllowQuit(bool allowQuit)
+{
+ s_allowQuit = allowQuit;
+}
+
#undef PRIVATE_DATA
diff -up kdelibs-4.1.0/kdecore/kernel/kglobal.h.kde#167826 kdelibs-4.1.0/kdecore/kernel/kglobal.h
--- kdelibs-4.1.0/kdecore/kernel/kglobal.h.kde#167826 2008-05-21 06:08:57.000000000 -0500
+++ kdelibs-4.1.0/kdecore/kernel/kglobal.h 2008-08-01 08:21:49.000000000 -0500
@@ -421,6 +421,13 @@ namespace KGlobal
KDECORE_EXPORT void deref();
/**
+ * If refcounting reaches 0 (or less), and @p allowQuit is true, the instance of the application
+ * will automatically be exited. Otherwise, the application will not exit automatically.
+ * @since 4.2
+ */
+ KDECORE_EXPORT void setAllowQuit(bool allowQuit);
+
+ /**
* The component currently active (useful in a multi-component
* application, such as a KParts application).
* Don't use this - it's mainly for KAboutDialog and KBugReport.
diff -up kdelibs-4.1.0/kdeui/widgets/kmainwindow.cpp.kde#167826 kdelibs-4.1.0/kdeui/widgets/kmainwindow.cpp
--- kdelibs-4.1.0/kdeui/widgets/kmainwindow.cpp.kde#167826 2008-07-23 03:26:33.000000000 -0500
+++ kdelibs-4.1.0/kdeui/widgets/kmainwindow.cpp 2008-08-01 08:15:52.000000000 -0500
@@ -226,6 +226,11 @@ void KMainWindowPrivate::init(KMainWindo
{
KGlobal::ref();
+ // We set allow quit to true, so when the refcounting reaches 0 the application instance will
+ // be exited. This has a similar purpose than setQuitOnLastWindowClosed (from
+ // QApplication), but it honors (de)refing from KGlobal.
+ KGlobal::setAllowQuit(true);
+
q = _q;
q->setAnimated(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects);