From 93fcdc9a8df494e9258a1ad4d6cd667c74e20cf0 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Thu, 9 Jul 2026 13:17:55 +1000 Subject: [PATCH] viewport: don't clobber the persisted nav preset at startup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit initWgpu() runs on the first exposeEvent, after MainWindow has already applied the nav preset saved in Settings. It then unconditionally re-applied "blender" whenever WGPU_NAV_PRESET was unset, silently overriding the user's saved choice — so the applied navigation didn't match what Settings showed. Only apply the preset from WGPU_NAV_PRESET when that env override is actually set; otherwise leave the current preset (MainWindow's persisted choice, or the blender default). The startup log now reports the effective orbit/pan bindings rather than a hardcoded name. Co-Authored-By: Claude Opus 4.8 --- src/ifcviewer/ViewportWindow.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ifcviewer/ViewportWindow.cpp b/src/ifcviewer/ViewportWindow.cpp index b4e95bf78c..7c3fc394c9 100644 --- a/src/ifcviewer/ViewportWindow.cpp +++ b/src/ifcviewer/ViewportWindow.cpp @@ -774,17 +774,20 @@ bool ViewportWindow::initWgpu() { Log::info() << "[wgpu fly] WGPU_FLY_DEBUG=1 — per-frame [fly] dt log enabled"; } } - const char* nav_env = std::getenv("WGPU_NAV_PRESET"); - applyNavPreset(nav_env ? nav_env : "blender"); + // WGPU_NAV_PRESET is a dev override; apply it here. Otherwise leave the + // preset alone — MainWindow applies the persisted Settings choice before the + // window is exposed (initWgpu runs on the first expose), so forcing a + // default here would clobber it and desync the applied preset from Settings. + if (const char* nav_env = std::getenv("WGPU_NAV_PRESET")) { + applyNavPreset(nav_env); + } Log::info().noquote().nospace() - << "[wgpu nav] preset=" << (nav_env ? nav_env : "blender") - << " (orbit " + << "[wgpu nav] orbit " << (orbit_button_ == Qt::RightButton ? "RMB" : "MMB") << (orbit_mods_ & Qt::ShiftModifier ? "+Shift" : "") << ", pan " << (pan_button_ == Qt::RightButton ? "RMB" : "MMB") - << (pan_mods_ & Qt::ShiftModifier ? "+Shift" : "") - << ")"; + << (pan_mods_ & Qt::ShiftModifier ? "+Shift" : ""); // ---- ViewportCore handles instance/adapter/device/queue/pool/format - if (!core_.initWgpu(web_limits_)) return false;