on xenial help sign in
ShellApplication: use manual deletion for workaround hanging on shutdown
commitffd336ebdc4dc3abacd8c73722f1ac1fd14f147b authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateTue 20 Oct 2015, 13:04 (11 years ago) parent11ee416
2 files changed+20−9
src/ShellApplication.cpp+16−6 src/ShellApplication.h+4−3
src/ShellApplication.cpp+16−6
@@ -74,7 +74,7 @@ ShellApplication::ShellApplication(int & argc, char ** argv, bool isMirServer)
7474 bindtextdomain("unity8", translationDirectory().toUtf8().data());
7575 textdomain("unity8");
7676
77− m_shellView.reset(new ShellView(m_qmlEngine, &m_qmlArgs));
77+ m_shellView = new ShellView(m_qmlEngine, &m_qmlArgs);
7878
7979 if (parser.windowGeometry().isValid()) {
8080 m_shellView->setWidth(parser.windowGeometry().width());
@@ -88,7 +88,7 @@ ShellApplication::ShellApplication(int & argc, char ** argv, bool isMirServer)
8888 // You will need this if you want to interact with touch-only components using a mouse
8989 // Needed only when manually testing on a desktop.
9090 if (parser.hasMouseToTouch()) {
91− m_mouseTouchAdaptor.reset(MouseTouchAdaptor::instance());
91+ m_mouseTouchAdaptor = MouseTouchAdaptor::instance();
9292 }
9393
9494
@@ -101,7 +101,7 @@ ShellApplication::ShellApplication(int & argc, char ** argv, bool isMirServer)
101101 m_shellView->setScreen(screens().at(1));
102102 m_qmlArgs.setDeviceName("desktop");
103103
104− m_secondaryWindow.reset(new SecondaryWindow(m_qmlEngine));
104+ m_secondaryWindow = new SecondaryWindow(m_qmlEngine);
105105 m_secondaryWindow->setScreen(screens().at(0));
106106 // QWindow::showFullScreen() also calls QWindow::requestActivate() and we don't want that!
107107 m_secondaryWindow->setWindowState(Qt::WindowFullScreen);
@@ -115,6 +115,15 @@ ShellApplication::ShellApplication(int & argc, char ** argv, bool isMirServer)
115115 }
116116}
117117
118+ShellApplication::~ShellApplication()
119+{
120+ // Deletion order is important. Don't use QScopedPointers and the like
121+ // Otherwise the process will hang on shutdown (bug somewhere I guess).
122+ delete m_shellView;
123+ delete m_secondaryWindow;
124+ delete m_mouseTouchAdaptor;
125+}
126+
118127void ShellApplication::setupQmlEngine(bool isMirServer)
119128{
120129 m_qmlEngine = new QQmlEngine(this);
@@ -143,7 +152,7 @@ void ShellApplication::onScreenAdded(QScreen * /*screen*/)
143152 // its backing QPlatformWindow recreated). So lets refocus it.
144153 m_shellView->requestActivate();
145154
146− m_secondaryWindow.reset(new SecondaryWindow(m_qmlEngine));
155+ m_secondaryWindow = new SecondaryWindow(m_qmlEngine);
147156 m_secondaryWindow->setScreen(screens().at(0));
148157
149158 // QWindow::showFullScreen() also calls QWindow::requestActivate() and we don't want that!
@@ -159,8 +168,9 @@ void ShellApplication::onScreenAboutToBeRemoved(QScreen *screen)
159168 if (screen == m_shellView->screen()) {
160169 Q_ASSERT(screens().count() > 1);
161170 Q_ASSERT(screens().at(0) != screen);
162− Q_ASSERT(!m_secondaryWindow.isNull());
163− m_secondaryWindow.reset();
171+ Q_ASSERT(m_secondaryWindow);
172+ delete m_secondaryWindow;
173+ m_secondaryWindow = nullptr;
164174 m_shellView->setScreen(screens().first());
165175 m_qmlArgs.setDeviceName(m_deviceName);
166176 // Changing the QScreen where a QWindow is drawn makes it also lose focus (besides having
src/ShellApplication.h+4−3
@@ -32,6 +32,7 @@ class ShellApplication : public QGuiApplication
3232 Q_OBJECT
3333public:
3434 ShellApplication(int & argc, char ** argv, bool isMirServer);
35+ virtual ~ShellApplication();
3536
3637public Q_SLOTS:
3738 // called by qtmir
@@ -44,9 +45,9 @@ private:
4445 void setupQmlEngine(bool isMirServer);
4546 QString m_deviceName;
4647 ApplicationArguments m_qmlArgs;
47− QScopedPointer<ShellView> m_shellView;
48− QScopedPointer<SecondaryWindow> m_secondaryWindow;
49− QScopedPointer<MouseTouchAdaptor> m_mouseTouchAdaptor;
48+ ShellView *m_shellView;
49+ SecondaryWindow *m_secondaryWindow;
50+ MouseTouchAdaptor *m_mouseTouchAdaptor;
5051 QQmlEngine *m_qmlEngine;
5152};
5253