From ba3b1b753b558f1893d51c07a26b5dab9927faef Mon Sep 17 00:00:00 2001 From: Chani Armitage Date: Wed, 23 Sep 2009 20:37:17 +0000 Subject: [PATCH] merge-squash of first containment-removal branch svn path=/trunk/KDE/kdelibs/; revision=1027320 --- applet.cpp | 12 ++++++++++++ containment.cpp | 15 +-------------- view.cpp | 1 + view.h | 6 ++++++ 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/applet.cpp b/applet.cpp index cebb3c49b..4d12f1275 100644 --- a/applet.cpp +++ b/applet.cpp @@ -514,7 +514,19 @@ void AppletPrivate::cleanUpAndDelete() resetConfigurationObject(); + QGraphicsScene *s = q->scene(); q->scene()->removeItem(q); + kDebug(); + //a hack to try and avoid crashes. doesn't seem to work. + QGraphicsItem *f = s->focusItem(); + if (f) { + QGraphicsItem *top = f->topLevelItem(); + kDebug() << "focus exists" << top; + if (top == q) { + kDebug() << "clearing focus"; + s->setFocusItem(0); + } + } q->deleteLater(); } diff --git a/containment.cpp b/containment.cpp index 8aa8b5403..3ecb3d06d 100644 --- a/containment.cpp +++ b/containment.cpp @@ -1947,16 +1947,6 @@ void Containment::destroy(bool confirm) } if (isContainment()) { - //don't remove a desktop that's in use - //FIXME: this should probably be based on whether any views care or not! - // sth like: foreach (view) { view->requires(this); } - Q_ASSERT(corona()); - if (d->type != PanelContainment && d->type != CustomPanelContainment && - (d->screen != -1 || d->screen >= corona()->numScreens())) { - kDebug() << (QObject*)this << "containment has a screen number?" << d->screen; - return; - } - //FIXME maybe that %1 should be the containment type not the name if (!confirm || KMessageBox::warningContinueCancel( @@ -2047,10 +2037,7 @@ void ContainmentPrivate::handleDisappeared(AppletHandle *handle) void ContainmentPrivate::checkRemoveAction() { - q->enableAction("remove", (q->immutability() == Mutable && - (screen == -1 || - type == Plasma::Containment::PanelContainment || - type == Plasma::Containment::CustomPanelContainment))); + q->enableAction("remove", q->immutability() == Mutable); } void ContainmentPrivate::containmentConstraintsEvent(Plasma::Constraints constraints) diff --git a/view.cpp b/view.cpp index ce3c791ec..fbff2d8a3 100644 --- a/view.cpp +++ b/view.cpp @@ -93,6 +93,7 @@ public: void containmentDestroyed() { containment = 0; + emit q->lostContainment(); } void containmentScreenChanged(int wasScreen, int newScreen, Plasma::Containment *containment) diff --git a/view.h b/view.h index 9de1a9738..2489ec564 100644 --- a/view.h +++ b/view.h @@ -178,6 +178,12 @@ Q_SIGNALS: */ void sceneRectChanged(); + /** + * This is emitted after the containment is destroyed, for views that need to do something about + * it (like find a new one). + */ + void lostContainment(); + public Q_SLOTS: /** * Sets the containment for this view, which will also cause the view