From c68a1b0708faa550da50c7fcfab08572cd0c045f Mon Sep 17 00:00:00 2001 From: Bertrand Bellenot Date: Fri, 24 Apr 2026 14:23:00 +0200 Subject: [PATCH] [gui] Add missing `FreePicture()` where needed --- gui/gui/src/TGFileBrowser.cxx | 4 +++- gui/gui/src/TGListTree.cxx | 34 ++++++++++++++++++++++------------ test/RootShower/RootShower.cxx | 8 ++++++++ 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/gui/gui/src/TGFileBrowser.cxx b/gui/gui/src/TGFileBrowser.cxx index 8cdd5d6748ba0..c048227c663b1 100644 --- a/gui/gui/src/TGFileBrowser.cxx +++ b/gui/gui/src/TGFileBrowser.cxx @@ -764,8 +764,10 @@ void TGFileBrowser::AddFSDirectory(const char *entry, const char *path, pic = (TGPicture *)gClient->GetPicture("cdrom_t.xpm"); else if (infos.Contains("Network")) pic = (TGPicture *)gClient->GetPicture("netdisk_t.xpm"); - if (pic) + if (pic) { item->SetPictures(pic, pic); + gClient->FreePicture(pic); + } } } diff --git a/gui/gui/src/TGListTree.cxx b/gui/gui/src/TGListTree.cxx index 091331a58f9de..8a187dad730d7 100644 --- a/gui/gui/src/TGListTree.cxx +++ b/gui/gui/src/TGListTree.cxx @@ -221,15 +221,19 @@ Bool_t TGListTreeItemStd::HasUnCheckedChild(Bool_t first) void TGListTreeItemStd::UpdateState() { + const TGPicture *pic1 = nullptr, *pic2 = nullptr; if ((!fChecked && HasCheckedChild(kTRUE)) || (fChecked && HasUnCheckedChild(kTRUE))) { - SetCheckBoxPictures(gClient->GetPicture("checked_dis_t.xpm"), - gClient->GetPicture("unchecked_dis_t.xpm")); + pic1 = gClient->GetPicture("checked_dis_t.xpm"); + pic2 = gClient->GetPicture("unchecked_dis_t.xpm"); } else { - SetCheckBoxPictures(gClient->GetPicture("checked_t.xpm"), - gClient->GetPicture("unchecked_t.xpm")); + pic1 = gClient->GetPicture("checked_t.xpm"); + pic2 = gClient->GetPicture("unchecked_t.xpm"); } + SetCheckBoxPictures(pic1, pic2); + gClient->FreePicture(pic1); + gClient->FreePicture(pic2); } //////////////////////////////////////////////////////////////////////////////// @@ -2744,6 +2748,7 @@ void TGListTree::UpdateChecked(TGListTreeItem *item, Bool_t redraw) { if (fAutoCheckBoxPic == kFALSE) return; + const TGPicture *pic1 = nullptr, *pic2 = nullptr; TGListTreeItem *parent; TGListTreeItem *current; current = item->GetFirstChild(); @@ -2752,27 +2757,32 @@ void TGListTree::UpdateChecked(TGListTreeItem *item, Bool_t redraw) while (parent && parent->HasCheckBox()) { if ((!parent->IsChecked() && parent->HasCheckedChild(kTRUE)) || (parent->IsChecked() && parent->HasUnCheckedChild(kTRUE))) { - parent->SetCheckBoxPictures(fClient->GetPicture("checked_dis_t.xpm"), - fClient->GetPicture("unchecked_dis_t.xpm")); + pic1 = fClient->GetPicture("checked_dis_t.xpm"); + pic2 = fClient->GetPicture("unchecked_dis_t.xpm"); } else { - parent->SetCheckBoxPictures(fClient->GetPicture("checked_t.xpm"), - fClient->GetPicture("unchecked_t.xpm")); + pic1 = fClient->GetPicture("checked_t.xpm"); + pic2 = fClient->GetPicture("unchecked_t.xpm"); } + parent->SetCheckBoxPictures(pic1, pic2); + fClient->FreePicture(pic1); + fClient->FreePicture(pic2); parent = parent->GetParent(); if (parent && fCheckMode == kRecursive) { + pic1 = fClient->GetPicture("checked_t.xpm"); + pic2 = fClient->GetPicture("unchecked_t.xpm"); if (!parent->IsChecked() && parent->GetFirstChild() && !parent->GetFirstChild()->HasUnCheckedChild()) { - parent->SetCheckBoxPictures(fClient->GetPicture("checked_t.xpm"), - fClient->GetPicture("unchecked_t.xpm")); + parent->SetCheckBoxPictures(pic1, pic2); parent->CheckItem(kTRUE); } else if (parent->IsChecked() && parent->GetFirstChild() && !parent->GetFirstChild()->HasCheckedChild()) { - parent->SetCheckBoxPictures(fClient->GetPicture("checked_t.xpm"), - fClient->GetPicture("unchecked_t.xpm")); + parent->SetCheckBoxPictures(pic1, pic2); parent->CheckItem(kFALSE); } + fClient->FreePicture(pic1); + fClient->FreePicture(pic2); } } if (redraw) { diff --git a/test/RootShower/RootShower.cxx b/test/RootShower/RootShower.cxx index 239a098ddd9a6..96dc07ff93397 100644 --- a/test/RootShower/RootShower.cxx +++ b/test/RootShower/RootShower.cxx @@ -1051,11 +1051,15 @@ void RootShower::OnShowerProduce() lpic = gClient->GetPicture("leaf_t.xpm"); lspic = gClient->GetPicture("leaf_t.xpm"); gLTI[i]->SetPictures(lpic, lspic); + gClient->FreePicture(lpic); + gClient->FreePicture(lspic); } else { bpic = gClient->GetPicture("branch_t.xpm"); bspic = gClient->GetPicture("branch_t.xpm"); gLTI[i]->SetPictures(bpic, bspic); + gClient->FreePicture(bpic); + gClient->FreePicture(bspic); } // Show only charged and massive particles... if ((fEvent->GetParticle(i)->GetPdgCode() != PHOTON) && @@ -1204,11 +1208,15 @@ void RootShower::OnOpenFile(const Char_t *filename) lpic = gClient->GetPicture("leaf_t.xpm"); lspic = gClient->GetPicture("leaf_t.xpm"); gLTI[i]->SetPictures(lpic, lspic); + gClient->FreePicture(lpic); + gClient->FreePicture(lspic); } else { bpic = gClient->GetPicture("branch_t.xpm"); bspic = gClient->GetPicture("branch_t.xpm"); gLTI[i]->SetPictures(bpic, bspic); + gClient->FreePicture(bpic); + gClient->FreePicture(bspic); } if ((fEvent->GetParticle(i)->GetPdgCode() != PHOTON) &&