| 150 | } |
| 151 | |
| 152 | void TWScriptManager::reloadScriptsInList(TWScriptList * list, QStringList & processed) |
| 153 | { |
| 154 | Tw::Settings settings; |
| 155 | bool enableScriptsPlugins = settings.value(QString::fromLatin1("enableScriptingPlugins"), false).toBool(); |
| 156 | |
| 157 | foreach(QObject * item, list->children()) { |
| 158 | if (qobject_cast<TWScriptList*>(item)) |
| 159 | reloadScriptsInList(qobject_cast<TWScriptList*>(item), processed); |
| 160 | else if (qobject_cast<Tw::Scripting::ScriptObject*>(item)) { |
| 161 | Tw::Scripting::ScriptObject * so = qobject_cast<Tw::Scripting::ScriptObject*>(item); |
| 162 | if (so->hasChanged()) { |
| 163 | // File has been removed |
| 164 | if (!(QFileInfo(so->getFilename()).exists())) { |
| 165 | delete so; |
| 166 | continue; |
| 167 | } |
| 168 | // File has been changed - reparse; if an error occurs or the |
| 169 | // script type has changed treat it as if has been removed (and |
| 170 | // possibly re-add it later) |
| 171 | if (!so->getScript()) { |
| 172 | delete so; |
| 173 | continue; |
| 174 | } |
| 175 | Tw::Scripting::Script::ScriptType oldType = so->getType(); |
| 176 | if (!so->getScript()->parseHeader() || so->getType() != oldType) { |
| 177 | delete so; |
| 178 | continue; |
| 179 | } |
| 180 | } |
| 181 | const bool needsPlugin = ( |
| 182 | #if WITH_QTSCRIPT |
| 183 | qobject_cast<const Tw::Scripting::JSScriptInterface*>(so->getScriptLanguagePlugin()) == nullptr && |
| 184 | #endif |
| 185 | qobject_cast<const Tw::Scripting::ECMAScriptInterface*>(so->getScriptLanguagePlugin()) == nullptr |
| 186 | ); |
| 187 | if (needsPlugin && !enableScriptsPlugins) { |
| 188 | // the plugin necessary to execute this scripts has been disabled |
| 189 | delete so; |
| 190 | continue; |
| 191 | } |
| 192 | processed << so->getFilename(); |
| 193 | } |
| 194 | else { |
| 195 | // should never happen |
| 196 | } |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | |
| 201 | void TWScriptManager::clear() |
nothing calls this directly
no test coverage detected