From 5dbc0a7da05fe49f05b2f95b7b3d15b54a03b3c5 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Tue, 18 Nov 2008 00:33:44 +0000 Subject: [PATCH] don't hang onto deleted actions svn path=/trunk/KDE/kdelibs/; revision=885851 --- widgets/iconwidget.cpp | 11 +++++++++++ widgets/iconwidget.h | 1 + widgets/iconwidget_p.h | 1 + 3 files changed, 13 insertions(+) diff --git a/widgets/iconwidget.cpp b/widgets/iconwidget.cpp index 6346bc7d2..5c83db6f7 100644 --- a/widgets/iconwidget.cpp +++ b/widgets/iconwidget.cpp @@ -343,6 +343,7 @@ void IconWidget::setAction(QAction *action) d->action = action; if (action) { connect(action, SIGNAL(changed()), this, SLOT(syncToAction())); + connect(action, SIGNAL(destroyed(QObject*)), this, SLOT(clearAction())); connect(this, SIGNAL(clicked()), action, SLOT(trigger())); d->syncToAction(); } @@ -1188,9 +1189,19 @@ void IconWidget::setUnpressed() setPressed(false); } +void IconWidgetPrivate::clearAction() +{ + action = 0; + syncToAction(); + emit q->changed(); +} + void IconWidgetPrivate::syncToAction() { if (!action) { + q->setIcon(QIcon()); + q->setText(QString()); + q->setEnabled(false); return; } //we don't get told *what* changed, just that something changed diff --git a/widgets/iconwidget.h b/widgets/iconwidget.h index 9adbda317..a4c81213a 100644 --- a/widgets/iconwidget.h +++ b/widgets/iconwidget.h @@ -278,6 +278,7 @@ public: private: Q_PRIVATE_SLOT(d, void syncToAction()) + Q_PRIVATE_SLOT(d, void clearAction()) void init(); void layoutIcons(const QStyleOptionGraphicsItem *option); void hoverEffect(bool); diff --git a/widgets/iconwidget_p.h b/widgets/iconwidget_p.h index 02bec38e0..ed2e8d9be 100644 --- a/widgets/iconwidget_p.h +++ b/widgets/iconwidget_p.h @@ -175,6 +175,7 @@ public: * update the icon's text, icon, etc. to reflect the properties of its associated action. */ void syncToAction(); + void clearAction(); IconWidget *q; QString text;