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;
|
d->action = action;
|
||||||
if (action) {
|
if (action) {
|
||||||
connect(action, SIGNAL(changed()), this, SLOT(syncToAction()));
|
connect(action, SIGNAL(changed()), this, SLOT(syncToAction()));
|
||||||
|
connect(action, SIGNAL(destroyed(QObject*)), this, SLOT(clearAction()));
|
||||||
connect(this, SIGNAL(clicked()), action, SLOT(trigger()));
|
connect(this, SIGNAL(clicked()), action, SLOT(trigger()));
|
||||||
d->syncToAction();
|
d->syncToAction();
|
||||||
}
|
}
|
||||||
@ -1188,9 +1189,19 @@ void IconWidget::setUnpressed()
|
|||||||
setPressed(false);
|
setPressed(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IconWidgetPrivate::clearAction()
|
||||||
|
{
|
||||||
|
action = 0;
|
||||||
|
syncToAction();
|
||||||
|
emit q->changed();
|
||||||
|
}
|
||||||
|
|
||||||
void IconWidgetPrivate::syncToAction()
|
void IconWidgetPrivate::syncToAction()
|
||||||
{
|
{
|
||||||
if (!action) {
|
if (!action) {
|
||||||
|
q->setIcon(QIcon());
|
||||||
|
q->setText(QString());
|
||||||
|
q->setEnabled(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//we don't get told *what* changed, just that something changed
|
//we don't get told *what* changed, just that something changed
|
||||||
|
@ -278,6 +278,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Q_PRIVATE_SLOT(d, void syncToAction())
|
Q_PRIVATE_SLOT(d, void syncToAction())
|
||||||
|
Q_PRIVATE_SLOT(d, void clearAction())
|
||||||
void init();
|
void init();
|
||||||
void layoutIcons(const QStyleOptionGraphicsItem *option);
|
void layoutIcons(const QStyleOptionGraphicsItem *option);
|
||||||
void hoverEffect(bool);
|
void hoverEffect(bool);
|
||||||
|
@ -175,6 +175,7 @@ public:
|
|||||||
* update the icon's text, icon, etc. to reflect the properties of its associated action.
|
* update the icon's text, icon, etc. to reflect the properties of its associated action.
|
||||||
*/
|
*/
|
||||||
void syncToAction();
|
void syncToAction();
|
||||||
|
void clearAction();
|
||||||
|
|
||||||
IconWidget *q;
|
IconWidget *q;
|
||||||
QString text;
|
QString text;
|
||||||
|
Loading…
Reference in New Issue
Block a user