From 9f03caaa18dae39b4f2c45f3a5382c38cd872ebd Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Fri, 9 Jan 2009 01:16:57 +0000 Subject: [PATCH] clear the current widget when an widget is unregistered; solves a crash where the task widget disconnects *all* signals to items before deleting them, thus preventing the destroyed(QObject*) signal from getting through. it was calling unregisterWidget, but that wasn't clearing the current widget -> POOF! CCMAIL:faure@kde.org CCBUG:179819 svn path=/branches/KDE/4.2/kdelibs/; revision=907982 --- tooltipmanager.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tooltipmanager.cpp b/tooltipmanager.cpp index 000f114a9..2ecf7fb92 100644 --- a/tooltipmanager.cpp +++ b/tooltipmanager.cpp @@ -80,9 +80,8 @@ public : * called when a widget inside the tooltip manager is deleted */ void onWidgetDestroyed(QObject * object); - + void removeWidget(QGraphicsWidget *w); void clearTips(); - void doDelayedHide(); QGraphicsWidget *currentWidget; @@ -182,7 +181,6 @@ void ToolTipManager::registerWidget(QGraphicsWidget *widget) //the tooltip is not registered we add it in our map of tooltips d->tooltips.insert(widget, ToolTipContent()); widget->installEventFilter(this); - //connect to object destruction connect(widget, SIGNAL(destroyed(QObject*)), this, SLOT(onWidgetDestroyed(QObject*))); } @@ -193,7 +191,7 @@ void ToolTipManager::unregisterWidget(QGraphicsWidget *widget) } widget->removeEventFilter(this); - d->tooltips.remove(widget); + d->removeWidget(widget); } void ToolTipManager::setContent(QGraphicsWidget *widget, const ToolTipContent &data) @@ -262,7 +260,12 @@ void ToolTipManagerPrivate::onWidgetDestroyed(QObject *object) // NOTE: DO NOT USE THE w VARIABLE FOR ANYTHING OTHER THAN COMPARING // THE ADDRESS! ACTUALLY USING THE OBJECT WILL RESULT IN A CRASH!!! QGraphicsWidget *w = static_cast(object); + removeWidget(w); +} +void ToolTipManagerPrivate::removeWidget(QGraphicsWidget *w) +{ + // DO NOTE ACCESS w HERE!! IT MAY BE IN THE PROCESS OF DELETION! if (currentWidget == w) { currentWidget = 0; showTimer->stop(); // stop the timer to show the tooltip