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"));
|
||||
|
||||
auto squishTools = SquishTools::instance();
|
||||
connect(squishTools, &SquishTools::queryFinished, this,
|
||||
[this] (const QString &out, const QString &) {
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
|
||||
squishTools->queryServerSettings([this] (const QString &out, const QString &) {
|
||||
SquishServerSettings s;
|
||||
s.setFromXmlOutput(out);
|
||||
QApplication::restoreOverrideCursor();
|
||||
for (const QString &app : s.mappedAuts.keys())
|
||||
aut.addItem(app);
|
||||
});
|
||||
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
squishTools->queryServerSettings();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -406,15 +406,13 @@ SquishServerSettingsWidget::SquishServerSettingsWidget(QWidget *parent)
|
||||
|
||||
// query settings
|
||||
SquishTools *squishTools = SquishTools::instance();
|
||||
connect(squishTools, &SquishTools::queryFinished, this,
|
||||
[this, progress] (const QString &out, const QString &) {
|
||||
squishTools->queryServerSettings([this, progress] (const QString &out, const QString &) {
|
||||
m_serverSettings.setFromXmlOutput(out);
|
||||
m_originalSettings.setFromXmlOutput(out);
|
||||
repopulateApplicationView();
|
||||
progress->hide();
|
||||
setEnabled(true);
|
||||
});
|
||||
squishTools->queryServerSettings();
|
||||
}
|
||||
|
||||
void SquishServerSettingsWidget::repopulateApplicationView()
|
||||
|
@@ -260,10 +260,12 @@ void SquishTools::runTestCases(const FilePath &suitePath,
|
||||
startSquishServer(RunTestRequested);
|
||||
}
|
||||
|
||||
void SquishTools::queryServerSettings()
|
||||
void SquishTools::queryServerSettings(QueryCallback callback)
|
||||
{
|
||||
if (m_shutdownInitiated)
|
||||
return;
|
||||
m_queryCallback = callback;
|
||||
|
||||
if (m_state != Idle) {
|
||||
QMessageBox::critical(Core::ICore::dialogParent(),
|
||||
Tr::tr("Error"),
|
||||
@@ -686,9 +688,11 @@ void SquishTools::onRunnerFinished()
|
||||
if (m_request == RunnerQueryRequested) {
|
||||
const QString error = m_licenseIssues ? Tr::tr("Could not get Squish license from server.")
|
||||
: QString();
|
||||
emit queryFinished(m_fullRunnerOutput, error);
|
||||
if (m_queryCallback)
|
||||
m_queryCallback(m_fullRunnerOutput, error);
|
||||
setState(RunnerStopped);
|
||||
m_fullRunnerOutput.clear();
|
||||
m_queryCallback = {};
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -61,12 +61,14 @@ public:
|
||||
Finished
|
||||
};
|
||||
|
||||
using QueryCallback = std::function<void(const QString &, const QString &)>;
|
||||
|
||||
State state() const { return m_state; }
|
||||
void runTestCases(const Utils::FilePath &suitePath,
|
||||
const QStringList &testCases = QStringList());
|
||||
void recordTestCase(const Utils::FilePath &suitePath, const QString &testCaseName,
|
||||
const SuiteConf &suiteConf);
|
||||
void queryServerSettings();
|
||||
void queryServerSettings(QueryCallback callback);
|
||||
void writeServerSettingsChanges(const QList<QStringList> &changes);
|
||||
void requestExpansion(const QString &name);
|
||||
|
||||
@@ -77,7 +79,6 @@ signals:
|
||||
void squishTestRunStarted();
|
||||
void squishTestRunFinished();
|
||||
void resultOutputCreated(const QByteArray &output);
|
||||
void queryFinished(const QString &output, const QString &error);
|
||||
void configChangesFailed(QProcess::ProcessError error);
|
||||
void configChangesWritten();
|
||||
void localsUpdated(const QString &output);
|
||||
@@ -161,6 +162,7 @@ private:
|
||||
QTimer *m_requestVarsTimer = nullptr;
|
||||
qint64 m_readResultsCount;
|
||||
int m_autId = 0;
|
||||
QueryCallback m_queryCallback;
|
||||
bool m_shutdownInitiated = false;
|
||||
bool m_closeRunnerOnEndRecord = false;
|
||||
bool m_licenseIssues = false;
|
||||
|
@@ -126,8 +126,8 @@ void SquishToolkitsPage::fetchServerSettings()
|
||||
auto squishTools = SquishTools::instance();
|
||||
QTC_ASSERT(squishTools, return);
|
||||
|
||||
connect(squishTools, &SquishTools::queryFinished, this,
|
||||
[this] (const QString &out, const QString &error) {
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
squishTools->queryServerSettings([this](const QString &out, const QString &error) {
|
||||
SquishServerSettings s;
|
||||
s.setFromXmlOutput(out);
|
||||
QApplication::restoreOverrideCursor();
|
||||
@@ -149,8 +149,6 @@ void SquishToolkitsPage::fetchServerSettings()
|
||||
m_errorLabel->setVisible(true);
|
||||
}
|
||||
});
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
squishTools->queryServerSettings();
|
||||
}
|
||||
|
||||
/********************************* ScriptLanguagePage ********************************************/
|
||||
|
Reference in New Issue
Block a user