don't hang onto deleted actions
svn path=/trunk/KDE/kdelibs/; revision=885851
This commit is contained in:
parent
d6bd085b75
commit
5dbc0a7da0
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user