[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [discover/Plasma/5.12] discover: Guard against calling a null object
From:       Aleix Pol <null () kde ! org>
Date:       2018-05-22 13:27:51
Message-ID: E1fL7KR-0006lo-32 () code ! kde ! org
[Download RAW message or body]

Git commit 0c4e121d78df65694694c0cee0c6feed0cb14da7 by Aleix Pol.
Committed on 22/05/2018 at 13:26.
Pushed by apol into branch 'Plasma/5.12'.

Guard against calling a null object

BUG: 394543

M  +6    -1    discover/DiscoverObject.cpp

https://commits.kde.org/discover/0c4e121d78df65694694c0cee0c6feed0cb14da7

diff --git a/discover/DiscoverObject.cpp b/discover/DiscoverObject.cpp
index a97245de..d7eb8ffa 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())
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic