Skip to content

Commit 06e4054

Browse files
committed
Fix leak in stressGraphics TImage test
Loaded image was not deleted. Instead loading same image multiple times - clone it Use tutorials dir
1 parent 892bd0c commit 06e4054

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

test/stressGraphics.cxx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3640,28 +3640,30 @@ void timage()
36403640
{
36413641
TCanvas *C = StartTest(800,800);
36423642

3643-
TImage *img = TImage::Open("$(ROOTSYS)/tutorials/visualisation/image/rose512.jpg");
3643+
TString fname = gROOT->GetTutorialDir();
3644+
fname.Append("/visualisation/image/rose512.jpg");
3645+
TImage *img = TImage::Open(fname);
36443646
if (!img) {
36453647
printf("Could not create an image... exit\n");
36463648
return;
36473649
}
3648-
TImage *i1 = TImage::Open("$(ROOTSYS)/tutorials/visualisation/image/rose512.jpg");
3650+
auto i1 = (TImage *) img->Clone();
36493651
i1->SetConstRatio(kFALSE);
36503652
i1->Flip(90);
3651-
TImage *i2 = TImage::Open("$(ROOTSYS)/tutorials/visualisation/image/rose512.jpg");
3653+
auto i2 = (TImage *) img->Clone();
36523654
i2->SetConstRatio(kFALSE);
36533655
i2->Flip(180);
3654-
TImage *i3 = TImage::Open("$(ROOTSYS)/tutorials/visualisation/image/rose512.jpg");
3656+
auto i3 = (TImage *) img->Clone();
36553657
i3->SetConstRatio(kFALSE);
36563658
i3->Flip(270);
3657-
TImage *i4 = TImage::Open("$(ROOTSYS)/tutorials/visualisation/image/rose512.jpg");
3658-
i4->SetConstRatio(kFALSE);
3659-
i4->Mirror(kTRUE);
3659+
3660+
img->SetConstRatio(kFALSE);
3661+
img->Mirror(kTRUE);
36603662
float d = 0.40;
36613663
TPad *p1 = new TPad("i1", "i1", 0.05, 0.55, 0.05+d*i1->GetWidth()/i1->GetHeight(), 0.95);
36623664
TPad *p2 = new TPad("i2", "i2", 0.55, 0.55, 0.95, 0.55+d*i2->GetHeight()/i2->GetWidth());
36633665
TPad *p3 = new TPad("i3", "i3", 0.55, 0.05, 0.55+d*i3->GetWidth()/i3->GetHeight(), 0.45);
3664-
TPad *p4 = new TPad("i4", "i4", 0.05, 0.05, 0.45, 0.05+d*i4->GetHeight()/i4->GetWidth());
3666+
TPad *p4 = new TPad("i4", "i4", 0.05, 0.05, 0.45, 0.05+d*img->GetHeight()/img->GetWidth());
36653667
p1->Draw();
36663668
p1->cd();
36673669
i1->Draw();
@@ -3676,7 +3678,7 @@ void timage()
36763678
C->cd();
36773679
p4->Draw();
36783680
p4->cd();
3679-
i4->Draw();
3681+
img->Draw();
36803682
C->cd();
36813683

36823684
TestReport(C, "timage", "TImage");

0 commit comments

Comments
 (0)