Commit 6f12c73a authored by dt's avatar dt
Browse files

App: Ask the user if creator -client can't send a message

Task-Nr: QTCREATORBUG-3980
parent 9cf1a49c
......@@ -144,9 +144,13 @@ static inline QString msgCoreLoadFailure(const QString &why)
return QCoreApplication::translate("Application", "Failed to load core: %1").arg(why);
}
static inline QString msgSendArgumentFailed()
static inline int askMsgSendFailed()
{
return QCoreApplication::translate("Application", "Unable to send command line arguments to the already running instance. It appears to be not responding.");
return QMessageBox::question(0, QApplication::translate("Application","Could not send message"),
QCoreApplication::translate("Application", "Unable to send command line arguments to the already running instance."
"It appears to be not responding. Do you want to start a new instance of Creator?"),
QMessageBox::Yes | QMessageBox::No | QMessageBox::Retry,
QMessageBox::Retry);
}
static inline QStringList getPluginPaths()
......@@ -317,11 +321,24 @@ int main(int argc, char **argv)
const bool isFirstInstance = !app.isRunning();
if (!isFirstInstance && foundAppOptions.contains(QLatin1String(CLIENT_OPTION))) {
if (!app.sendMessage(pluginManager.serializedArguments())) {
displayError(msgSendArgumentFailed());
return -1;
if (app.sendMessage(pluginManager.serializedArguments()))
return 0;
// Message could not be send, maybe it was in the process of quitting
if (app.isRunning()) {
// Nah app is still running, ask the user
int button = askMsgSendFailed();
while(button == QMessageBox::Retry) {
if (app.sendMessage(pluginManager.serializedArguments()))
return 0;
if (!app.isRunning()) // App quit while we were trying so start a new creator
button = QMessageBox::Yes;
else
button = askMsgSendFailed();
}
if (button == QMessageBox::No)
return -1;
}
return 0;
}
pluginManager.loadPlugins();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment