Skip to content

Commit 6bd7830

Browse files
committed
[gui] Simplify ROOTSYS handling in TGFSComboBox
In `TGFSComboBox.cxx`, the logic to figure out ROOTSYS is duplicating what is already done in TROOT. We can just use `gROOT->GetRootSys()` to reuse that logic.
1 parent a58f11a commit 6bd7830

1 file changed

Lines changed: 2 additions & 29 deletions

File tree

gui/gui/src/TGFSComboBox.cxx

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ It will allow the file path selection.
3535
#include "TGFSComboBox.h"
3636
#include "TGResourcePool.h"
3737
#include "TGPicture.h"
38+
#include "TROOT.h"
3839
#include "TSystem.h"
3940
#include "TVirtualX.h"
4041
#include "strlcpy.h"
@@ -210,11 +211,6 @@ TGFSComboBox::TGFSComboBox(const TGWindow *parent, Int_t id, UInt_t options,
210211
//--- first check for the existence of some directories...
211212

212213
const char *homeDir = gSystem->HomeDirectory();
213-
#ifndef ROOTPREFIX
214-
const char *rootSys = gSystem->Getenv("ROOTSYS");
215-
#else
216-
// const char *rootSys = ROOTPREFIX;
217-
#endif
218214

219215
TList *volumes = gSystem->GetVolumes("all");
220216
TList *curvol = gSystem->GetVolumes("cur");
@@ -243,11 +239,7 @@ TGFSComboBox::TGFSComboBox(const TGWindow *parent, Int_t id, UInt_t options,
243239
fLbc.emplace_back("CD-ROM", "/cdrom", "cdrom_t.xpm", 1);
244240
}
245241
fLbc.emplace_back("Home", "$HOME", "home_t.xpm", 1);
246-
#ifndef ROOTPREFIX
247-
fLbc.emplace_back("RootSys", "$ROOTSYS", "root_t.xpm", 1);
248-
#else
249-
fLbc.emplace_back(ROOTPREFIX, ROOTPREFIX, "root_t.xpm", 1);
250-
#endif
242+
fLbc.emplace_back("RootSys", gROOT->GetRootSys(), "root_t.xpm", 1);
251243

252244
if (volumes && curvol) {
253245
TIter next(volumes);
@@ -285,25 +277,6 @@ TGFSComboBox::TGFSComboBox(const TGWindow *parent, Int_t id, UInt_t options,
285277
entry.fFlags = 0;
286278
}
287279
}
288-
#ifndef ROOTPREFIX
289-
// Below should _only_ be called if the prefix isn't set at build
290-
// time. The code below expands the occurance of `$ROOTSYS' in
291-
// the table above. However, in the case of prefix being set at
292-
// build time, we do not need to expand the prefix, as it is
293-
// already known, so the entries in the table above are actually
294-
// fully expanded.
295-
if (entry.fPath.find("$ROOTSYS") == 0) {
296-
// Get the size of the prefix template
297-
const int plen = 8;
298-
if (rootSys) {
299-
std::string newpath = rootSys;
300-
newpath.append(entry.fPath.substr(plen));
301-
entry.fPath = newpath;
302-
} else {
303-
entry.fFlags = 0;
304-
}
305-
}
306-
#endif
307280
if (gSystem->AccessPathName(entry.fPath.c_str(), kFileExists) == 0)
308281
entry.fFlags = 1;
309282
}

0 commit comments

Comments
 (0)