Skip to content

Commit 45f0530

Browse files
gui: guard Gui API against null main_window in headless/web mode
In -web/headless mode the static main_window is null while Gui::enabled() is true (the web HeadlessViewer is installed). Public Gui methods dereferenced main_window unconditionally, so any call reaching them from the web render thread or from a module's debug-graphics renderer crashed (issue #10576, e.g. HeatMapRenderer::drawObjects -> Renderer::checkDisplayControl -> Gui::checkDisplayControlsVisible). - Add an early `if (!hasUI())` guard to the affected Gui methods: no-op for void methods, safe default (0/""/false/empty static) otherwise. - Route the display-control accessors to the HeadlessViewer when the Qt widget is absent; extend HeadlessViewer with default-safe virtuals. - Replace the false-positive `enabled()` guards (true in web) with `hasUI()` in saveImage/saveClockTreeImage/saveHistogramImage/ showWorstTimingPath/clearTimingPath/selectClockviewerClock/selectHelp/ selectChart/gifStart/setLogger. - Guard the static findWidget() helper at its root. The guards only fire when main_window is null, so interactive -gui behavior is unchanged. Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
1 parent 4c26918 commit 45f0530

2 files changed

Lines changed: 239 additions & 14 deletions

File tree

src/gui/include/gui/gui.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,24 @@ class HeadlessViewer
741741
// True while pause() is blocking. Consumers (like the web tile renderer)
742742
// can use this to gate unsafe cross-thread reads of renderer state.
743743
virtual bool isPaused() const = 0;
744+
745+
// Display-control accessors consulted by Gui::*DisplayControls* when the Qt
746+
// GUI (and its DisplayControls widget) is absent. Default implementations
747+
// assume "everything visible, nothing selectable" so headless renderers draw
748+
// by default without a Qt widget. Viewers that track their own visibility
749+
// model (e.g. the web viewer) may override these.
750+
virtual bool checkDisplayControlVisible(const std::string& name)
751+
{
752+
return true;
753+
}
754+
virtual bool checkDisplayControlSelectable(const std::string& name)
755+
{
756+
return false;
757+
}
758+
virtual void setDisplayControlVisible(const std::string& name, bool value) {}
759+
virtual void setDisplayControlSelectable(const std::string& name, bool value)
760+
{
761+
}
744762
};
745763

746764
// This is the API for the rest of the program to interact with the

0 commit comments

Comments
 (0)