From 324dbec95db62a29f7540dab35cecfee07cc5074 Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Wed, 29 Oct 2025 14:27:35 +0100 Subject: [PATCH 1/3] Fix TGraph painter for rx/ry options If both options are specified, X painting can be corrupted. While gPad->Update called after reverse X axis was painted - removing everything again. Now call gPad->Update() inside PaintGraphReverse before actual reverse axes are painted. --- hist/histpainter/src/TGraphPainter.cxx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/hist/histpainter/src/TGraphPainter.cxx b/hist/histpainter/src/TGraphPainter.cxx index eb51453dd2bb6..bc3e33322a873 100644 --- a/hist/histpainter/src/TGraphPainter.cxx +++ b/hist/histpainter/src/TGraphPainter.cxx @@ -4207,15 +4207,22 @@ void TGraphPainter::PaintGraphReverse(TGraph *theGraph, Option_t *option) Int_t i; // loop index + // if axis drawn update painting once before continue + // otherwise X axis will disappear when Y axis makes own update + if (axis && (lrx || lry)) { + if (lrx) { + theHist->GetXaxis()->SetTickLength(0.); + theHist->GetXaxis()->SetLabelOffset(999.); + } + gPad->Update(); + } + // Reserve the TGraph along the X axis if (lrx) { opt.ReplaceAll("rx", ""); if (axis) { // Reverse the X axis Double_t GL = 0.; - theHist->GetXaxis()->SetTickLength(0.); - theHist->GetXaxis()->SetLabelOffset(999.); - gPad->Update(); TString optax = "-SDH"; if (gPad->GetGridx()) { if (gPad->GetLogy()) { @@ -4283,7 +4290,6 @@ void TGraphPainter::PaintGraphReverse(TGraph *theGraph, Option_t *option) if (axis) { // Reverse the Y axis Double_t GL = 0.; - gPad->Update(); TString optax = "-SDH"; if (gPad->GetGridy()) { if (gPad->GetLogx()) { From 561f78ef524c8dc8f03983cc66322cf197c1a598 Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Wed, 29 Oct 2025 14:39:30 +0100 Subject: [PATCH 2/3] Fix memory leak in TGraphPainter::PaintGraphReverse Delete temporary TGraph and TGaxis objects used only for painting. These objects do not appears in canvas list of primitives, therfore cannot be cleaned up --- hist/histpainter/src/TGraphPainter.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hist/histpainter/src/TGraphPainter.cxx b/hist/histpainter/src/TGraphPainter.cxx index bc3e33322a873..fdfee34bc3f01 100644 --- a/hist/histpainter/src/TGraphPainter.cxx +++ b/hist/histpainter/src/TGraphPainter.cxx @@ -4265,6 +4265,7 @@ void TGraphPainter::PaintGraphReverse(TGraph *theGraph, Option_t *option) theReversedXaxis->SetLabelColor(theGraph->GetXaxis()->GetLabelColor()); theReversedXaxis->SetTickLength(TLX); theReversedXaxis->Paint(); + delete theReversedXaxis; } // Reverse X coordinates @@ -4331,6 +4332,7 @@ void TGraphPainter::PaintGraphReverse(TGraph *theGraph, Option_t *option) theReversedYaxis->SetTickLength(-TLY); theReversedYaxis->SetLabelOffset(LOY-TLY); theReversedYaxis->Paint(); + delete theReversedYaxis; } // Reverse Y coordinates @@ -4361,6 +4363,8 @@ void TGraphPainter::PaintGraphReverse(TGraph *theGraph, Option_t *option) PaintHelper(theReversedGraph,opt.Data()); + delete theReversedGraph; + theHist->GetXaxis()->SetLabelOffset(LOX); theHist->GetXaxis()->SetTickLength(TLX); theHist->GetYaxis()->SetLabelOffset(LOY); From de83449464baf057fbdf8977e06e81d78ba635d6 Mon Sep 17 00:00:00 2001 From: Sergey Linev Date: Thu, 30 Oct 2025 08:16:47 +0100 Subject: [PATCH 3/3] Fix Y axis in PaintGraphReverse Visisble Y range configured in the fMinimum/fMaximum values of histogram and not in the axis properties. Extra handling unzoom action when fMinimum == fMaximum == 0. More important - remove unnecessary gPad->Update() to prevent unpredictable results during painting. Resolves error with new stressGraphics tests --- hist/histpainter/src/TGraphPainter.cxx | 32 +++++++++++++++----------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/hist/histpainter/src/TGraphPainter.cxx b/hist/histpainter/src/TGraphPainter.cxx index fdfee34bc3f01..e12da9fe59652 100644 --- a/hist/histpainter/src/TGraphPainter.cxx +++ b/hist/histpainter/src/TGraphPainter.cxx @@ -4150,6 +4150,13 @@ void TGraphPainter::PaintGraphReverse(TGraph *theGraph, Option_t *option) theHist->GetYaxis()->SetLabelOffset(999.); theHist->GetYaxis()->SetAxisColor(gPad->GetFrameFillColor()); } + + // after Unzoom menu command min/max can be 0 and should be reset + if ((theHist->GetMinimum() == theHist->GetMaximum()) && (theHist->GetMinimum() != -1111)) { + theHist->SetMinimum(theGraph->GetYaxis()->GetXmin()); + theHist->SetMaximum(theGraph->GetYaxis()->GetXmax()); + } + TString opth = "0"; if (lxp) opth.Append("x+"); if (lyp) opth.Append("y+"); @@ -4207,16 +4214,6 @@ void TGraphPainter::PaintGraphReverse(TGraph *theGraph, Option_t *option) Int_t i; // loop index - // if axis drawn update painting once before continue - // otherwise X axis will disappear when Y axis makes own update - if (axis && (lrx || lry)) { - if (lrx) { - theHist->GetXaxis()->SetTickLength(0.); - theHist->GetXaxis()->SetLabelOffset(999.); - } - gPad->Update(); - } - // Reserve the TGraph along the X axis if (lrx) { opt.ReplaceAll("rx", ""); @@ -4305,14 +4302,21 @@ void TGraphPainter::PaintGraphReverse(TGraph *theGraph, Option_t *option) else xpos = gPad->GetUxmin(); if (gPad->GetLogx()) xpos = TMath::Power(10,xpos); TGaxis *theReversedYaxis; + Double_t ymin = theHist->GetMinimum(); + Double_t ymax = theHist->GetMaximum(); + if (ymin == ymax) { + ymin = theGraph->GetYaxis()->GetXmin(); + ymax = theGraph->GetYaxis()->GetXmax(); + } + if (gPad->GetLogy()) { optax.Append("G"); theReversedYaxis = new TGaxis(xpos, TMath::Power(10,gPad->GetUymax()), xpos, TMath::Power(10,gPad->GetUymin()), - theGraph->GetYaxis()->GetXmin(), - theGraph->GetYaxis()->GetXmax(), + ymin, + ymax, theHist->GetNdivisions("Y"), optax.Data(), GL); if (theHist->GetYaxis()->GetMoreLogLabels()) theReversedYaxis->SetMoreLogLabels(); @@ -4321,8 +4325,8 @@ void TGraphPainter::PaintGraphReverse(TGraph *theGraph, Option_t *option) gPad->GetUymax(), xpos, gPad->GetUymin(), - theGraph->GetYaxis()->GetXmin(), - theGraph->GetYaxis()->GetXmax(), + ymin, + ymax, theHist->GetNdivisions("Y"), optax.Data(), GL); }