forked from qt-creator/qt-creator
QmlProfiler: Move connection failure message to QmlProfilerTool
and show it on any kind of connection failure, not only on timeout. Change-Id: I6b9c44cd3455d5dd383a552f9b422d3d236b67c4 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -33,7 +33,6 @@
|
|||||||
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QMessageBox>
|
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
@@ -186,6 +185,17 @@ void QmlProfilerClientManager::createConnection()
|
|||||||
this, &QmlProfilerClientManager::qmlDebugConnectionStateChanged);
|
this, &QmlProfilerClientManager::qmlDebugConnectionStateChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QmlProfilerClientManager::retryConnect()
|
||||||
|
{
|
||||||
|
disconnectClient();
|
||||||
|
if (!d->localSocket.isEmpty())
|
||||||
|
connectLocalClient(d->localSocket);
|
||||||
|
else if (!d->tcpHost.isEmpty() && d->tcpPort.isValid())
|
||||||
|
connectTcpClient(d->tcpPort);
|
||||||
|
else
|
||||||
|
emit connectionFailed();
|
||||||
|
}
|
||||||
|
|
||||||
void QmlProfilerClientManager::connectClientSignals()
|
void QmlProfilerClientManager::connectClientSignals()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(d->profilerState, return);
|
QTC_ASSERT(d->profilerState, return);
|
||||||
@@ -267,22 +277,7 @@ void QmlProfilerClientManager::tryToConnect()
|
|||||||
d->connectionAttempts = 0;
|
d->connectionAttempts = 0;
|
||||||
delete d->connection; // delete directly.
|
delete d->connection; // delete directly.
|
||||||
d->connection = 0;
|
d->connection = 0;
|
||||||
|
emit connectionFailed();
|
||||||
QMessageBox *infoBox = QmlProfilerTool::requestMessageBox();
|
|
||||||
infoBox->setIcon(QMessageBox::Critical);
|
|
||||||
infoBox->setWindowTitle(tr("Qt Creator"));
|
|
||||||
infoBox->setText(tr("Could not connect to the in-process QML profiler.\n"
|
|
||||||
"Do you want to retry?"));
|
|
||||||
infoBox->setStandardButtons(QMessageBox::Retry |
|
|
||||||
QMessageBox::Cancel |
|
|
||||||
QMessageBox::Help);
|
|
||||||
infoBox->setDefaultButton(QMessageBox::Retry);
|
|
||||||
infoBox->setModal(true);
|
|
||||||
|
|
||||||
connect(infoBox, &QDialog::finished,
|
|
||||||
this, &QmlProfilerClientManager::retryMessageBoxFinished);
|
|
||||||
|
|
||||||
infoBox->show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,30 +315,6 @@ void QmlProfilerClientManager::logState(const QString &msg)
|
|||||||
QmlProfilerTool::logState(QLatin1String("QML Profiler: ") + msg);
|
QmlProfilerTool::logState(QLatin1String("QML Profiler: ") + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerClientManager::retryMessageBoxFinished(int result)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(!d->connection, disconnectClient());
|
|
||||||
|
|
||||||
switch (result) {
|
|
||||||
case QMessageBox::Retry: {
|
|
||||||
connectTcpClient(d->tcpPort);
|
|
||||||
d->connectionAttempts = 0;
|
|
||||||
d->connectionTimer.start();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case QMessageBox::Help: {
|
|
||||||
QmlProfilerTool::handleHelpRequest(QLatin1String("qthelp://org.qt-project.qtcreator/doc/creator-debugging-qml.html"));
|
|
||||||
// fall through
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
// The actual error message has already been logged.
|
|
||||||
logState(tr("Failed to connect!"));
|
|
||||||
emit connectionFailed();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlProfilerClientManager::qmlComplete(qint64 maximumTime)
|
void QmlProfilerClientManager::qmlComplete(qint64 maximumTime)
|
||||||
{
|
{
|
||||||
if (d->profilerState->currentState() == QmlProfilerStateManager::AppStopRequested)
|
if (d->profilerState->currentState() == QmlProfilerStateManager::AppStopRequested)
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ signals:
|
|||||||
void connectionClosed();
|
void connectionClosed();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void retryConnect();
|
||||||
void connectTcpClient(Utils::Port port);
|
void connectTcpClient(Utils::Port port);
|
||||||
void connectLocalClient(const QString &file);
|
void connectLocalClient(const QString &file);
|
||||||
void disconnectClient();
|
void disconnectClient();
|
||||||
@@ -75,8 +76,6 @@ private slots:
|
|||||||
void qmlDebugConnectionStateChanged(QAbstractSocket::SocketState state);
|
void qmlDebugConnectionStateChanged(QAbstractSocket::SocketState state);
|
||||||
void logState(const QString &);
|
void logState(const QString &);
|
||||||
|
|
||||||
void retryMessageBoxFinished(int result);
|
|
||||||
|
|
||||||
void qmlComplete(qint64 maximumTime);
|
void qmlComplete(qint64 maximumTime);
|
||||||
void qmlNewEngine(int engineId);
|
void qmlNewEngine(int engineId);
|
||||||
|
|
||||||
|
|||||||
@@ -348,14 +348,15 @@ AnalyzerRunControl *QmlProfilerTool::createRunControl(RunConfiguration *runConfi
|
|||||||
void QmlProfilerTool::finalizeRunControl(QmlProfilerRunControl *runControl)
|
void QmlProfilerTool::finalizeRunControl(QmlProfilerRunControl *runControl)
|
||||||
{
|
{
|
||||||
runControl->registerProfilerStateManager(d->m_profilerState);
|
runControl->registerProfilerStateManager(d->m_profilerState);
|
||||||
|
QmlProfilerClientManager *clientManager = d->m_profilerConnections;
|
||||||
|
|
||||||
QTC_ASSERT(runControl->connection().is<AnalyzerConnection>(), return);
|
QTC_ASSERT(runControl->connection().is<AnalyzerConnection>(), return);
|
||||||
// FIXME: Check that there's something sensible in sp.connParams
|
// FIXME: Check that there's something sensible in sp.connParams
|
||||||
auto connection = runControl->connection().as<AnalyzerConnection>();
|
auto connection = runControl->connection().as<AnalyzerConnection>();
|
||||||
if (!connection.analyzerSocket.isEmpty())
|
if (!connection.analyzerSocket.isEmpty())
|
||||||
d->m_profilerConnections->setLocalSocket(connection.analyzerSocket);
|
clientManager->setLocalSocket(connection.analyzerSocket);
|
||||||
else
|
else
|
||||||
d->m_profilerConnections->setTcpConnection(connection.analyzerHost, connection.analyzerPort);
|
clientManager->setTcpConnection(connection.analyzerHost, connection.analyzerPort);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Initialize m_projectFinder
|
// Initialize m_projectFinder
|
||||||
@@ -372,8 +373,35 @@ void QmlProfilerTool::finalizeRunControl(QmlProfilerRunControl *runControl)
|
|||||||
if (connection.analyzerSocket.isEmpty())
|
if (connection.analyzerSocket.isEmpty())
|
||||||
connect(runControl, &QmlProfilerRunControl::processRunning,
|
connect(runControl, &QmlProfilerRunControl::processRunning,
|
||||||
d->m_profilerConnections, &QmlProfilerClientManager::connectTcpClient);
|
d->m_profilerConnections, &QmlProfilerClientManager::connectTcpClient);
|
||||||
connect(d->m_profilerConnections, &QmlProfilerClientManager::connectionFailed,
|
connect(clientManager, &QmlProfilerClientManager::connectionFailed,
|
||||||
runControl, &QmlProfilerRunControl::cancelProcess);
|
runControl, [clientManager, runControl]() {
|
||||||
|
QMessageBox *infoBox = new QMessageBox(ICore::mainWindow());
|
||||||
|
infoBox->setIcon(QMessageBox::Critical);
|
||||||
|
infoBox->setWindowTitle(tr("Qt Creator"));
|
||||||
|
infoBox->setText(tr("Could not connect to the in-process QML profiler.\n"
|
||||||
|
"Do you want to retry?"));
|
||||||
|
infoBox->setStandardButtons(QMessageBox::Retry | QMessageBox::Cancel | QMessageBox::Help);
|
||||||
|
infoBox->setDefaultButton(QMessageBox::Retry);
|
||||||
|
infoBox->setModal(true);
|
||||||
|
|
||||||
|
connect(infoBox, &QDialog::finished, runControl, [clientManager, runControl](int result) {
|
||||||
|
switch (result) {
|
||||||
|
case QMessageBox::Retry:
|
||||||
|
clientManager->retryConnect();
|
||||||
|
break;
|
||||||
|
case QMessageBox::Help:
|
||||||
|
HelpManager::handleHelpRequest(
|
||||||
|
"qthelp://org.qt-project.qtcreator/doc/creator-debugging-qml.html");
|
||||||
|
case QMessageBox::Cancel:
|
||||||
|
// The actual error message has already been logged.
|
||||||
|
logState(tr("Failed to connect!"));
|
||||||
|
runControl->cancelProcess();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
infoBox->show();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlProfilerTool::populateFileFinder(QString projectDirectory, QString activeSysroot)
|
void QmlProfilerTool::populateFileFinder(QString projectDirectory, QString activeSysroot)
|
||||||
@@ -817,16 +845,6 @@ void QmlProfilerTool::showNonmodalWarning(const QString &warningMsg)
|
|||||||
noExecWarning->show();
|
noExecWarning->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
QMessageBox *QmlProfilerTool::requestMessageBox()
|
|
||||||
{
|
|
||||||
return new QMessageBox(ICore::mainWindow());
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlProfilerTool::handleHelpRequest(const QString &link)
|
|
||||||
{
|
|
||||||
HelpManager::handleHelpRequest(link);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlProfilerTool::profilerStateChanged()
|
void QmlProfilerTool::profilerStateChanged()
|
||||||
{
|
{
|
||||||
switch (d->m_profilerState->currentState()) {
|
switch (d->m_profilerState->currentState()) {
|
||||||
|
|||||||
@@ -59,8 +59,6 @@ public:
|
|||||||
static QList <QAction *> profilerContextMenuActions();
|
static QList <QAction *> profilerContextMenuActions();
|
||||||
|
|
||||||
// display dialogs / log output
|
// display dialogs / log output
|
||||||
static QMessageBox *requestMessageBox();
|
|
||||||
static void handleHelpRequest(const QString &link);
|
|
||||||
static void logState(const QString &msg);
|
static void logState(const QString &msg);
|
||||||
static void logError(const QString &msg);
|
static void logError(const QString &msg);
|
||||||
static void showNonmodalWarning(const QString &warningMsg);
|
static void showNonmodalWarning(const QString &warningMsg);
|
||||||
|
|||||||
Reference in New Issue
Block a user