Fwd: Re: Reproducable Crash in UIController

Andreas Pakulat apaku at gmx.de
Wed Jun 24 22:11:49 UTC 2009


On 24.06.09 23:06:53, Milian Wolff wrote:
> 
> > Milian Wolff, 17.06.2009:
> > > Hi, found a reproducable crash. To see it, do the following:
> > >
> > > Open Kdevelop
> > > Open a second main window (shift + ctrl + n)
> > > close one of the main windows
> > > close kdevelop => crash
> > >
> > > Why?
> > > Thread 1 (Thread 0xb5429710 (LWP 5531)):
> > > [KCrash Handler]
> > > #6  0xb7c407db in KDevelop::UiController::cleanup (this=0xa151970) at
> > > /home/milianw/projects/kde4/kdevplatform/shell/uicontroller.cpp:355
> > > #7  0xb7c3c84d in KDevelop::Core::cleanup (this=0xa0ffe00) at
> > > /home/milianw/projects/kde4/kdevplatform/shell/core.cpp:247
> > > #8  0xb7c2fba6 in ~MainWindow (this=0xa1583d8) at
> > > /home/milianw/projects/kde4/kdevplatform/shell/mainwindow.cpp:99
> > >
> > > In cleanup:
> > >
> > >      foreach (Sublime::MainWindow* w, mainWindows())
> > >          w->saveSettings();
> > >
> > > Problem:
> > > mainWindows() (controlledMainWindows in pointer of Controller) is never
> > > cleaned up! I thought it would be an easy fix but had bad luck:
> > >
> > > I thought I'd just have to add something like
> > >
> > >
> > > void Controller::removeMainWindow(MainWindow* mainWindow)
> > > {
> > >      int index = d->controlledWindows.indexOf(mainWindow);
> > >      Q_ASSERT (index != -1);
> > >
> > >      d->controlledWindows.removeAt(index);
> > >
> > >      ///TODO: do I have to delete areas?
> > >      d->mainWindowAreas.remove(index);
> > > }
> > >
> > > To controller.cpp and call that from uicontroller->cleanup() but then I
> > > get a crash in the qobject_cast in
> > >
> > >
> > > void DocumentSwitcherPlugin::removeMainWindow( QObject* obj )
> > > {
> > >      Sublime::MainWindow* mainwindow =
> > > qobject_cast<Sublime::MainWindow*>( obj );
> > >
> > > Which I cannot explain. So who fixes that?
> 
> Ok, I think I managed to fix this, see attached patch. I also sent a mail
> to adymo with a question on how to "properly" fix it in his opinion, since
> I have no experience with Sublime.
> 
> NOTE: This patch is much simpler than what I tried above.
> 
> Essentially it fixes two bugs:
> 
> 1) It makes sure the list of controlledWindows gets properly reduced when a
> mainwindow closes (see my report above and also bug 196414).

That part is ok.
 
> 2) It fixes the documentswitcherplugin to not call removeMainWindow in the
> unload() method since at that point the windows should already be deleted.
> And thanks to the (already existing) connection to MainWindow::destroyed()
> the removeMainWindow is called whenever needed. This explains / fixes the
> crash I explained above after trying to fix the initial bug.

Hmm, I'm confused, if the plugin already removes mainwindows when they're
destroyed, then why does it find anything in its documentLists at all?
Maybe it doesn't remove a mainwindow from that map when its destroyed?

I'd first like to clarify that before removing the code from ::unload()
(will take a look at that tomorrow myself).

Andreas

-- 
You may be gone tomorrow, but that doesn't mean that you weren't here today.




More information about the KDevelop-devel mailing list