forked from qt-creator/qt-creator
Squish: Use callback instead of signals and slots
...when "querying" the server. There are other queries which need to get handled properly. Reduces maintenance as using a callback here allows to avoid unnecessary connects and drops the need of the disconnects. Change-Id: Ib1c2c2b5b20c84b7eee5503ad134f5ab0e18c5a6 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -74,17 +74,15 @@ public:
|
|||||||
setWindowTitle(Tr::tr("Recording Settings"));
|
setWindowTitle(Tr::tr("Recording Settings"));
|
||||||
|
|
||||||
auto squishTools = SquishTools::instance();
|
auto squishTools = SquishTools::instance();
|
||||||
connect(squishTools, &SquishTools::queryFinished, this,
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
[this] (const QString &out, const QString &) {
|
|
||||||
|
squishTools->queryServerSettings([this] (const QString &out, const QString &) {
|
||||||
SquishServerSettings s;
|
SquishServerSettings s;
|
||||||
s.setFromXmlOutput(out);
|
s.setFromXmlOutput(out);
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
for (const QString &app : s.mappedAuts.keys())
|
for (const QString &app : s.mappedAuts.keys())
|
||||||
aut.addItem(app);
|
aut.addItem(app);
|
||||||
});
|
});
|
||||||
|
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
|
||||||
squishTools->queryServerSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -406,15 +406,13 @@ SquishServerSettingsWidget::SquishServerSettingsWidget(QWidget *parent)
|
|||||||
|
|
||||||
// query settings
|
// query settings
|
||||||
SquishTools *squishTools = SquishTools::instance();
|
SquishTools *squishTools = SquishTools::instance();
|
||||||
connect(squishTools, &SquishTools::queryFinished, this,
|
squishTools->queryServerSettings([this, progress] (const QString &out, const QString &) {
|
||||||
[this, progress] (const QString &out, const QString &) {
|
|
||||||
m_serverSettings.setFromXmlOutput(out);
|
m_serverSettings.setFromXmlOutput(out);
|
||||||
m_originalSettings.setFromXmlOutput(out);
|
m_originalSettings.setFromXmlOutput(out);
|
||||||
repopulateApplicationView();
|
repopulateApplicationView();
|
||||||
progress->hide();
|
progress->hide();
|
||||||
setEnabled(true);
|
setEnabled(true);
|
||||||
});
|
});
|
||||||
squishTools->queryServerSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SquishServerSettingsWidget::repopulateApplicationView()
|
void SquishServerSettingsWidget::repopulateApplicationView()
|
||||||
|
@@ -260,10 +260,12 @@ void SquishTools::runTestCases(const FilePath &suitePath,
|
|||||||
startSquishServer(RunTestRequested);
|
startSquishServer(RunTestRequested);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SquishTools::queryServerSettings()
|
void SquishTools::queryServerSettings(QueryCallback callback)
|
||||||
{
|
{
|
||||||
if (m_shutdownInitiated)
|
if (m_shutdownInitiated)
|
||||||
return;
|
return;
|
||||||
|
m_queryCallback = callback;
|
||||||
|
|
||||||
if (m_state != Idle) {
|
if (m_state != Idle) {
|
||||||
QMessageBox::critical(Core::ICore::dialogParent(),
|
QMessageBox::critical(Core::ICore::dialogParent(),
|
||||||
Tr::tr("Error"),
|
Tr::tr("Error"),
|
||||||
@@ -686,9 +688,11 @@ void SquishTools::onRunnerFinished()
|
|||||||
if (m_request == RunnerQueryRequested) {
|
if (m_request == RunnerQueryRequested) {
|
||||||
const QString error = m_licenseIssues ? Tr::tr("Could not get Squish license from server.")
|
const QString error = m_licenseIssues ? Tr::tr("Could not get Squish license from server.")
|
||||||
: QString();
|
: QString();
|
||||||
emit queryFinished(m_fullRunnerOutput, error);
|
if (m_queryCallback)
|
||||||
|
m_queryCallback(m_fullRunnerOutput, error);
|
||||||
setState(RunnerStopped);
|
setState(RunnerStopped);
|
||||||
m_fullRunnerOutput.clear();
|
m_fullRunnerOutput.clear();
|
||||||
|
m_queryCallback = {};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -61,12 +61,14 @@ public:
|
|||||||
Finished
|
Finished
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using QueryCallback = std::function<void(const QString &, const QString &)>;
|
||||||
|
|
||||||
State state() const { return m_state; }
|
State state() const { return m_state; }
|
||||||
void runTestCases(const Utils::FilePath &suitePath,
|
void runTestCases(const Utils::FilePath &suitePath,
|
||||||
const QStringList &testCases = QStringList());
|
const QStringList &testCases = QStringList());
|
||||||
void recordTestCase(const Utils::FilePath &suitePath, const QString &testCaseName,
|
void recordTestCase(const Utils::FilePath &suitePath, const QString &testCaseName,
|
||||||
const SuiteConf &suiteConf);
|
const SuiteConf &suiteConf);
|
||||||
void queryServerSettings();
|
void queryServerSettings(QueryCallback callback);
|
||||||
void writeServerSettingsChanges(const QList<QStringList> &changes);
|
void writeServerSettingsChanges(const QList<QStringList> &changes);
|
||||||
void requestExpansion(const QString &name);
|
void requestExpansion(const QString &name);
|
||||||
|
|
||||||
@@ -77,7 +79,6 @@ signals:
|
|||||||
void squishTestRunStarted();
|
void squishTestRunStarted();
|
||||||
void squishTestRunFinished();
|
void squishTestRunFinished();
|
||||||
void resultOutputCreated(const QByteArray &output);
|
void resultOutputCreated(const QByteArray &output);
|
||||||
void queryFinished(const QString &output, const QString &error);
|
|
||||||
void configChangesFailed(QProcess::ProcessError error);
|
void configChangesFailed(QProcess::ProcessError error);
|
||||||
void configChangesWritten();
|
void configChangesWritten();
|
||||||
void localsUpdated(const QString &output);
|
void localsUpdated(const QString &output);
|
||||||
@@ -161,6 +162,7 @@ private:
|
|||||||
QTimer *m_requestVarsTimer = nullptr;
|
QTimer *m_requestVarsTimer = nullptr;
|
||||||
qint64 m_readResultsCount;
|
qint64 m_readResultsCount;
|
||||||
int m_autId = 0;
|
int m_autId = 0;
|
||||||
|
QueryCallback m_queryCallback;
|
||||||
bool m_shutdownInitiated = false;
|
bool m_shutdownInitiated = false;
|
||||||
bool m_closeRunnerOnEndRecord = false;
|
bool m_closeRunnerOnEndRecord = false;
|
||||||
bool m_licenseIssues = false;
|
bool m_licenseIssues = false;
|
||||||
|
@@ -126,8 +126,8 @@ void SquishToolkitsPage::fetchServerSettings()
|
|||||||
auto squishTools = SquishTools::instance();
|
auto squishTools = SquishTools::instance();
|
||||||
QTC_ASSERT(squishTools, return);
|
QTC_ASSERT(squishTools, return);
|
||||||
|
|
||||||
connect(squishTools, &SquishTools::queryFinished, this,
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
[this] (const QString &out, const QString &error) {
|
squishTools->queryServerSettings([this](const QString &out, const QString &error) {
|
||||||
SquishServerSettings s;
|
SquishServerSettings s;
|
||||||
s.setFromXmlOutput(out);
|
s.setFromXmlOutput(out);
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
@@ -149,8 +149,6 @@ void SquishToolkitsPage::fetchServerSettings()
|
|||||||
m_errorLabel->setVisible(true);
|
m_errorLabel->setVisible(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
|
||||||
squishTools->queryServerSettings();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************* ScriptLanguagePage ********************************************/
|
/********************************* ScriptLanguagePage ********************************************/
|
||||||
|
Reference in New Issue
Block a user