summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleix Pol <[email protected]>2018-05-22 15:26:45 +0200
committerAleix Pol <[email protected]>2018-05-22 15:26:45 +0200
commit0c4e121d78df65694694c0cee0c6feed0cb14da7 (patch)
treed54965f66fd58136da3193a9c91bae8350f1ef25
parentfd4f6382136fb23f8338f332f8354c4d5a15739e (diff)
Guard against calling a null object
-rw-r--r--discover/DiscoverObject.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/discover/DiscoverObject.cpp b/discover/DiscoverObject.cpp
index a97245d..d7eb8ff 100644
--- a/discover/DiscoverObject.cpp
+++ b/discover/DiscoverObject.cpp
@@ -154,13 +154,18 @@ QStringList DiscoverObject::modes() const
void DiscoverObject::openMode(const QString& _mode)
{
+ QObject* obj = rootObject();
+ if (!obj) {
+ qWarning() << "could not get the main object";
+ return;
+ }
+
if(!modes().contains(_mode))
qWarning() << "unknown mode" << _mode;
QString mode = _mode;
mode[0] = mode[0].toUpper();
- QObject* obj = rootObject();
const QByteArray propertyName = "top"+mode.toLatin1()+"Comp";
const QVariant modeComp = obj->property(propertyName.constData());
if (!modeComp.isValid())