mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-19 03:56:26 +02:00
[ui] TextFileViewer: wait for request completion before sending a new one
On auto-realod mode, only trigger a new request when the last one has been completed. Avoids requests loops on slow filesystems that can lead to UI freezes.
This commit is contained in:
parent
88b0297660
commit
52361d0b86
1 changed files with 6 additions and 3 deletions
|
@ -22,6 +22,7 @@ Item {
|
|||
property bool loading: false
|
||||
|
||||
onSourceChanged: loadSource()
|
||||
onAutoReloadChanged: loadSource()
|
||||
onVisibleChanged: if(visible) loadSource()
|
||||
|
||||
RowLayout {
|
||||
|
@ -307,11 +308,10 @@ Item {
|
|||
|
||||
// Auto-reload current file timer
|
||||
Timer {
|
||||
id: reloadTimer
|
||||
running: root.autoReload
|
||||
interval: root.autoReloadInterval
|
||||
repeat: true
|
||||
// reload file on start and stop
|
||||
onRunningChanged: loadSource()
|
||||
repeat: false // timer is restarted in request's callback (see loadSource)
|
||||
onTriggered: loadSource()
|
||||
}
|
||||
|
||||
|
@ -333,6 +333,9 @@ Item {
|
|||
if(xhr.readyState === XMLHttpRequest.DONE) {
|
||||
textView.setText(xhr.status === 200 ? xhr.responseText : "");
|
||||
loading = false;
|
||||
// re-trigger reload source file
|
||||
if(autoReload)
|
||||
reloadTimer.restart();
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue