mirror of
https://github.com/overte-org/overte.git
synced 2025-04-13 16:05:17 +02:00
Merge pull request #10755 from seefo/fb5278
Fixed an issue where toolbar buttons duplicated themselves when reloading scripts
This commit is contained in:
commit
7668fbb7a0
3 changed files with 21 additions and 4 deletions
|
@ -356,6 +356,13 @@ QStringList ScriptEngines::getRunningScripts() {
|
||||||
void ScriptEngines::stopAllScripts(bool restart) {
|
void ScriptEngines::stopAllScripts(bool restart) {
|
||||||
QVector<QString> toReload;
|
QVector<QString> toReload;
|
||||||
QReadLocker lock(&_scriptEnginesHashLock);
|
QReadLocker lock(&_scriptEnginesHashLock);
|
||||||
|
|
||||||
|
if (_isReloading) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
_isReloading = true;
|
||||||
|
}
|
||||||
|
|
||||||
for (QHash<QUrl, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin();
|
for (QHash<QUrl, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin();
|
||||||
it != _scriptEnginesHash.constEnd(); it++) {
|
it != _scriptEnginesHash.constEnd(); it++) {
|
||||||
ScriptEngine *scriptEngine = it.value();
|
ScriptEngine *scriptEngine = it.value();
|
||||||
|
@ -375,7 +382,7 @@ void ScriptEngines::stopAllScripts(bool restart) {
|
||||||
}
|
}
|
||||||
// wait for engines to stop (ie: providing time for .scriptEnding cleanup handlers to run) before
|
// wait for engines to stop (ie: providing time for .scriptEnding cleanup handlers to run) before
|
||||||
// triggering reload of any Client scripts / Entity scripts
|
// triggering reload of any Client scripts / Entity scripts
|
||||||
QTimer::singleShot(500, this, [=]() {
|
QTimer::singleShot(1000, this, [=]() {
|
||||||
for(const auto &scriptName : toReload) {
|
for(const auto &scriptName : toReload) {
|
||||||
auto scriptEngine = getScriptEngine(scriptName);
|
auto scriptEngine = getScriptEngine(scriptName);
|
||||||
if (scriptEngine && !scriptEngine->isFinished()) {
|
if (scriptEngine && !scriptEngine->isFinished()) {
|
||||||
|
@ -390,6 +397,7 @@ void ScriptEngines::stopAllScripts(bool restart) {
|
||||||
qCDebug(scriptengine) << "stopAllScripts -- emitting scriptsReloading";
|
qCDebug(scriptengine) << "stopAllScripts -- emitting scriptsReloading";
|
||||||
emit scriptsReloading();
|
emit scriptsReloading();
|
||||||
}
|
}
|
||||||
|
_isReloading = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,7 @@ protected:
|
||||||
ScriptsModel _scriptsModel;
|
ScriptsModel _scriptsModel;
|
||||||
ScriptsModelFilter _scriptsModelFilter;
|
ScriptsModelFilter _scriptsModelFilter;
|
||||||
std::atomic<bool> _isStopped { false };
|
std::atomic<bool> _isStopped { false };
|
||||||
|
std::atomic<bool> _isReloading { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
QUrl normalizeScriptURL(const QUrl& rawScriptURL);
|
QUrl normalizeScriptURL(const QUrl& rawScriptURL);
|
||||||
|
|
|
@ -41,7 +41,16 @@ var numStillSnapshotUploadsPending = 0;
|
||||||
|
|
||||||
// It's totally unnecessary to return to C++ to perform many of these requests, such as DELETEing an old story,
|
// It's totally unnecessary to return to C++ to perform many of these requests, such as DELETEing an old story,
|
||||||
// POSTING a new one, PUTTING a new audience, or GETTING story data. It's far more efficient to do all of that within JS
|
// POSTING a new one, PUTTING a new audience, or GETTING story data. It's far more efficient to do all of that within JS
|
||||||
var request = Script.require('request').request;
|
var request;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Due to an issue where if the user spams 'script reload', this call could cause an exception
|
||||||
|
// preventing our scriptEnding to not properly be initialized resulting in the tablet button
|
||||||
|
// duplicating itself where you end up with a bunch of SNAP buttons on your toolbar
|
||||||
|
request = Script.require('request').request;
|
||||||
|
} catch(err) {
|
||||||
|
print('Failed to resolve request api, error: ' + err);
|
||||||
|
}
|
||||||
|
|
||||||
function openLoginWindow() {
|
function openLoginWindow() {
|
||||||
if ((HMD.active && Settings.getValue("hmdTabletBecomesToolbar", false))
|
if ((HMD.active && Settings.getValue("hmdTabletBecomesToolbar", false))
|
||||||
|
@ -750,11 +759,10 @@ Script.scriptEnding.connect(function () {
|
||||||
}
|
}
|
||||||
if (tablet) {
|
if (tablet) {
|
||||||
tablet.removeButton(button);
|
tablet.removeButton(button);
|
||||||
|
tablet.screenChanged.disconnect(onTabletScreenChanged);
|
||||||
}
|
}
|
||||||
Window.snapshotShared.disconnect(snapshotUploaded);
|
Window.snapshotShared.disconnect(snapshotUploaded);
|
||||||
tablet.screenChanged.disconnect(onTabletScreenChanged);
|
|
||||||
Snapshot.snapshotLocationSet.disconnect(snapshotLocationSet);
|
Snapshot.snapshotLocationSet.disconnect(snapshotLocationSet);
|
||||||
|
|
||||||
Entities.canRezChanged.disconnect(processRezPermissionChange);
|
Entities.canRezChanged.disconnect(processRezPermissionChange);
|
||||||
Entities.canRezTmpChanged.disconnect(processRezPermissionChange);
|
Entities.canRezTmpChanged.disconnect(processRezPermissionChange);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue