viewport: don't clobber the persisted nav preset at startup

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 <noreply@anthropic.com>
This commit is contained in:
Dion Moult
2026-07-09 13:17:55 +10:00
parent 6e86072d5a
commit 93fcdc9a8d
+9 -6
View File
@@ -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;