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

List:       kde-core-devel
Subject:    KToolBar problem
From:       Michael Reiher <michael.reiher () gmx ! de>
Date:       2000-10-06 12:34:36
[Download RAW message or body]

Dies ist eine mehrteilige Nachricht im MIME-Format.

Hi

There is some evil problem in KToolBar which leads to weird crashes in
Konqueror in certain cases when you manipulate your boorkmarks. The most
relieable way is probably deleting a bunch of bookmarks at once. 

The problem is that KToolBar keeps a second list of widgets which is read
during rebuildLayout() and if there are illegal pointers in it -> crash.
Widgets are removed from that list either explicitly or by a ChildRemove event.
So normally when you delete a widget it gets cleand out by the event. However
if you delete it so quickly that the ChildInserted event dosnīt get posted
QObject simply deletes the Remove(and the Inserted) event. So KToolBar doesnīt
get notifyed about the remove. And this is the case when modifying bookmarks. 
KBookmarkBar runs slotBookmarksChanged() which rebuilds the bookmarkbar. There
is some kind of placeholder widget or whatever which gets simply deleted.
KBookmarkbar doesnīt get the Removed event and keeps it -> crash on next
layout.

Iīm kinda unsure what to do now. Possible solutions:
1. Remove the placeholder widget. Doesnīt seem to serve any useful purpose
anyway. 
2. Explicitly remove it when clearing KBookmarkBar
But these two are actually cheating and donīt fix the real Problem;-)

3. Implement some mechanism which compares KToolBars "widgets" list with the
children() list and throw out illegal pointers. Though this one would have to
be put in *every* place which accesses the widget list. Hmm...

IMO all three are sub optimal. With regard to the current freeze Iīd go for 1.
or 2. as they are the least dangerous. Attached a patch for 2.

Any comments, please? Has anyone a better idea? Perhaps someone with more
insight into
KToolBar?

Greets

Michael.


-- 
Michael Reiher                                    :  michael.reiher@gmx.de
Student of Computer Science at TU Dresden/Germany : mr23@inf.tu-dresden.de
KDE Developer                                     :         reiher@kde.org

As the New Gnu knew very soon at the Zoo Guinness is good for you
["kbookmarkbar.diff" (text/plain)]

Index: kbookmarkbar.cc
===================================================================
RCS file: /home/kde/kdebase/libkonq/kbookmarkbar.cc,v
retrieving revision 1.16
diff -b -u -p -r1.16 kbookmarkbar.cc
--- kbookmarkbar.cc	2000/09/22 22:03:37	1.16
+++ kbookmarkbar.cc	2000/10/06 12:29:23
@@ -35,6 +35,8 @@
 
 #include <qiconset.h>
 
+#define DUMMY_WIDGET_ID 1000
+
 KBookmarkBar::KBookmarkBar( KBookmarkOwner *_owner, KToolBar *_toolBar,
                             KActionCollection *_collec, QObject *parent, const char *name )
     : QObject( parent, name ), m_pOwner(_owner), m_toolBar(_toolBar), m_actionCollection(_collec)
@@ -70,8 +72,10 @@ void KBookmarkBar::clear()
     m_actions.setAutoDelete( false );
 
     // remove that strange separator thing..
-    if (m_toolBar)
-        m_toolBar->clear();
+    if (m_toolBar) {
+      m_toolBar->removeItem( DUMMY_WIDGET_ID );
+      //m_toolBar->clear();
+    }
 }
 
 void KBookmarkBar::slotBookmarksChanged()
@@ -83,7 +87,7 @@ void KBookmarkBar::slotBookmarksChanged(
     { // KToolBar needs a setMinimumSize method similar to this
       KToolBarButton *separ = new KToolBarButton(m_toolBar);
 
-      m_toolBar->insertWidget(-1, 1, separ);
+      m_toolBar->insertWidget(DUMMY_WIDGET_ID, 1, separ);
       separ->resize(1, 26);
       separ->hide();
     }


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

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