aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 }