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

List:       kde-pim
Subject:    Re: [Kde-pim] KMail crashes when message box is shown on startup
From:       Thomas McGuire <thomas.mcguire () gmx ! net>
Date:       2007-06-15 17:32:27
Message-ID: 200706151932.27087.thomas.mcguire () gmx ! net
[Download RAW message or body]

Hi,

> > After a quick look at kmkernel.cpp I suggest to delay the instantiation
> > of MailTransport::TransportManager by moving the connects from
> > KMKernel's c'tor to the init() method. See the attached (and completely
> > untested) patch.
>
> Thanks for answering. The patch works, besides the fact the the message box
> pops up behind the mainwindow.
>
> However, there are still other message boxes (don't remember which ones,
> but I've definitaly seen some) having the same problem. Finding each of
> those message boxes and fixing them is not easily possible.
>
> What we really need to do is to fix the KUniqueApplication thing: Only
> create the new instance just before qApp->exec() in main.cpp, not when the
> event loop is entered (which can happen before qApp->exec() because of
> those message boxes).
> Still, I have no idea how to do that.
OK, attached a new patch, which will delay the call to newInstance until just 
before the main event loop if necessary. It is probably still not the nicest 
solution, but it should work in all situations.

If nobody objects or has a better idea, I'll commit that soon.

Regards,
Thomas


["delay-instance-creation.diff" (text/x-diff)]

Index: main.cpp
===================================================================
--- main.cpp	(revision 674960)
+++ main.cpp	(working copy)
@@ -37,9 +37,16 @@
 class KMailApplication : public KUniqueApplication
 {
 public:
-  KMailApplication() : KUniqueApplication() { };
+  KMailApplication() : KUniqueApplication(),
+                       mDelayedInstanceCreation( false ),
+                       mEventLoopReached( false ) { };
   virtual int newInstance();
   void commitData(QSessionManager& sm);
+  void setEventLoopReached();
+  void delayedInstanceCreation();
+protected:
+  bool mDelayedInstanceCreation;
+  bool mEventLoopReached;
 
 };
 
@@ -49,6 +56,9 @@
   KApplication::commitData( sm );
 }
 
+void KMailApplication::setEventLoopReached() {
+  mEventLoopReached = true;
+}
 
 int KMailApplication::newInstance()
 {
@@ -56,12 +66,23 @@
   if (!kmkernel)
      return 0;
 
+  if ( !mEventLoopReached ) {
+    kDebug(5006) << "Delaying instance creation." << endl;
+    mDelayedInstanceCreation = true;
+    return 0;
+  }
+
   if (!kmkernel->firstInstance() || !kapp->isSessionRestored())
     kmkernel->handleCommandLine( true );
   kmkernel->setFirstInstance(false);
   return 0;
 }
 
+void KMailApplication::delayedInstanceCreation() {
+  if ( mDelayedInstanceCreation )
+    newInstance();
+}
+
 int main(int argc, char *argv[])
 {
   // WABA: KMail is a KUniqueApplication. Unfortunately this makes debugging
@@ -110,6 +131,11 @@
 #endif
 //  kapp->dcopClient()->resume(); // Ok. We are ready for DCOP requests.
   kmkernel->setStartingUp( false ); // Starting up is finished
+
+  //If the instance hasn't been created yet, do that now
+  app.setEventLoopReached();
+  app.delayedInstanceCreation();
+
   // Go!
   int ret = qApp->exec();
   // clean up


_______________________________________________
kde-pim mailing list
kde-pim@kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/

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

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