[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: KToolBar problem
From: Reginald Stadlbauer <reggie () trolltech ! com>
Date: 2000-10-08 13:13:23
[Download RAW message or body]
On Sat, 07 Oct 2000, Michael Reiher wrote:
> Michael Reiher wrote:
> > Unforunately it crashes now with the following backtrace:(
>
> Hmm, very strange. It doesn´t crash anymore. I wonder if the crash was
> related to the patch at all. Can someone else please apply the patch and
> test it? Quit konqy a few times and say if it crashes.
I got the crash. It was related to the patch. I changed now the patch so that
it doesn't crash when removing items from the toolbar fast and not when
exiting too:
Index: ktoolbar.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/ktoolbar.cpp,v
retrieving revision 1.245
diff -u -u -r1.245 ktoolbar.cpp
--- ktoolbar.cpp 2000/10/06 19:25:27 1.245
+++ ktoolbar.cpp 2000/10/08 13:11:56
@@ -176,6 +176,9 @@
KToolBar::~KToolBar()
{
+ for ( QWidget *w = widgets.first(); w; w = widgets.next() )
+ disconnect( w, SIGNAL( destroyed() ),
+ this, SLOT( widgetDestroyed() ) );
delete d;
}
@@ -1333,9 +1336,10 @@
int dummy = -1;
if ( e->child()->isWidgetType() ) {
if ( e->type() == QEvent::ChildInserted ) {
- insertWidgetInternal( (QWidget*)e->child(), dummy, -1 );
- if ( !e->child()->inherits( "QPopupMenu" ) )
+ if ( !e->child()->inherits( "QPopupMenu" ) ) {
+ insertWidgetInternal( (QWidget*)e->child(), dummy, -1 );
( (QWidget*)e->child() )->show();
+ }
} else {
widgets.removeRef( (QWidget*)e->child() );
}
@@ -1347,12 +1351,20 @@
void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id )
{
+ // prevent items that have been explicitly inserted by insert*() from
+ // being inserted again
if ( inserted.findRef( w ) != -1 )
return;
+
if ( widgets.findRef( w ) != -1 )
widgets.removeRef( w );
- if ( index == -1 || index > (int)widgets.count() )
+
+ connect( w, SIGNAL( destroyed() ),
+ this, SLOT( widgetDestroyed() ) );
+ if ( index == -1 || index > (int)widgets.count() ) {
widgets.append( w );
+ index = (int)widgets.count();
+ }
else
widgets.insert( index, w );
if ( id == -1 )
@@ -1975,6 +1987,16 @@
break;
default: break;
}
+}
+
+void KToolBar::widgetDestroyed()
+{
+ widgets.removeRef( (QWidget*)sender() );
+ QMap< QWidget*, int >::Iterator it = widget2id.find( (QWidget*)sender());
+ if ( it == widget2id.end() )
+ return;
+ widget2id.remove( it );
+ id2widget.remove( *it );
}
#include "ktoolbar.moc"
Index: ktoolbar.h
===================================================================
RCS file: /home/kde/kdelibs/kdeui/ktoolbar.h,v
retrieving revision 1.123
diff -u -u -r1.123 ktoolbar.h
--- ktoolbar.h 2000/09/25 17:04:36 1.123
+++ ktoolbar.h 2000/10/08 13:11:58
@@ -998,6 +998,7 @@
void slotRepaint();
void toolBarPosChanged( QToolBar *tb );
void slotContextAboutToShow();
+ void widgetDestroyed();
private:
void init( bool readConfig = true, bool honorStyle = false );
-------------------------------------------
Please test and if it work now for others as well, I'll submit it.
--
Reggie (reggie@trolltech.com)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic