From 191c621cbaa318e60111ae88c7b1e57286b1368b Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 8 Jul 2009 13:18:24 +0200 Subject: QMainWindow: fixed a crash in some cases when deleting the widget This happened because the rubberband used as a gapindicator was not allocated on the heap and might have been deleted by the QMainWindow destructor. Task-number: 257626 --- src/gui/widgets/qmainwindowlayout.cpp | 16 +++++----------- src/gui/widgets/qmainwindowlayout_p.h | 3 +-- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/gui/widgets/qmainwindowlayout.cpp index a02dca3..ad608d3 100644 --- a/src/gui/widgets/qmainwindowlayout.cpp +++ b/src/gui/widgets/qmainwindowlayout.cpp @@ -1639,7 +1639,7 @@ QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow) , widgetAnimator(this) , pluggingWidget(0) #ifndef QT_NO_RUBBERBAND - , gapIndicator(QRubberBand::Rectangle, mainwindow) + , gapIndicator(new QRubberBand(QRubberBand::Rectangle, mainwindow)) #endif //QT_NO_RUBBERBAND { #ifndef QT_NO_DOCKWIDGET @@ -1655,8 +1655,8 @@ QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow) #ifndef QT_NO_RUBBERBAND // For accessibility to identify this special widget. - gapIndicator.setObjectName(QLatin1String("qt_rubberband")); - gapIndicator.hide(); + gapIndicator->setObjectName(QLatin1String("qt_rubberband")); + gapIndicator->hide(); #endif pluggingWidget = 0; @@ -1762,14 +1762,8 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget) void QMainWindowLayout::updateGapIndicator() { #ifndef QT_NO_RUBBERBAND - if (widgetAnimator.animating() || currentGapPos.isEmpty()) { - gapIndicator.hide(); - } else { - if (gapIndicator.geometry() != currentGapRect) - gapIndicator.setGeometry(currentGapRect); - if (!gapIndicator.isVisible()) - gapIndicator.show(); - } + gapIndicator->setVisible(!widgetAnimator.animating() && !currentGapPos.isEmpty()); + gapIndicator->setGeometry(currentGapRect); #endif } diff --git a/src/gui/widgets/qmainwindowlayout_p.h b/src/gui/widgets/qmainwindowlayout_p.h index a7f70b4..45f62cd 100644 --- a/src/gui/widgets/qmainwindowlayout_p.h +++ b/src/gui/widgets/qmainwindowlayout_p.h @@ -59,7 +59,6 @@ #include "QtGui/qlayout.h" #include "QtGui/qtabbar.h" -#include "QtGui/qrubberband.h" #include "QtCore/qvector.h" #include "QtCore/qset.h" #include "QtCore/qbasictimer.h" @@ -284,7 +283,7 @@ public: QRect currentGapRect; QWidget *pluggingWidget; #ifndef QT_NO_RUBBERBAND - QRubberBand gapIndicator; + QRubberBand *gapIndicator; #endif QList hover(QLayoutItem *widgetItem, const QPoint &mousePos); -- cgit v0.12