Bug#45691: some investigation

Nicolai Haehnle <[email protected]> Thu, 25 Jul 2002 19:39:30 +0200
Newsgroups gmane.comp.kde.devel.kate
Message-ID <[email protected]>
I've been hit by this bug as well, and I've done some debugging before I 
realized that there's a bug report on this already:

When a message box is displayed during startup of Kate (indicating an
error condition), the DCOP command "newInstance()" is dispatched too early.
I don't know if this is a problem with DCOP or just a problem with Kate
because it makes assumptions it shouldn't make.

Anyway.. KateApp::newInstance() expects one main window to exist under
certain conditions. This is not the case, though, and causes crashes in
various places later on.

The following patch simply bails out in newInstance() when the main window
hasn't been created yet (note: i'm unsure about the return value). It allows
me to continue, and Kate starts up successfully. I'm not suggesting that 
this is a correct solution, but it works around the problem:

Index: kateapp.cpp
===================================================================
RCS file: /home/kde/kdebase/kate/app/kateapp.cpp,v
retrieving revision 1.43
diff -p -u -r1.43 kateapp.cpp
--- kateapp.cpp 18 Jul 2002 19:26:18 -0000      1.43
+++ kateapp.cpp 25 Jul 2002 16:37:00 -0000
@@ -121,6 +121,9 @@ int KateApp::newInstance()
   if (!m_firstStart && args->isSet ("w"))
     newMainWindow ();

+  if (m_mainWindows.count() == 0)
+    return -1;
+
   raiseCurrentMainWindow ();

   if (m_firstStart && m_initPlugin)

cu,
Nicolai

(Complete bug history is available at http://bugs.kde.org/db/45/45691.html)