summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Reininghaus <frank78ac@googlemail.com>2009-08-26 20:49:32 +0200
committerOlivier Goffart <ogoffart@trolltech.com>2009-08-27 10:01:08 +0200
commit8ac7e812604d24fcbf28132a611d3b3e06120349 (patch)
tree82051d86764e6483815654e9ddfb2ecf58831c8d
parent4de2a2241e9e1c5f29223d6bd0616e6db77be70e (diff)
Do not crash when double-clicking a tab in a QTabBar with movable tabs
Check if QTabBarPrivate's movingTab member is 0 before dereferencing it. This fixes a crash when double-clicking a tab. New unit test included. http://bugs.kde.org/show_bug.cgi?id=202767 Reviewed-by: Olivier Goffart <ogoffart@trolltech.com> Merge-Request: 1337
-rw-r--r--src/gui/widgets/qtabbar.cpp3
-rw-r--r--tests/auto/qtabbar/tst_qtabbar.cpp34
2 files changed, 36 insertions, 1 deletions
diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp
index 51663901e3..d8246c8061 100644
--- a/src/gui/widgets/qtabbar.cpp
+++ b/src/gui/widgets/qtabbar.cpp
@@ -1836,7 +1836,8 @@ void QTabBarPrivate::moveTabFinished(int index)
}
#endif //QT_NO_ANIMATION
if (allAnimationsFinished && cleanup) {
- movingTab->setVisible(false); // We might not get a mouse release
+ if(movingTab)
+ movingTab->setVisible(false); // We might not get a mouse release
for (int i = 0; i < tabList.count(); ++i) {
tabList[i].dragOffset = 0;
}
diff --git a/tests/auto/qtabbar/tst_qtabbar.cpp b/tests/auto/qtabbar/tst_qtabbar.cpp
index 041836c0a1..3f77b7a6f7 100644
--- a/tests/auto/qtabbar/tst_qtabbar.cpp
+++ b/tests/auto/qtabbar/tst_qtabbar.cpp
@@ -94,6 +94,7 @@ private slots:
void moveTab();
void task251184_removeTab();
+ void changeTitleWhileDoubleClickingTab();
};
// Testing get/set functions
@@ -535,5 +536,38 @@ void tst_QTabBar::task251184_removeTab()
}
+class TitleChangeTabBar : public QTabBar
+{
+ Q_OBJECT
+
+ QTimer timer;
+ int count;
+
+public:
+ TitleChangeTabBar(QWidget * parent = 0) : QTabBar(parent), count(0)
+ {
+ setMovable(true);
+ addTab("0");
+ connect(&timer, SIGNAL(timeout()), this, SLOT(updateTabText()));
+ timer.start(1);
+ }
+
+public slots:
+ void updateTabText()
+ {
+ count++;
+ setTabText(0, QString("%1").arg(count));
+ }
+};
+
+void tst_QTabBar::changeTitleWhileDoubleClickingTab()
+{
+ TitleChangeTabBar bar;
+ QPoint tabPos = bar.tabRect(0).center();
+
+ for(int i=0; i < 10; i++)
+ QTest::mouseDClick(&bar, Qt::LeftButton, 0, tabPos);
+}
+
QTEST_MAIN(tst_QTabBar)
#include "tst_qtabbar.moc"