History

new --scripts switch overrides default scripts location

David Kelly committed 9 years ago

Commit ff5b37c1 parent 34edd958 files · +81 −45Browse files

Showing the changes to libraries/script-engine/src/ScriptEngines.cpp (1 of 8 files). Show all

Unified · Split

libraries/script-engine/src/ScriptEngines.cpp+14−7
@@ -74,7 +74,7 @@ ScriptEngines::ScriptEngines(ScriptEngine::Context context) · 73 unmodified lines
74QUrl normalizeScriptURL(const QUrl& rawScriptURL) {74QUrl normalizeScriptURL(const QUrl& rawScriptURL) {
75 if (rawScriptURL.scheme() == "file") {75 if (rawScriptURL.scheme() == "file") {
76 QUrl fullNormal = rawScriptURL;76 QUrl fullNormal = rawScriptURL;
77 QUrl defaultScriptLoc = defaultScriptsLocation();77 QUrl defaultScriptLoc = PathUtils::defaultScriptsLocation();
78 78
79 // if this url is something "beneath" the default script url, replace the local path with ~79 // if this url is something "beneath" the default script url, replace the local path with ~
80 if (fullNormal.scheme() == defaultScriptLoc.scheme() &&80 if (fullNormal.scheme() == defaultScriptLoc.scheme() &&
@@ -93,7 +93,7 @@ QUrl normalizeScriptURL(const QUrl& rawScriptURL) { · 12 unmodified lines
93 93
94QString expandScriptPath(const QString& rawPath) {94QString expandScriptPath(const QString& rawPath) {
95 QStringList splitPath = rawPath.split("/");95 QStringList splitPath = rawPath.split("/");
96 QUrl defaultScriptsLoc = defaultScriptsLocation();96 QUrl defaultScriptsLoc = PathUtils::defaultScriptsLocation();
97 return defaultScriptsLoc.path() + "/" + splitPath.mid(2).join("/"); // 2 to skip the slashes in /~/97 return defaultScriptsLoc.path() + "/" + splitPath.mid(2).join("/"); // 2 to skip the slashes in /~/
98}98}
99 99
@@ -112,7 +112,7 @@ QUrl expandScriptUrl(const QUrl& rawScriptURL) { · 12 unmodified lines
112 QFileInfo fileInfo(url.toLocalFile());112 QFileInfo fileInfo(url.toLocalFile());
113 url = QUrl::fromLocalFile(fileInfo.canonicalFilePath());113 url = QUrl::fromLocalFile(fileInfo.canonicalFilePath());
114 114
115 QUrl defaultScriptsLoc = defaultScriptsLocation();115 QUrl defaultScriptsLoc = PathUtils::defaultScriptsLocation();
116 if (!defaultScriptsLoc.isParentOf(url)) {116 if (!defaultScriptsLoc.isParentOf(url)) {
117 qCWarning(scriptengine) << "Script.include() ignoring file path" << rawScriptURL117 qCWarning(scriptengine) << "Script.include() ignoring file path" << rawScriptURL
118 << "-- outside of standard libraries: "118 << "-- outside of standard libraries: "
@@ -327,6 +327,13 @@ void ScriptEngines::saveScripts() { · 208 unmodified lines
327 return;327 return;
328 }328 }
329 329
330 // don't save scripts if we started with --scripts, as we would overwrite
331 // the scripts that the user expects to be there when launched without the
332 // --scripts override.
333 if (_defaultScriptsLocationOverridden) {
334 return;
335 }
336
330 // Saves all currently running user-loaded scripts337 // Saves all currently running user-loaded scripts
331 QVariantList list;338 QVariantList list;
332 339
@@ -533,11 +540,11 @@ void ScriptEngines::launchScriptEngine(ScriptEngine* scriptEngine) { · 200 unmodified lines
533 initializer(scriptEngine);540 initializer(scriptEngine);
534 }541 }
535 542
536 // FIXME disabling 'shift key' debugging for now. If you start up the application with 543 // FIXME disabling 'shift key' debugging for now. If you start up the application with
537 // the shift key held down, it triggers a deadlock because of script interfaces running 544 // the shift key held down, it triggers a deadlock because of script interfaces running
538 // on the main thread545 // on the main thread
539 auto const wantDebug = scriptEngine->isDebuggable(); // || (qApp->queryKeyboardModifiers() & Qt::ShiftModifier);546 auto const wantDebug = scriptEngine->isDebuggable(); // || (qApp->queryKeyboardModifiers() & Qt::ShiftModifier);
540 547
541 if (HIFI_SCRIPT_DEBUGGABLES && wantDebug) {548 if (HIFI_SCRIPT_DEBUGGABLES && wantDebug) {
542 scriptEngine->runDebuggable();549 scriptEngine->runDebuggable();
543 } else {550 } else {
@@ -573,5 +580,5 @@ void ScriptEngines::onScriptEngineError(const QString& scriptFilename) { · 29 unmodified lines
573}580}
574 581
575QString ScriptEngines::getDefaultScriptsLocation() const {582QString ScriptEngines::getDefaultScriptsLocation() const {
576 return defaultScriptsLocation().toString();583 return PathUtils::defaultScriptsLocation().toString();
577}584}