From dc613c013d11811b0d9de719a32143fe26c6a211 Mon Sep 17 00:00:00 2001
From: Pawel Polanski <pawel.3.polanski@nokia.com>
Date: Thu, 29 Jul 2010 11:40:58 +0200
Subject: [PATCH] Fixed: Creator crashes when trying to deploy to a non
 existing device

---
 src/plugins/qt4projectmanager/qt-s60/s60deploystep.cpp | 5 +++--
 src/shared/symbianutils/launcher.cpp                   | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/plugins/qt4projectmanager/qt-s60/s60deploystep.cpp b/src/plugins/qt4projectmanager/qt-s60/s60deploystep.cpp
index b2f56980cca..8a1c47bd95c 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60deploystep.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/s60deploystep.cpp
@@ -135,8 +135,9 @@ bool S60DeployStep::init()
     setDisplayName(tr("Deploy", "Qt4 DeployStep display name."));
     QString message;
     m_launcher = trk::Launcher::acquireFromDeviceManager(m_serialPortName, this, &message);
-    if (!message.isEmpty()) {
-        trk::Launcher::releaseToDeviceManager(m_launcher);
+    if (!message.isEmpty() || !m_launcher) {
+        if (m_launcher)
+            trk::Launcher::releaseToDeviceManager(m_launcher);
         delete m_launcher;
         m_launcher = 0;
         appendMessage(message, true);
diff --git a/src/shared/symbianutils/launcher.cpp b/src/shared/symbianutils/launcher.cpp
index 4f8eaf7ad28..7218deec062 100644
--- a/src/shared/symbianutils/launcher.cpp
+++ b/src/shared/symbianutils/launcher.cpp
@@ -1033,6 +1033,8 @@ Launcher *Launcher::acquireFromDeviceManager(const QString &serverName,
 // Preliminary release of device, disconnecting the signal.
 void Launcher::releaseToDeviceManager(Launcher *launcher)
 {
+    Q_ASSERT(launcher);
+
     SymbianUtils::SymbianDeviceManager *sdm = SymbianUtils::SymbianDeviceManager::instance();
     // Disentangle launcher and its device, remove connection from destroyed
     launcher->setCloseDevice(false);
-- 
GitLab