From 56fc44f841e72d793488c33af1bf09fb91a39399 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Fri, 28 Jan 2011 22:30:54 +0000 Subject: [PATCH] various cleanups svn path=/trunk/KDE/kdelibs/; revision=1217825 --- containment.cpp | 2 +- corona.cpp | 8 ++++---- extenders/extender.cpp | 7 +++++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/containment.cpp b/containment.cpp index ed6d94de6..47ffb5e20 100644 --- a/containment.cpp +++ b/containment.cpp @@ -528,7 +528,7 @@ void ContainmentPrivate::checkContainmentFurniture() Corona *Containment::corona() const { - return dynamic_cast(scene()); + return qobject_cast(scene()); } void Containment::mouseMoveEvent(QGraphicsSceneMouseEvent *event) diff --git a/corona.cpp b/corona.cpp index a7f62a6c6..a7dddb0cb 100644 --- a/corona.cpp +++ b/corona.cpp @@ -436,14 +436,14 @@ int Corona::numScreens() const QRect Corona::screenGeometry(int id) const { Q_UNUSED(id); - if (views().isEmpty()) { - return sceneRect().toRect(); - } else { - QGraphicsView *v = views()[0]; + QGraphicsView *v = views().value(0); + if (v) { QRect r = sceneRect().toRect(); r.moveTo(v->mapToGlobal(QPoint(0, 0))); return r; } + + return sceneRect().toRect(); } QRegion Corona::availableScreenRegion(int id) const diff --git a/extenders/extender.cpp b/extenders/extender.cpp index 2d5ce179d..1d817e2b9 100644 --- a/extenders/extender.cpp +++ b/extenders/extender.cpp @@ -913,8 +913,11 @@ void ExtenderPrivate::adjustSize() { QRect screenRect; QSizeF size = mainWidget->effectiveSizeHint(Qt::PreferredSize); - if (applet && applet.data()->containment() && applet.data()->containment()->corona()) { - screenRect = applet.data()->containment()->corona()->screenGeometry(applet.data()->containment()->screen()); + if (applet) { + Containment *containment = applet.data()->containment(); + if (containment && containment->corona()) { + screenRect = containment->corona()->screenGeometry(containment->screen()); + } } q->resize(qMin(screenRect.width()/3, (int)size.width()), qMin(screenRect.height()/3, (int)size.height()));