Fix UI freeze every 5 s

The settings main page exists from startup inside the closed dialog and
its IP timer always ran: networkInfo() spawns nmcli twice synchronously on
the GUI thread (~200 ms), stalling every animation. Poll only while the
page is visible. Also write the qt.alive heartbeat without QSaveFile's
fsync (bt-update only checks its mtime).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-10 10:58:16 +00:00
co-authored by Claude Opus 5.5
parent f07e153f09
commit 1dc88fabf5
2 changed files with 11 additions and 5 deletions
+6 -1
View File
@@ -42,9 +42,14 @@ Item {
refreshIp() refreshIp()
refreshBrightness() refreshBrightness()
} }
// networkInfo() runs nmcli synchronously on the GUI thread (~200 ms), so
// poll only while this page is on screen. The page exists from startup
// inside the closed settings dialog; an always-running timer froze all
// animations every 5 s.
onVisibleChanged: if (visible) refreshIp()
Timer { Timer {
interval: 5000 interval: 5000
running: true running: page.visible
repeat: true repeat: true
onTriggered: page.refreshIp() onTriggered: page.refreshIp()
} }
+5 -4
View File
@@ -55,12 +55,13 @@ QString SystemInfo::scriptsDir() const
void SystemInfo::writeHeartbeat() void SystemInfo::writeHeartbeat()
{ {
QSaveFile f(runDir() + "/qt.alive"); // Runs on the GUI thread every 5 s. Plain write, no QSaveFile: its
// commit() fsyncs, which on eMMC can stall the UI for a visible moment.
// bt-update only looks at the mtime, so atomicity is not needed.
QFile f(runDir() + "/qt.alive");
if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate)) if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate))
return; return;
QByteArray ts = QByteArray::number(QDateTime::currentSecsSinceEpoch()); f.write(QByteArray::number(QDateTime::currentSecsSinceEpoch()));
f.write(ts);
f.commit();
} }
QString SystemInfo::appVersion() const QString SystemInfo::appVersion() const