provide a short-circuit path for checking the js anims so we don't check over and over again
svn path=/trunk/KDE/kdelibs/; revision=1138329
This commit is contained in:
parent
3e4c38bbf4
commit
5df21d2137
@ -49,6 +49,7 @@ namespace AnimationScriptEngine
|
|||||||
|
|
||||||
QScriptEngine* inst = 0;
|
QScriptEngine* inst = 0;
|
||||||
QHash<QString, QScriptValue> s_animFuncs;
|
QHash<QString, QScriptValue> s_animFuncs;
|
||||||
|
QSet<QString> s_animFailures;
|
||||||
QString s_prefix;
|
QString s_prefix;
|
||||||
|
|
||||||
QScriptValue animation(const QString &anim)
|
QScriptValue animation(const QString &anim)
|
||||||
@ -61,9 +62,20 @@ bool isAnimationRegistered(const QString &anim)
|
|||||||
return s_animFuncs.contains(anim);
|
return s_animFuncs.contains(anim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addToLoadFailures(const QString &anim)
|
||||||
|
{
|
||||||
|
s_animFailures.insert(anim);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool animationFailedToLoad(const QString &anim)
|
||||||
|
{
|
||||||
|
return s_animFailures.contains(anim);
|
||||||
|
}
|
||||||
|
|
||||||
void clearAnimations()
|
void clearAnimations()
|
||||||
{
|
{
|
||||||
s_animFuncs.clear();
|
s_animFuncs.clear();
|
||||||
|
s_animFailures.clear();
|
||||||
delete inst;
|
delete inst;
|
||||||
inst = 0;
|
inst = 0;
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,8 @@ bool isAnimationRegistered(const QString &anim);
|
|||||||
QScriptEngine* globalEngine();
|
QScriptEngine* globalEngine();
|
||||||
QScriptValue animation(const QString &anim);
|
QScriptValue animation(const QString &anim);
|
||||||
bool loadScript(const QString &path, const QString &prefix = QString());
|
bool loadScript(const QString &path, const QString &prefix = QString());
|
||||||
|
void addToLoadFailures(const QString &anim);
|
||||||
|
bool animationFailedToLoad(const QString &anim);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,19 +183,26 @@ QEasingCurve Animator::create(Animator::CurveShape type)
|
|||||||
|
|
||||||
Plasma::Animation *Animator::create(const QString &anim, QObject *parent)
|
Plasma::Animation *Animator::create(const QString &anim, QObject *parent)
|
||||||
{
|
{
|
||||||
|
if (AnimationScriptEngine::animationFailedToLoad(anim)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!AnimationScriptEngine::isAnimationRegistered(anim)) {
|
if (!AnimationScriptEngine::isAnimationRegistered(anim)) {
|
||||||
const QString path = Theme::defaultTheme()->animationPath(anim);
|
const QString path = Theme::defaultTheme()->animationPath(anim);
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
|
AnimationScriptEngine::addToLoadFailures(anim);
|
||||||
//kError() << "************ failed to find script file for animation" << anim;
|
//kError() << "************ failed to find script file for animation" << anim;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!AnimationScriptEngine::loadScript(path)) {
|
if (!AnimationScriptEngine::loadScript(path)) {
|
||||||
|
AnimationScriptEngine::addToLoadFailures(anim);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!AnimationScriptEngine::isAnimationRegistered(anim)) {
|
if (!AnimationScriptEngine::isAnimationRegistered(anim)) {
|
||||||
//kError() << "successfully loaded script file" << path << ", but did not get animation object for" << anim;
|
//kError() << "successfully loaded script file" << path << ", but did not get animation object for" << anim;
|
||||||
|
AnimationScriptEngine::addToLoadFailures(anim);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user