summaryrefslogtreecommitdiff
path: root/net/linphone/files/patch-06-70f47b0
blob: 36df71bf63954c249461a30dfe692003ef697ab9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
From 70f47b01d375ab1d3687b2d448c601fdc15fab20 Mon Sep 17 00:00:00 2001
From: Ronan Abhamon <ronan.abhamon@belledonne-communications.com>
Date: Wed, 20 Jun 2018 14:56:53 +0200
Subject: [PATCH] fix(App): do not create windows later to avoid warning and
 abort (QQmlComponent: Cannot create new component instance before completing
 the previous)

---
 src/app/App.cpp | 40 +++++++++++++++++++---------------------
 src/app/App.hpp |  4 ++--
 2 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/src/app/App.cpp b/src/app/App.cpp
index 36b68590..12661dd4 100644
--- src/app/App.cpp.orig
+++ src/app/App.cpp
@@ -147,8 +147,6 @@
     qInfo() << QStringLiteral("Restarting app...");
     delete mEngine;
 
-    mCallsWindow = nullptr;
-    mSettingsWindow = nullptr;
 
     CoreManager::uninit();
 
@@ -232,10 +230,7 @@
 
 // -----------------------------------------------------------------------------
 
-QQuickWindow *App::getCallsWindow () {
-  if (!mCallsWindow)
-    mCallsWindow = ::createSubWindow(mEngine, QML_VIEW_CALLS_WINDOW);
-
+QQuickWindow *App::getCallsWindow () const {
   return mCallsWindow;
 }
 
@@ -245,18 +240,7 @@
   );
 }
 
-QQuickWindow *App::getSettingsWindow () {
-  if (!mSettingsWindow) {
-    mSettingsWindow = ::createSubWindow(mEngine, QML_VIEW_SETTINGS_WINDOW);
-    QObject::connect(mSettingsWindow, &QWindow::visibilityChanged, this, [](QWindow::Visibility visibility) {
-        if (visibility == QWindow::Hidden) {
-          qInfo() << QStringLiteral("Update nat policy.");
-          shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
-          core->setNatPolicy(core->getNatPolicy());
-        }
-      });
-  }
-
+QQuickWindow *App::getSettingsWindow () const {
   return mSettingsWindow;
 }
 
@@ -504,6 +488,17 @@
 
 void App::openAppAfterInit () {
   qInfo() << QStringLiteral("Open linphone app.");
+
+  // Create other windows.
+  mCallsWindow = createSubWindow(mEngine, QML_VIEW_CALLS_WINDOW);
+  mSettingsWindow = createSubWindow(mEngine, QML_VIEW_SETTINGS_WINDOW);
+  QObject::connect(mSettingsWindow, &QWindow::visibilityChanged, this, [](QWindow::Visibility visibility) {
+    if (visibility == QWindow::Hidden) {
+      qInfo() << QStringLiteral("Update nat policy.");
+      shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
+      core->setNatPolicy(core->getNatPolicy());
+    }
+  });
 
   QQuickWindow *mainWindow = getMainWindow();
 
diff --git a/src/app/App.hpp b/src/app/App.hpp
index cdae4a06..21ad9617 100644
--- src/app/App.hpp.orig
+++ src/app/App.hpp
@@ -79,8 +79,8 @@
     exit(APP_CODE_RESTART);
   }
 
-  Q_INVOKABLE QQuickWindow *getCallsWindow ();
-  Q_INVOKABLE QQuickWindow *getSettingsWindow ();
+  Q_INVOKABLE QQuickWindow *getCallsWindow () const;
+  Q_INVOKABLE QQuickWindow *getSettingsWindow () const;
 
   Q_INVOKABLE static void smartShowWindow (QQuickWindow *window);