diff --git a/containment.cpp b/containment.cpp index 1efec42d2..f1ed42bad 100644 --- a/containment.cpp +++ b/containment.cpp @@ -1291,6 +1291,9 @@ void ContainmentPrivate::appletDestroyed(QObject* object) // point anymore since we are in the qobject dtor. we don't actually // try and do anything with it, we just need the value of the pointer // so this unsafe looking code is actually just fine. + // + // NOTE: DO NOT USE THE applet VARIABLE FOR ANYTHING OTHER THAN COMPARING + // THE ADDRESS! ACTUALLY USING THE OBJECT WILL RESULT IN A CRASH!!! Applet* applet = static_cast(object); applets.removeAll(applet); if (focusedApplet == applet) { diff --git a/tooltipmanager.cpp b/tooltipmanager.cpp index 240f882ab..eee728ca4 100644 --- a/tooltipmanager.cpp +++ b/tooltipmanager.cpp @@ -194,7 +194,7 @@ void ToolTipManager::setWidgetToolTipContent(QGraphicsWidget *widget,const ToolT tooltip->updateTheme(); } -bool ToolTipManager::widgetHasToolTip(QGraphicsWidget *widget) +bool ToolTipManager::widgetHasToolTip(QGraphicsWidget *widget) const { return d->tooltips.contains(widget); } @@ -214,6 +214,13 @@ void ToolTipManagerPrivate::onWidgetDestroyed(QObject *object) return; } + // we do a static_cast here since it really isn't a QGraphicsWidget by this + // point anymore since we are in the QObject dtor. we don't actually + // try and do anything with it, we just need the value of the pointer + // so this unsafe looking code is actually just fine. + // + // 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); if (currentWidget == w) { diff --git a/tooltipmanager.h b/tooltipmanager.h index f9233405c..fbad15819 100644 --- a/tooltipmanager.h +++ b/tooltipmanager.h @@ -130,7 +130,7 @@ namespace Plasma * @param widget the widget * @return true if this widget has a tooltip */ - bool widgetHasToolTip(QGraphicsWidget *widget); + bool widgetHasToolTip(QGraphicsWidget *widget) const; /** * Reccomended position for a popup window like a menu or a tooltip