mirror of
https://github.com/overte-org/overte.git
synced 2025-04-17 06:46:22 +02:00
Fix heap corruption coming out of running scripts dialog
This commit is contained in:
parent
4439de240a
commit
d50c448151
1 changed files with 25 additions and 3 deletions
|
@ -39,10 +39,26 @@ ScrollingWindow {
|
|||
property alias x: root.x
|
||||
property alias y: root.y
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: refreshTimer
|
||||
interval: 100
|
||||
repeat: false
|
||||
running: false
|
||||
onTriggered: updateRunningScripts();
|
||||
}
|
||||
|
||||
Component {
|
||||
id: listModelBuilder
|
||||
ListModel { }
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: ScriptDiscoveryService
|
||||
onScriptCountChanged: updateRunningScripts();
|
||||
onScriptCountChanged: {
|
||||
runningScriptsModel = listModelBuilder.createObject(root);
|
||||
refreshTimer.restart();
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
|
@ -65,10 +81,16 @@ ScrollingWindow {
|
|||
b = simplify(b.path);
|
||||
return a < b ? -1 : a > b ? 1 : 0;
|
||||
});
|
||||
runningScriptsModel.clear()
|
||||
// Calling `runningScriptsModel.clear()` here instead of creating a new object
|
||||
// triggers some kind of weird heap corruption deep inside Qt. So instead of
|
||||
// modifying the model in place, possibly triggering behaviors in the table
|
||||
// instead we create a new `ListModel`, populate it and update the
|
||||
// existing model atomically.
|
||||
var newRunningScriptsModel = listModelBuilder.createObject(root);
|
||||
for (var i = 0; i < runningScripts.length; ++i) {
|
||||
runningScriptsModel.append(runningScripts[i]);
|
||||
newRunningScriptsModel.append(runningScripts[i]);
|
||||
}
|
||||
runningScriptsModel = newRunningScriptsModel;
|
||||
}
|
||||
|
||||
function loadScript(script) {
|
||||
|
|
Loading…
Reference in a new issue