diff --git a/applet.cpp b/applet.cpp index 51c0a6a38..3c79c23e2 100644 --- a/applet.cpp +++ b/applet.cpp @@ -1409,6 +1409,7 @@ void AppletPrivate::addGlobalShortcutsPage(KConfigDialog *dialog) if (!shortcutEditor) { shortcutEditor = new KKeySequenceWidget(page); + QObject::connect(shortcutEditor, SIGNAL(destroyed(QObject*)), q, SLOT(clearShortcutEditorPtr())); } shortcutEditor->setKeySequence(q->globalShortcut().primary()); @@ -1417,6 +1418,11 @@ void AppletPrivate::addGlobalShortcutsPage(KConfigDialog *dialog) dialog->addPage(page, i18n("Keyboard Shortcut"), "preferences-desktop-keyboard"); } +void AppletPrivate::clearShortcutEditorPtr() +{ + shortcutEditor = 0; +} + void Applet::configChanged() { if (d->script) { @@ -1429,9 +1435,6 @@ void Applet::configChanged() setGlobalShortcut(KShortcut(sequence)); emit configNeedsSaving(); } - - delete d->shortcutEditor; - d->shortcutEditor = 0; } } diff --git a/applet.h b/applet.h index aad27a6da..caf47b018 100644 --- a/applet.h +++ b/applet.h @@ -834,6 +834,7 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget Q_PRIVATE_SLOT(d, void selectItemToDestroy()) Q_PRIVATE_SLOT(d, void updateRect(const QRectF& rect)) Q_PRIVATE_SLOT(d, void destroyMessageOverlay()) + Q_PRIVATE_SLOT(d, void clearShortcutEditorPtr()) /** * Reimplemented from QGraphicsItem diff --git a/private/applet_p.h b/private/applet_p.h index 8594d5bfd..6182f9fd4 100644 --- a/private/applet_p.h +++ b/private/applet_p.h @@ -76,6 +76,7 @@ public: void createMessageOverlay(); void destroyMessageOverlay(); void addGlobalShortcutsPage(KConfigDialog *dialog); + void clearShortcutEditorPtr(); static uint s_maxAppletId; static uint s_maxZValue;