Files
musrfit/src
suter_aandClaude Opus 5 9d1b6eac30 musrview: fix the segfault of the interactive "Save graphics"
RenderGraphics() flips gROOT's batch flag so that the export TCanvas is
built headless. That is enough for TCanvas to take its batch branch, but
not enough to make the session batch: an interactive musrview is a
non-batch ROOT session, hence TApplication has loaded the X11 graphics
and gVirtualX points at TGX11.

A batch TCanvas never obtains a drawable - its fPixmapID stays -1 - yet
TCanvas::Build() unconditionally paints the canvas background through
SelectDrawable(fPixmapID)/PaintBorder(). With the batch gVirtualX that is
a no-op, with TGX11 it selects window -1 and TGX11::DrawBoxW() segfaults.
Saving from the musrview window therefore crashed every time, while the
--png/--pdf/... batch export was never affected (there gVirtualX already
is the batch one).

Put the graphics interface into the same state a genuine batch session
has by pointing gVirtualX at ROOT's gGXBatch for the duration of the
export. Batch flag and gVirtualX are now handled by one RAII guard, which
also replaces the three hand-written restore points, and which is
declared before the canvas so that it outlives it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LVGQWoKNXByP2PSmMgPz3i
2026-09-18 16:39:25 +02:00
..
2026-01-25 07:45:44 +01:00
2026-09-11 14:49:04 +02:00