summaryrefslogtreecommitdiff
path: root/src/plugins/winrt
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2017-07-07 17:20:16 +0200
committerhjk <hjk@qt.io>2017-07-11 10:53:00 +0000
commit6f0a600bcf7647493f8044f7d5d18d698e8c2fdc (patch)
tree1c54533528f712cf61135063e75151713a3faf30 /src/plugins/winrt
parent8637d04c1d1f192f024ec1a88f271a1a9f6085d6 (diff)
downloadqt-creator-6f0a600bcf7647493f8044f7d5d18d698e8c2fdc.tar.gz
Debugger: Streamline error string handling
Let the workers keep track of errors instead of passing around string pointers in some but not all interesting places. Change-Id: I3956bc947a50747dd3a0c9302b9f9873d192e9c6 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/winrt')
-rw-r--r--src/plugins/winrt/winrtdebugsupport.cpp35
-rw-r--r--src/plugins/winrt/winrtdebugsupport.h4
-rw-r--r--src/plugins/winrt/winrtrunfactories.cpp11
3 files changed, 24 insertions, 26 deletions
diff --git a/src/plugins/winrt/winrtdebugsupport.cpp b/src/plugins/winrt/winrtdebugsupport.cpp
index 352ac3f3f9..7499200df1 100644
--- a/src/plugins/winrt/winrtdebugsupport.cpp
+++ b/src/plugins/winrt/winrtdebugsupport.cpp
@@ -45,7 +45,7 @@ using namespace ProjectExplorer;
namespace WinRt {
namespace Internal {
-WinRtDebugSupport::WinRtDebugSupport(RunControl *runControl, QString *errorMessage)
+WinRtDebugSupport::WinRtDebugSupport(RunControl *runControl)
: DebuggerRunTool(runControl)
{
// FIXME: This is just working for local debugging;
@@ -57,35 +57,38 @@ WinRtDebugSupport::WinRtDebugSupport(RunControl *runControl, QString *errorMessa
QFileInfo debuggerHelper(QCoreApplication::applicationDirPath()
+ QLatin1String("/winrtdebughelper.exe"));
if (!debuggerHelper.isExecutable()) {
- *errorMessage = tr("The WinRT debugging helper is missing from your Qt Creator "
- "installation. It was assumed to be located at %1").arg(
- debuggerHelper.absoluteFilePath());
+ reportFailure(tr("The WinRT debugging helper is missing from your Qt Creator "
+ "installation. It was assumed to be located at %1").arg(
+ debuggerHelper.absoluteFilePath()));
return;
}
if (isQmlDebugging()) {
Utils::Port qmlDebugPort;
- if (!getFreePort(qmlDebugPort, errorMessage))
+ if (!getFreePort(qmlDebugPort))
return;
params.qmlServer.host = QHostAddress(QHostAddress::LocalHost).toString();
params.qmlServer.port = qmlDebugPort;
}
- m_runner = new WinRtRunnerHelper(this, errorMessage);
- if (!errorMessage->isEmpty())
+ QString errorMessage;
+ m_runner = new WinRtRunnerHelper(this, &errorMessage);
+ if (!errorMessage.isEmpty()) {
+ reportFailure(errorMessage);
return;
+ }
QLocalServer server;
server.listen(QLatin1String("QtCreatorWinRtDebugPIDPipe"));
m_runner->debug(debuggerHelper.absoluteFilePath());
if (!m_runner->waitForStarted()) {
- *errorMessage = tr("Cannot start the WinRT Runner Tool.");
+ reportFailure(tr("Cannot start the WinRT Runner Tool."));
return;
}
if (!server.waitForNewConnection(10000)) {
- *errorMessage = tr("Cannot establish connection to the WinRT debugging helper.");
+ reportFailure(tr("Cannot establish connection to the WinRT debugging helper."));
return;
}
@@ -98,12 +101,12 @@ WinRtDebugSupport::WinRtDebugSupport(RunControl *runControl, QString *errorMessa
bool ok =false;
params.attachPID = Utils::ProcessHandle(arg.last().toInt(&ok));
if (!ok) {
- *errorMessage = tr("Cannot extract the PID from the WinRT debugging helper. "
- "(output: %1)").arg(QString::fromLocal8Bit(output));
+ reportFailure(tr("Cannot extract the PID from the WinRT debugging helper. "
+ "(output: %1)").arg(QString::fromLocal8Bit(output)));
return;
}
server.close();
- setStartParameters(params, errorMessage);
+ setStartParameters(params);
return;
}
}
@@ -111,16 +114,16 @@ WinRtDebugSupport::WinRtDebugSupport(RunControl *runControl, QString *errorMessa
server.close();
- *errorMessage = tr("Cannot create an appropriate run control for "
- "the current run configuration.");
+ reportFailure(tr("Cannot create an appropriate run control for "
+ "the current run configuration."));
}
-bool WinRtDebugSupport::getFreePort(Utils::Port &qmlDebuggerPort, QString *errorMessage)
+bool WinRtDebugSupport::getFreePort(Utils::Port &qmlDebuggerPort)
{
QTcpServer server;
if (!server.listen(QHostAddress::LocalHost,
qmlDebuggerPort.isValid() ? qmlDebuggerPort.number() : 0)) {
- *errorMessage = tr("Not enough free ports for QML debugging.");
+ reportFailure(tr("Not enough free ports for QML debugging."));
return false;
}
qmlDebuggerPort = Utils::Port(server.serverPort());
diff --git a/src/plugins/winrt/winrtdebugsupport.h b/src/plugins/winrt/winrtdebugsupport.h
index 995c3a0b73..0a8ed4e31a 100644
--- a/src/plugins/winrt/winrtdebugsupport.h
+++ b/src/plugins/winrt/winrtdebugsupport.h
@@ -38,11 +38,11 @@ class WinRtDebugSupport : public Debugger::DebuggerRunTool
Q_OBJECT
public:
- WinRtDebugSupport(ProjectExplorer::RunControl *runControl, QString *errorMessage);
+ explicit WinRtDebugSupport(ProjectExplorer::RunControl *runControl);
~WinRtDebugSupport();
private:
- static bool getFreePort(Utils::Port &qmlDebuggerPort, QString *errorMessage);
+ bool getFreePort(Utils::Port &qmlDebuggerPort);
WinRtRunnerHelper *m_runner = nullptr;
};
diff --git a/src/plugins/winrt/winrtrunfactories.cpp b/src/plugins/winrt/winrtrunfactories.cpp
index af4914c9bd..3269b32d64 100644
--- a/src/plugins/winrt/winrtrunfactories.cpp
+++ b/src/plugins/winrt/winrtrunfactories.cpp
@@ -151,7 +151,7 @@ bool WinRtRunControlFactory::canRun(RunConfiguration *runConfiguration,
}
RunControl *WinRtRunControlFactory::create(
- RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage)
+ RunConfiguration *runConfiguration, Core::Id mode, QString *)
{
RunControl *runControl = nullptr;
if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE) {
@@ -161,15 +161,10 @@ RunControl *WinRtRunControlFactory::create(
} else if (mode == ProjectExplorer::Constants::DEBUG_RUN_MODE
|| mode == ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN) {
runControl = new RunControl(runConfiguration, mode);
- (void) new WinRtDebugSupport(runControl, errorMessage);
- } else {
- *errorMessage = tr("Unsupported run mode %1.").arg(mode.toString());
- }
-
- if (errorMessage->isEmpty())
+ (void) new WinRtDebugSupport(runControl);
return runControl;
+ }
- delete runControl;
return nullptr;
}