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

List:       kde-commits
Subject:    [kwin/fredrik/vulkan] /: Improve robustness in some QML paths
From:       Fredrik_Höglund <null () kde ! org>
Date:       2018-02-20 15:38:02
Message-ID: E1eo9zW-0004jh-2F () code ! kde ! org
[Download RAW message or body]

Git commit 8f6509b9cb3f79598cd08c2a5f4e2b1ba620960a by Fredrik Höglund.
Committed on 20/02/2018 at 15:35.
Pushed by fredrik into branch 'fredrik/vulkan'.

Improve robustness in some QML paths

Improve robustness by connecting an error handler that does not abort()
to QQuickWindow::sceneGraphError().

M  +8    -1    onscreennotification.cpp
M  +8    -1    outline.cpp
M  +8    -1    tabbox/tabboxhandler.cpp

https://commits.kde.org/kwin/8f6509b9cb3f79598cd08c2a5f4e2b1ba620960a

diff --git a/onscreennotification.cpp b/onscreennotification.cpp
index 98adb0073..51196f0f7 100644
--- a/onscreennotification.cpp
+++ b/onscreennotification.cpp
@@ -193,7 +193,14 @@ void OnScreenNotification::ensureQmlComponent()
     }
     m_qmlComponent->loadUrl(QUrl::fromLocalFile(fileName));
     if (!m_qmlComponent->isError()) {
-        m_mainItem.reset(m_qmlComponent->create(m_qmlContext.data()));
+        m_mainItem.reset(m_qmlComponent->beginCreate(m_qmlContext.data()));
+        if (QQuickWindow *w = qobject_cast<QQuickWindow*>(m_mainItem.data())) {
+            QObject::connect(w, &QQuickWindow::sceneGraphError, \
[&](QQuickWindow::SceneGraphError error, const QString &message) { +                  \
Q_UNUSED(error) +                                 qCritical() << "Scene graph error \
in OnScreenNotification:" << message; +                             });
+            m_qmlComponent->completeCreate();
+        }
     } else {
         m_qmlComponent.reset();
     }
diff --git a/outline.cpp b/outline.cpp
index 69a8a5462..8f4c0f0bb 100644
--- a/outline.cpp
+++ b/outline.cpp
@@ -178,7 +178,14 @@ void CompositedOutlineVisual::show()
         if (m_qmlComponent->isError()) {
             qCDebug(KWIN_CORE) << "Component failed to load: " << \
m_qmlComponent->errors();  } else {
-            m_mainItem.reset(m_qmlComponent->create(m_qmlContext.data()));
+            m_mainItem.reset(m_qmlComponent->beginCreate(m_qmlContext.data()));
+            if (QQuickWindow *w = qobject_cast<QQuickWindow*>(m_mainItem.data())) {
+                QObject::connect(w, &QQuickWindow::sceneGraphError, \
[&](QQuickWindow::SceneGraphError error, const QString &message) { +                  \
Q_UNUSED(error) +                                     qCCritical(KWIN_CORE) << "Scene \
graph error in CompositedOutlineVisual: " << message; +                               \
}); +                m_qmlComponent->completeCreate();
+            }
         }
     }
 }
diff --git a/tabbox/tabboxhandler.cpp b/tabbox/tabboxhandler.cpp
index 9d8f16ce7..469510a81 100644
--- a/tabbox/tabboxhandler.cpp
+++ b/tabbox/tabboxhandler.cpp
@@ -284,7 +284,14 @@ QObject *TabBoxHandlerPrivate::createSwitcherItem(bool \
                desktopMode)
                                             "Contact your distribution about this.") \
<< QStringLiteral("20");  KProcess::startDetached(QStringLiteral("kdialog"), args);
     } else {
-        QObject *object = m_qmlComponent->create(m_qmlContext.data());
+        QObject *object = m_qmlComponent->beginCreate(m_qmlContext.data());
+        if (QQuickWindow *w = qobject_cast<QQuickWindow*>(object)) {
+            QObject::connect(w, &QQuickWindow::sceneGraphError, \
[](QQuickWindow::SceneGraphError error, const QString &message) { +                   \
Q_UNUSED(error) +                                 qCCritical(KWIN_TABBOX) << "Scene \
graph error in TabBoxHandlerPrivate:" << message; +                             });
+            m_qmlComponent->completeCreate();
+        }
         if (desktopMode) {
             m_desktopTabBoxes.insert(config.layoutName(), object);
         } else {


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

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