aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-04-25 23:37:33 +0200
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-04-25 21:38:41 +0000
commitac1d446c1356ec8e11d1bf14b5559c682079b70c (patch)
tree52967cb35cadcbbcb672c603ece23f8c9329dced
parent2f55a4926347a6f6b445efca7dfed792e1bacc57 (diff)
ExclusiveGroup: don't crash when passing null
Change-Id: I4d6f555faac81e56c32c6baf0a9ede14849a5855 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
-rw-r--r--src/controls/qquickexclusivegroup.cpp6
-rw-r--r--tests/auto/controls/data/tst_exclusivegroup.qml9
2 files changed, 15 insertions, 0 deletions
diff --git a/src/controls/qquickexclusivegroup.cpp b/src/controls/qquickexclusivegroup.cpp
index 5144bf92..8eec97ab 100644
--- a/src/controls/qquickexclusivegroup.cpp
+++ b/src/controls/qquickexclusivegroup.cpp
@@ -107,6 +107,9 @@ void QQuickExclusiveGroup::setCurrent(QObject *current)
*/
void QQuickExclusiveGroup::addCheckable(QObject *object)
{
+ if (!object)
+ return;
+
connect(object, SIGNAL(checkedChanged()), this, SLOT(_q_updateCurrent()), Qt::UniqueConnection);
connect(object, SIGNAL(destroyed(QObject*)), this, SLOT(removeCheckable(QObject*)), Qt::UniqueConnection);
@@ -122,6 +125,9 @@ void QQuickExclusiveGroup::addCheckable(QObject *object)
void QQuickExclusiveGroup::removeCheckable(QObject *object)
{
Q_D(QQuickExclusiveGroup);
+ if (!object)
+ return;
+
if (object->metaObject()->indexOfProperty("checked") != -1)
disconnect(object, SIGNAL(checkedChanged()), this, SLOT(_q_updateCurrent()));
disconnect(object, SIGNAL(destroyed(QObject*)), this, SLOT(removeCheckable(QObject*)));
diff --git a/tests/auto/controls/data/tst_exclusivegroup.qml b/tests/auto/controls/data/tst_exclusivegroup.qml
index 5848eade..d8ae6103 100644
--- a/tests/auto/controls/data/tst_exclusivegroup.qml
+++ b/tests/auto/controls/data/tst_exclusivegroup.qml
@@ -77,6 +77,15 @@ TestCase {
group.destroy()
}
+ function test_null() {
+ var group = exclusiveGroup.createObject(testCase)
+
+ group.addCheckable(null)
+ group.removeCheckable(null)
+
+ group.destroy()
+ }
+
Component {
id: checkable
QtObject { property bool checked }