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
7474 QUrl normalizeScriptURL(const QUrl& rawScriptURL) {
7575 if (rawScriptURL.scheme() == "file") {
7676 QUrl fullNormal = rawScriptURL;
77− QUrl defaultScriptLoc = defaultScriptsLocation();
77+ QUrl defaultScriptLoc = PathUtils::defaultScriptsLocation();
7878
7979 // if this url is something "beneath" the default script url, replace the local path with ~
8080 if (fullNormal.scheme() == defaultScriptLoc.scheme() &&
@@ -93,7 +93,7 @@ QUrl normalizeScriptURL(const QUrl& rawScriptURL) { · 12 unmodified lines
9393
9494 QString expandScriptPath(const QString& rawPath) {
9595 QStringList splitPath = rawPath.split("/");
96− QUrl defaultScriptsLoc = defaultScriptsLocation();
96+ QUrl defaultScriptsLoc = PathUtils::defaultScriptsLocation();
9797 return defaultScriptsLoc.path() + "/" + splitPath.mid(2).join("/"); // 2 to skip the slashes in /~/
9898 }
9999
@@ -112,7 +112,7 @@ QUrl expandScriptUrl(const QUrl& rawScriptURL) { · 12 unmodified lines
112112 QFileInfo fileInfo(url.toLocalFile());
113113 url = QUrl::fromLocalFile(fileInfo.canonicalFilePath());
114114
115− QUrl defaultScriptsLoc = defaultScriptsLocation();
115+ QUrl defaultScriptsLoc = PathUtils::defaultScriptsLocation();
116116 if (!defaultScriptsLoc.isParentOf(url)) {
117117 qCWarning(scriptengine) << "Script.include() ignoring file path" << rawScriptURL
118118 << "-- outside of standard libraries: "
@@ -327,6 +327,13 @@ void ScriptEngines::saveScripts() { · 208 unmodified lines
327327 return;
328328 }
329329
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+
330337 // Saves all currently running user-loaded scripts
331338 QVariantList list;
332339
@@ -533,11 +540,11 @@ void ScriptEngines::launchScriptEngine(ScriptEngine* scriptEngine) { · 200 unmodified lines
533540 initializer(scriptEngine);
534541 }
535542
536− // 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
543+ // FIXME disabling 'shift key' debugging for now. If you start up the application with
544+ // the shift key held down, it triggers a deadlock because of script interfaces running
538545 // on the main thread
539546 auto const wantDebug = scriptEngine->isDebuggable(); // || (qApp->queryKeyboardModifiers() & Qt::ShiftModifier);
540−
547+
541548 if (HIFI_SCRIPT_DEBUGGABLES && wantDebug) {
542549 scriptEngine->runDebuggable();
543550 } else {
@@ -573,5 +580,5 @@ void ScriptEngines::onScriptEngineError(const QString& scriptFilename) { · 29 unmodified lines
573580 }
574581
575582 QString ScriptEngines::getDefaultScriptsLocation() const {
576− return defaultScriptsLocation().toString();
583+ return PathUtils::defaultScriptsLocation().toString();
577584 }