[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kmail-devel
Subject:    Patch: kill running jobs so that kmail exits
From:       David Faure <dfaure () klaralvdalens-datakonsult ! se>
Date:       2004-04-27 13:17:53
Message-ID: 200404271517.53850.dfaure () klaralvdalens-datakonsult ! se
[Download RAW message or body]

Currently if you close the last kmail mainwindow and some account is still
checking mails (e.g. the IMAP server hangs, or you're just in a hurry and want to
leave soon :), the kmail process doesn't exit [until the mail check is over].

This is because both mainwindows and jobs keep a ref() on KApplication.
This seems wrong in KMail's context, but think about people downloading URLs
in konqueror: when you close the last konqueror window, you _do_ want your
downloads to finish before the konqueror process exits.

In KMail it's different, closing the windows means that mail checking should stop
(when there's no systray icon), right?

See attached patch.

-- 
David Faure -- faure@kde.org, dfaure@klaralvdalens-datakonsult.se
Qt/KDE/KOffice developer
Klarälvdalens Datakonsult AB, Platform-independent software solutions

["killjobs_on_exit.diff" (text/x-diff)]

? handlejoberror.diff
Index: imapaccountbase.h
===================================================================
RCS file: /home/kde/kdepim/kmail/imapaccountbase.h,v
retrieving revision 1.38
diff -u -p -r1.38 imapaccountbase.h
--- imapaccountbase.h	25 Apr 2004 15:55:39 -0000	1.38
+++ imapaccountbase.h	27 Apr 2004 13:11:39 -0000
@@ -206,11 +206,6 @@ namespace KMail {
     void slaveDied() { mSlave = 0; killAllJobs(); }
 
     /**
-     * Kill the slave if any jobs are active
-     */
-    void killAllJobs( bool disconnectSlave=false ) = 0;
-
-    /**
      * Init a new-mail-check for a single folder
      */
     void processNewMailSingleFolder(KMFolder* folder);
Index: kmaccount.h
===================================================================
RCS file: /home/kde/kdepim/kmail/kmaccount.h,v
retrieving revision 1.66
diff -u -p -r1.66 kmaccount.h
--- kmaccount.h	29 Mar 2004 15:33:01 -0000	1.66
+++ kmaccount.h	27 Apr 2004 13:11:39 -0000
@@ -191,6 +191,11 @@ public:
    */
   void checkDone( bool newmails, int newmailCount );
 
+  /**
+   * Abort all running jobs. Used when exiting.
+   */
+  virtual void killAllJobs( bool /*disconnectSlave*/ = false ) {}
+
 signals:
   virtual void finishedCheck(bool newMail);
   virtual void newMailsProcessed(int numberOfNewMails);
Index: kmacctimap.h
===================================================================
RCS file: /home/kde/kdepim/kmail/kmacctimap.h,v
retrieving revision 1.81
diff -u -p -r1.81 kmacctimap.h
--- kmacctimap.h	25 Apr 2004 15:55:39 -0000	1.81
+++ kmacctimap.h	27 Apr 2004 13:11:39 -0000
@@ -64,7 +64,7 @@ public:
   /**
    * Kill the slave if any jobs are active
    */
-  void killAllJobs( bool disconnectSlave=false );
+  virtual void killAllJobs( bool disconnectSlave=false );
 
   /**
    * Set the top level pseudo folder
Index: kmacctmgr.cpp
===================================================================
RCS file: /home/kde/kdepim/kmail/kmacctmgr.cpp,v
retrieving revision 1.111
diff -u -p -r1.111 kmacctmgr.cpp
--- kmacctmgr.cpp	24 Mar 2004 18:51:59 -0000	1.111
+++ kmacctmgr.cpp	27 Apr 2004 13:11:39 -0000
@@ -385,4 +385,12 @@ uint KMAcctMgr::createId()
 }
 
 //-----------------------------------------------------------------------------
+void KMAcctMgr::killAllJobs( bool disconnectSlave )
+{
+  for ( QPtrListIterator<KMAccount> it(mAcctList) ;
+	it.current() ; ++it ) {
+    it.current()->killAllJobs( disconnectSlave );
+  }
+}
+
 #include "kmacctmgr.moc"
Index: kmacctmgr.h
===================================================================
RCS file: /home/kde/kdepim/kmail/kmacctmgr.h,v
retrieving revision 1.41
diff -u -p -r1.41 kmacctmgr.h
--- kmacctmgr.h	10 Mar 2004 18:41:27 -0000	1.41
+++ kmacctmgr.h	27 Apr 2004 13:11:39 -0000
@@ -65,6 +65,9 @@ public:
   /** Create a new unique ID */
   uint createId();
 
+  /// Called on exit (KMMainWin::queryExit)
+  void killAllJobs( bool disconnectSlave = false );
+
 public slots:
   virtual void singleCheckMail(KMAccount *, bool _interactive = true);
   virtual void singleInvalidateIMAPFolders(KMAccount *);
Index: kmmainwin.cpp
===================================================================
RCS file: /home/kde/kdepim/kmail/kmmainwin.cpp,v
retrieving revision 1.586
diff -u -p -r1.586 kmmainwin.cpp
--- kmmainwin.cpp	21 Mar 2004 22:44:03 -0000	1.586
+++ kmmainwin.cpp	27 Apr 2004 13:11:39 -0000
@@ -9,7 +9,8 @@
 #include "kmsender.h"
 #include "kmbroadcaststatus.h"
 #include "kmglobal.h"
-#include "kapplication.h"
+#include "kmacctmgr.h"
+#include <kapplication.h>
 #include <klocale.h>
 #include <kedittoolbar.h>
 #include <kconfig.h>
@@ -182,3 +183,13 @@ bool KMMainWin::queryClose() {
 
   return true;
 }
+
+bool KMMainWin::queryExit() {
+  // Called when the last visible window (of any sort) was closed
+
+  if ( !kmkernel->haveSystemTrayApplet() ) {
+    // Running KIO jobs prevent kapp from exiting, so we need to kill them
+    kmkernel->acctMgr()->killAllJobs( true );
+  }
+  return true;
+}
Index: kmmainwin.h
===================================================================
RCS file: /home/kde/kdepim/kmail/kmmainwin.h,v
retrieving revision 1.165
diff -u -p -r1.165 kmmainwin.h
--- kmmainwin.h	15 Apr 2004 13:04:46 -0000	1.165
+++ kmmainwin.h	27 Apr 2004 13:11:40 -0000
@@ -40,6 +40,7 @@ public slots:
 
 protected:
   virtual bool queryClose ();
+  virtual bool queryExit();
 
 protected slots:
   void slotQuit();


_______________________________________________
KMail developers mailing list
KMail-devel@kde.org
https://mail.kde.org/mailman/listinfo/kmail-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic