Avoid global static for effects
Otherwise we call i18n without a QCoreApplication
Differential Revision: https://phabricator.kde.org/D15163
(cherry picked from commit 0fd939425b
)
This commit is contained in:
parent
fa5242b3ee
commit
3cfb7a30f0
1 changed files with 13 additions and 9 deletions
|
@ -84,7 +84,9 @@ inline Effect *createHelper()
|
|||
return new T();
|
||||
}
|
||||
|
||||
static const QVector<EffectData> s_effectData = {
|
||||
static const QVector<EffectData> &effectData()
|
||||
{
|
||||
static const QVector<EffectData> s_effectData = {
|
||||
{
|
||||
QString(),
|
||||
QString(),
|
||||
|
@ -683,7 +685,9 @@ EFFECT_FALLBACK
|
|||
#endif
|
||||
EFFECT_FALLBACK
|
||||
}
|
||||
};
|
||||
};
|
||||
return s_effectData;
|
||||
}
|
||||
|
||||
static inline int index(BuiltInEffect effect)
|
||||
{
|
||||
|
@ -701,12 +705,12 @@ Effect *create(BuiltInEffect effect)
|
|||
|
||||
bool available(const QString &name)
|
||||
{
|
||||
auto it = std::find_if(s_effectData.begin(), s_effectData.end(),
|
||||
auto it = std::find_if(effectData().begin(), effectData().end(),
|
||||
[name](const EffectData &data) {
|
||||
return data.name == name;
|
||||
}
|
||||
);
|
||||
return it != s_effectData.end();
|
||||
return it != effectData().end();
|
||||
}
|
||||
|
||||
bool supported(BuiltInEffect effect)
|
||||
|
@ -741,7 +745,7 @@ bool enabledByDefault(BuiltInEffect effect)
|
|||
QStringList availableEffectNames()
|
||||
{
|
||||
QStringList result;
|
||||
for (const EffectData &data : s_effectData) {
|
||||
for (const EffectData &data : effectData()) {
|
||||
if (data.name.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -761,15 +765,15 @@ QList< BuiltInEffect > availableEffects()
|
|||
|
||||
BuiltInEffect builtInForName(const QString &name)
|
||||
{
|
||||
auto it = std::find_if(s_effectData.begin(), s_effectData.end(),
|
||||
auto it = std::find_if(effectData().begin(), effectData().end(),
|
||||
[name](const EffectData &data) {
|
||||
return data.name == name;
|
||||
}
|
||||
);
|
||||
if (it == s_effectData.end()) {
|
||||
if (it == effectData().end()) {
|
||||
return BuiltInEffect::Invalid;
|
||||
}
|
||||
return BuiltInEffect(std::distance(s_effectData.begin(), it));
|
||||
return BuiltInEffect(std::distance(effectData().begin(), it));
|
||||
}
|
||||
|
||||
QString nameForEffect(BuiltInEffect effect)
|
||||
|
@ -779,7 +783,7 @@ QString nameForEffect(BuiltInEffect effect)
|
|||
|
||||
const EffectData &effectData(BuiltInEffect effect)
|
||||
{
|
||||
return s_effectData.at(index(effect));
|
||||
return effectData().at(index(effect));
|
||||
}
|
||||
|
||||
} // BuiltInEffects
|
||||
|
|
Loading…
Reference in a new issue