From 8e2c274d53f5fabc1105121c2f4d09e013a57e76 Mon Sep 17 00:00:00 2001
From: Pawel Polanski <pawel.3.polanski@nokia.com>
Date: Thu, 5 Aug 2010 15:25:01 +0200
Subject: [PATCH] Application is not launched if an error occurred during
 deployment for Symbian OS

Reviewed-by: Tobias Hunger
---
 .../qt-s60/s60createpackagestep.cpp           |  2 +-
 .../qt-s60/s60deploystep.cpp                  | 31 +++++++++++--------
 .../qt4projectmanager/qt-s60/s60deploystep.h  | 10 +++---
 3 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.cpp b/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.cpp
index 7ea037b6165..f5856ad29a8 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/s60createpackagestep.cpp
@@ -340,7 +340,7 @@ void S60CreatePackageStep::slotProcessFinished(int, QProcess::ExitStatus)
         //waiting for the user to input new passphrase or to abort
         m_waitCondition.wait(&m_mutex);
         if( m_errorType == ErrorUndefined ) {
-            m_eventLoop->exit(true);
+            m_eventLoop->exit(false);
             return;
         } else {
             QRegExp passphraseRegExp("^"+QLatin1String(MAKE_PASSPHRASE_ARGUMENT)+"(.+)$");
diff --git a/src/plugins/qt4projectmanager/qt-s60/s60deploystep.cpp b/src/plugins/qt4projectmanager/qt-s60/s60deploystep.cpp
index 5a2d947f9d2..d5c2d83e66c 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60deploystep.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/s60deploystep.cpp
@@ -231,13 +231,14 @@ void S60DeployStep::setupConnections()
     connect(SymbianUtils::SymbianDeviceManager::instance(), SIGNAL(deviceRemoved(SymbianUtils::SymbianDevice)),
             this, SLOT(deviceRemoved(SymbianUtils::SymbianDevice)));
     connect(m_launcher, SIGNAL(finished()), this, SLOT(launcherFinished()));
-    connect(m_launcher, SIGNAL(canNotConnect(QString)), this, SLOT(printConnectFailed(QString)));
+
+    connect(m_launcher, SIGNAL(canNotConnect(QString)), this, SLOT(connectFailed(QString)));
     connect(m_launcher, SIGNAL(copyingStarted()), this, SLOT(printCopyingNotice()));
-    connect(m_launcher, SIGNAL(canNotCreateFile(QString,QString)), this, SLOT(printCreateFileFailed(QString,QString)));
-    connect(m_launcher, SIGNAL(canNotWriteFile(QString,QString)), this, SLOT(printWriteFileFailed(QString,QString)));
-    connect(m_launcher, SIGNAL(canNotCloseFile(QString,QString)), this, SLOT(printCloseFileFailed(QString,QString)));
+    connect(m_launcher, SIGNAL(canNotCreateFile(QString,QString)), this, SLOT(createFileFailed(QString,QString)));
+    connect(m_launcher, SIGNAL(canNotWriteFile(QString,QString)), this, SLOT(writeFileFailed(QString,QString)));
+    connect(m_launcher, SIGNAL(canNotCloseFile(QString,QString)), this, SLOT(closeFileFailed(QString,QString)));
     connect(m_launcher, SIGNAL(installingStarted()), this, SLOT(printInstallingNotice()));
-    connect(m_launcher, SIGNAL(canNotInstall(QString,QString)), this, SLOT(printInstallFailed(QString,QString)));
+    connect(m_launcher, SIGNAL(canNotInstall(QString,QString)), this, SLOT(installFailed(QString,QString)));
     connect(m_launcher, SIGNAL(installingFinished()), this, SLOT(printInstallingFinished()));
     connect(m_launcher, SIGNAL(stateChanged(int)), this, SLOT(slotLauncherStateChanged(int)));
 }
@@ -275,7 +276,7 @@ void S60DeployStep::startDeployment()
 void S60DeployStep::run(QFutureInterface<bool> &fi)
 {
     m_futureInterface = &fi;
-    m_deployResult = false;
+    m_deployResult = true;
     connect(this, SIGNAL(finished()),
             this, SLOT(launcherFinished()));
     connect(this, SIGNAL(finishNow()),
@@ -322,25 +323,29 @@ void S60DeployStep::slotWaitingForTrkClosed()
     }
 }
 
-void S60DeployStep::printCreateFileFailed(const QString &filename, const QString &errorMessage)
+void S60DeployStep::createFileFailed(const QString &filename, const QString &errorMessage)
 {
     appendMessage(tr("Could not create file %1 on device: %2").arg(filename, errorMessage), true);
+    m_deployResult = false;
 }
 
-void S60DeployStep::printWriteFileFailed(const QString &filename, const QString &errorMessage)
+void S60DeployStep::writeFileFailed(const QString &filename, const QString &errorMessage)
 {
     appendMessage(tr("Could not write to file %1 on device: %2").arg(filename, errorMessage), true);
+    m_deployResult = false;
 }
 
-void S60DeployStep::printCloseFileFailed(const QString &filename, const QString &errorMessage)
+void S60DeployStep::closeFileFailed(const QString &filename, const QString &errorMessage)
 {
     const QString msg = tr("Could not close file %1 on device: %2. It will be closed when App TRK is closed.");
     appendMessage( msg.arg(filename, errorMessage), true);
+    m_deployResult = false;
 }
 
-void S60DeployStep::printConnectFailed(const QString &errorMessage)
+void S60DeployStep::connectFailed(const QString &errorMessage)
 {
     appendMessage(tr("Could not connect to App TRK on device: %1. Restarting App TRK might help.").arg(errorMessage), true);
+    m_deployResult = false;
 }
 
 void S60DeployStep::printCopyingNotice()
@@ -358,9 +363,10 @@ void S60DeployStep::printInstallingFinished()
     appendMessage(tr("Installation has finished"), false);
 }
 
-void S60DeployStep::printInstallFailed(const QString &filename, const QString &errorMessage)
+void S60DeployStep::installFailed(const QString &filename, const QString &errorMessage)
 {
     appendMessage(tr("Could not install from package %1 on device: %2").arg(filename, errorMessage), true);
+    m_deployResult = false;
 }
 
 void S60DeployStep::checkForCancel()
@@ -379,12 +385,11 @@ void S60DeployStep::launcherFinished()
         m_handleDeviceRemoval = false;
         trk::Launcher::releaseToDeviceManager(m_launcher);
     }
-    m_deployResult = true;
     if(m_launcher)
         m_launcher->deleteLater();
     m_launcher = 0;
     if(m_eventLoop)
-        m_eventLoop->exit(0);
+        m_eventLoop->exit();
 }
 
 void S60DeployStep::deviceRemoved(const SymbianUtils::SymbianDevice &d)
diff --git a/src/plugins/qt4projectmanager/qt-s60/s60deploystep.h b/src/plugins/qt4projectmanager/qt-s60/s60deploystep.h
index 297a25be097..197f69101d1 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60deploystep.h
+++ b/src/plugins/qt4projectmanager/qt-s60/s60deploystep.h
@@ -98,13 +98,13 @@ protected slots:
     void deviceRemoved(const SymbianUtils::SymbianDevice &);
 
 private slots:
-    void printConnectFailed(const QString &errorMessage);
+    void connectFailed(const QString &errorMessage);
     void printCopyingNotice();
-    void printCreateFileFailed(const QString &filename, const QString &errorMessage);
-    void printWriteFileFailed(const QString &filename, const QString &errorMessage);
-    void printCloseFileFailed(const QString &filename, const QString &errorMessage);
+    void createFileFailed(const QString &filename, const QString &errorMessage);
+    void writeFileFailed(const QString &filename, const QString &errorMessage);
+    void closeFileFailed(const QString &filename, const QString &errorMessage);
     void printInstallingNotice();
-    void printInstallFailed(const QString &filename, const QString &errorMessage);
+    void installFailed(const QString &filename, const QString &errorMessage);
     void printInstallingFinished();
     void launcherFinished();
     void slotLauncherStateChanged(int);
-- 
GitLab