Avoid global static for effects
Otherwise we call i18n without a QCoreApplication Differential Revision: https://phabricator.kde.org/D15163
This commit is contained in:
parent
16c63efdb7
commit
0fd939425b
1 changed files with 13 additions and 9 deletions
|
@ -85,7 +85,9 @@ inline Effect *createHelper()
|
||||||
return new T();
|
return new T();
|
||||||
}
|
}
|
||||||
|
|
||||||
static const QVector<EffectData> s_effectData = {
|
static const QVector<EffectData> &effectData()
|
||||||
|
{
|
||||||
|
static const QVector<EffectData> s_effectData = {
|
||||||
{
|
{
|
||||||
QString(),
|
QString(),
|
||||||
QString(),
|
QString(),
|
||||||
|
@ -699,7 +701,9 @@ EFFECT_FALLBACK
|
||||||
#endif
|
#endif
|
||||||
EFFECT_FALLBACK
|
EFFECT_FALLBACK
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
return s_effectData;
|
||||||
|
}
|
||||||
|
|
||||||
static inline int index(BuiltInEffect effect)
|
static inline int index(BuiltInEffect effect)
|
||||||
{
|
{
|
||||||
|
@ -717,12 +721,12 @@ Effect *create(BuiltInEffect effect)
|
||||||
|
|
||||||
bool available(const QString &name)
|
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) {
|
[name](const EffectData &data) {
|
||||||
return data.name == name;
|
return data.name == name;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return it != s_effectData.end();
|
return it != effectData().end();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool supported(BuiltInEffect effect)
|
bool supported(BuiltInEffect effect)
|
||||||
|
@ -757,7 +761,7 @@ bool enabledByDefault(BuiltInEffect effect)
|
||||||
QStringList availableEffectNames()
|
QStringList availableEffectNames()
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
for (const EffectData &data : s_effectData) {
|
for (const EffectData &data : effectData()) {
|
||||||
if (data.name.isEmpty()) {
|
if (data.name.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -777,15 +781,15 @@ QList< BuiltInEffect > availableEffects()
|
||||||
|
|
||||||
BuiltInEffect builtInForName(const QString &name)
|
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) {
|
[name](const EffectData &data) {
|
||||||
return data.name == name;
|
return data.name == name;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if (it == s_effectData.end()) {
|
if (it == effectData().end()) {
|
||||||
return BuiltInEffect::Invalid;
|
return BuiltInEffect::Invalid;
|
||||||
}
|
}
|
||||||
return BuiltInEffect(std::distance(s_effectData.begin(), it));
|
return BuiltInEffect(std::distance(effectData().begin(), it));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString nameForEffect(BuiltInEffect effect)
|
QString nameForEffect(BuiltInEffect effect)
|
||||||
|
@ -795,7 +799,7 @@ QString nameForEffect(BuiltInEffect effect)
|
||||||
|
|
||||||
const EffectData &effectData(BuiltInEffect effect)
|
const EffectData &effectData(BuiltInEffect effect)
|
||||||
{
|
{
|
||||||
return s_effectData.at(index(effect));
|
return effectData().at(index(effect));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // BuiltInEffects
|
} // BuiltInEffects
|
||||||
|
|
Loading…
Reference in a new issue