From 45a826f66a9d85e55cd63577a4ad34dc320bf071 Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Wed, 9 Sep 2026 13:15:07 +0200 Subject: [PATCH 1/2] [rootcanvas] select canvas window before close Before it was hapenning in TCanvas::Close() but we removing gVirtualX from there. Therefore do it explicitely already in TRootCanvas::Close() --- gui/gui/src/TRootCanvas.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gui/gui/src/TRootCanvas.cxx b/gui/gui/src/TRootCanvas.cxx index 4f04f830db9c7..cfbe44023c694 100644 --- a/gui/gui/src/TRootCanvas.cxx +++ b/gui/gui/src/TRootCanvas.cxx @@ -726,7 +726,11 @@ void TRootCanvas::Close() else gged->Hide(); } - gVirtualX->CloseWindow(); + if (fCanvasID != -1) { + gVirtualX->SelectWindow(fCanvasID); + gVirtualX->CloseWindow(); + fCanvasID = -1; + } } //////////////////////////////////////////////////////////////////////////////// From c0ad54ec080b7ee7df28fb24487b0e58e9b98754 Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Wed, 9 Sep 2026 13:21:40 +0200 Subject: [PATCH 2/2] [gpad] do not select canvas before deleting Now it happens in the canvas implementation and therefore not necessary. --- graf2d/gpad/src/TCanvas.cxx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/graf2d/gpad/src/TCanvas.cxx b/graf2d/gpad/src/TCanvas.cxx index 2082e7d4a392c..762ea448e751a 100644 --- a/graf2d/gpad/src/TCanvas.cxx +++ b/graf2d/gpad/src/TCanvas.cxx @@ -804,10 +804,6 @@ void TCanvas::Close(Option_t *option) TPad::Close(option); if (!IsBatch() && !IsWeb()) { - //select current canvas - if (fPainter) - fPainter->SelectDrawable(fCanvasID); - DeleteCanvasPainter(); if (fCanvasImp)