forked from qt-creator/qt-creator
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:
@@ -129,7 +129,6 @@ AbstractSettings::AbstractSettings(const QString &name, const QString &ending)
|
|||||||
, m_styleDir(Core::ICore::userResourcePath(Beautifier::Constants::SETTINGS_DIRNAME)
|
, m_styleDir(Core::ICore::userResourcePath(Beautifier::Constants::SETTINGS_DIRNAME)
|
||||||
.pathAppended(name)
|
.pathAppended(name)
|
||||||
.toString())
|
.toString())
|
||||||
, m_versionUpdater(new VersionUpdater)
|
|
||||||
{
|
{
|
||||||
setSettingsGroups(Utils::Constants::BEAUTIFIER_SETTINGS_GROUP, name);
|
setSettingsGroups(Utils::Constants::BEAUTIFIER_SETTINGS_GROUP, name);
|
||||||
|
|
||||||
@@ -159,9 +158,7 @@ AbstractSettings::AbstractSettings(const QString &name, const QString &ending)
|
|||||||
return types.join("; ");
|
return types.join("; ");
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(&command, &BaseAspect::changed, this, [this] {
|
connect(&command, &BaseAspect::changed, this, [this] { m_version = {}; version(); });
|
||||||
m_versionUpdater->update(command());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractSettings::~AbstractSettings() = default;
|
AbstractSettings::~AbstractSettings() = default;
|
||||||
@@ -232,12 +229,18 @@ QString AbstractSettings::styleFileName(const QString &key) const
|
|||||||
|
|
||||||
QVersionNumber AbstractSettings::version() 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)
|
void AbstractSettings::setVersionRegExp(const QRegularExpression &versionRegExp)
|
||||||
{
|
{
|
||||||
m_versionUpdater->setVersionRegExp(versionRegExp);
|
m_versionRegExp = versionRegExp;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AbstractSettings::isApplicable(const Core::IDocument *document) const
|
bool AbstractSettings::isApplicable(const Core::IDocument *document) const
|
||||||
|
@@ -8,22 +8,18 @@
|
|||||||
#include <texteditor/command.h>
|
#include <texteditor/command.h>
|
||||||
|
|
||||||
#include <utils/aspects.h>
|
#include <utils/aspects.h>
|
||||||
#include <utils/filepath.h>
|
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QRegularExpression>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QVersionNumber>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QRegularExpression;
|
|
||||||
class QVersionNumber;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class IDocument;
|
class IDocument;
|
||||||
class IEditor;
|
class IEditor;
|
||||||
@@ -58,8 +54,6 @@ public:
|
|||||||
static void showError(const QString &error);
|
static void showError(const QString &error);
|
||||||
};
|
};
|
||||||
|
|
||||||
class VersionUpdater;
|
|
||||||
|
|
||||||
class AbstractSettings : public Utils::AspectContainer
|
class AbstractSettings : public Utils::AspectContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -104,12 +98,13 @@ protected:
|
|||||||
virtual void readStyles();
|
virtual void readStyles();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<VersionUpdater> m_versionUpdater;
|
|
||||||
QStringList m_stylesToRemove;
|
QStringList m_stylesToRemove;
|
||||||
QSet<QString> m_changedStyles;
|
QSet<QString> m_changedStyles;
|
||||||
QHash<QString, int> m_options;
|
QHash<QString, int> m_options;
|
||||||
QStringList m_docu;
|
QStringList m_docu;
|
||||||
QStringList m_supportedMimeTypes;
|
QStringList m_supportedMimeTypes;
|
||||||
|
mutable QVersionNumber m_version;
|
||||||
|
QRegularExpression m_versionRegExp;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Beautifier::Internal
|
} // Beautifier::Internal
|
||||||
|
Reference in New Issue
Block a user