Beautifier: Make sure version update process finishes

Change-Id: Ifd6fcee56d03f2853c7b196e8dade650f4e60e55
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-07-11 09:01:38 +02:00
parent dbfc2a3242
commit 6346952380
2 changed files with 13 additions and 15 deletions

View File

@@ -129,7 +129,6 @@ AbstractSettings::AbstractSettings(const QString &name, const QString &ending)
, m_styleDir(Core::ICore::userResourcePath(Beautifier::Constants::SETTINGS_DIRNAME)
.pathAppended(name)
.toString())
, m_versionUpdater(new VersionUpdater)
{
setSettingsGroups(Utils::Constants::BEAUTIFIER_SETTINGS_GROUP, name);
@@ -159,9 +158,7 @@ AbstractSettings::AbstractSettings(const QString &name, const QString &ending)
return types.join("; ");
});
connect(&command, &BaseAspect::changed, this, [this] {
m_versionUpdater->update(command());
});
connect(&command, &BaseAspect::changed, this, [this] { m_version = {}; version(); });
}
AbstractSettings::~AbstractSettings() = default;
@@ -232,12 +229,18 @@ QString AbstractSettings::styleFileName(const QString &key) const
QVersionNumber AbstractSettings::version() const
{
return m_versionUpdater->version();
if (m_version.isNull()) {
VersionUpdater updater;
updater.setVersionRegExp(m_versionRegExp);
updater.update(command());
m_version = updater.version();
}
return m_version;
}
void AbstractSettings::setVersionRegExp(const QRegularExpression &versionRegExp)
{
m_versionUpdater->setVersionRegExp(versionRegExp);
m_versionRegExp = versionRegExp;
}
bool AbstractSettings::isApplicable(const Core::IDocument *document) const

View File

@@ -8,22 +8,18 @@
#include <texteditor/command.h>
#include <utils/aspects.h>
#include <utils/filepath.h>
#include <QDir>
#include <QHash>
#include <QMap>
#include <QObject>
#include <QRegularExpression>
#include <QSet>
#include <QStringList>
#include <QVersionNumber>
#include <memory>
QT_BEGIN_NAMESPACE
class QRegularExpression;
class QVersionNumber;
QT_END_NAMESPACE
namespace Core {
class IDocument;
class IEditor;
@@ -58,8 +54,6 @@ public:
static void showError(const QString &error);
};
class VersionUpdater;
class AbstractSettings : public Utils::AspectContainer
{
public:
@@ -104,12 +98,13 @@ protected:
virtual void readStyles();
private:
std::unique_ptr<VersionUpdater> m_versionUpdater;
QStringList m_stylesToRemove;
QSet<QString> m_changedStyles;
QHash<QString, int> m_options;
QStringList m_docu;
QStringList m_supportedMimeTypes;
mutable QVersionNumber m_version;
QRegularExpression m_versionRegExp;
};
} // Beautifier::Internal