diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-07-08 11:18:24 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-07-08 11:18:24 (GMT) |
commit | 191c621cbaa318e60111ae88c7b1e57286b1368b (patch) | |
tree | cf714c377a5032c8d1d2e579d35d31b28a29eb3f | |
parent | 7486389a0d742a7c9e70c6110692186f70dbf1e5 (diff) | |
download | Qt-191c621cbaa318e60111ae88c7b1e57286b1368b.zip Qt-191c621cbaa318e60111ae88c7b1e57286b1368b.tar.gz Qt-191c621cbaa318e60111ae88c7b1e57286b1368b.tar.bz2 |
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
-rw-r--r-- | src/gui/widgets/qmainwindowlayout.cpp | 16 | ||||
-rw-r--r-- | 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<int> hover(QLayoutItem *widgetItem, const QPoint &mousePos); |