Skip to content

Commit

Permalink
Fix seldom crash in TPad::ShowGuidelines
Browse files Browse the repository at this point in the history
In some cases gPad can be set to tmpGuideLinePad, which is deleted
any time ShowGuidelines method is called. In that case pointer on
this temporary pad should be removed from TContext object
  • Loading branch information
linev committed May 8, 2023
1 parent 6a220a3 commit a25c523
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions graf2d/gpad/src/TPad.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -6240,15 +6240,16 @@ void TPad::ShowGuidelines(TObject *object, const Int_t event, const char mode, c
if (mode != 'i') resize = true;

TPad *is_pad = dynamic_cast<TPad *>( object );
TVirtualPad *padSave = 0;
padSave = gPad;
TVirtualPad *padSave = gPad;
if (is_pad)
if (is_pad->GetMother()) is_pad->GetMother()->cd();

static TPad * tmpGuideLinePad;
static TPad *tmpGuideLinePad = 0;

//delete all existing Guidelines and create new invisible pad
if (tmpGuideLinePad) {
if (padSave == tmpGuideLinePad)
padSave = 0;
if (object == tmpGuideLinePad) { // in case of funny button click combination.
tmpGuideLinePad->Delete();
tmpGuideLinePad = 0;
Expand Down Expand Up @@ -6502,7 +6503,7 @@ void TPad::ShowGuidelines(TObject *object, const Int_t event, const char mode, c
}

gPad->Modified(kTRUE);
padSave->cd();
if (padSave) padSave->cd();
}

////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit a25c523

Please sign in to comment.