Skip to content

Commit 6827f40

Browse files
committed
Let return dummy TGPicture in batch mode
In batch real pixmap manipulation is not possible. But all instances of TGPicture are created. In normal mode they are "hidden", but in batch one can return pointer on the picture to suppress many errors printout in the TG.. classes By the way - by the first call of `TGPicturePool::GetPicture()` also dummy ` TGPicture` is returned
1 parent 31591c8 commit 6827f40

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

gui/gui/src/TGPicture.cxx

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,42 +94,36 @@ const TGPicture *TGPicturePool::GetPicture(const char *name)
9494

9595
TGPicture *pic = (TGPicture *)fPicList->FindObject(pname);
9696
if (pic && !pic->IsScaled()) {
97-
if (pic->fPic == kNone)
98-
return 0;
97+
// in batch mode allow to return dummy image
98+
if ((pic->fPic == kNone) && !gROOT->IsBatch())
99+
return nullptr;
99100
pic->AddReference();
100101
return pic;
101102
}
102103

103104
char *picnam = gSystem->Which(fPath, pname, kReadPermission);
104-
if (!picnam) {
105-
pic = new TGPicture(pname);
106-
pic->fAttributes.fColormap = fClient->GetDefaultColormap();
107-
pic->fAttributes.fCloseness = 40000; // Allow for "similar" colors
108-
pic->fAttributes.fMask = kPASize | kPAColormap | kPACloseness;
109-
fPicList->Add(pic);
110-
return 0;
111-
}
112105

113-
TImage *img = TImage::Open(picnam);
106+
TImage *img = picnam ? TImage::Open(picnam) : nullptr;
107+
108+
delete [] picnam;
109+
114110
if (!img) {
115111
pic = new TGPicture(pname);
116112
pic->fAttributes.fColormap = fClient->GetDefaultColormap();
117113
pic->fAttributes.fCloseness = 40000; // Allow for "similar" colors
118114
pic->fAttributes.fMask = kPASize | kPAColormap | kPACloseness;
119115
fPicList->Add(pic);
120-
delete [] picnam;
121-
return 0;
116+
return nullptr;
122117
}
123118

124119
pic = new TGPicture(pname, img->GetPixmap(), img->GetMask());
125-
delete [] picnam;
126120
delete img;
127121
fPicList->Add(pic);
128122
return pic;
129123
}
130124

131125
////////////////////////////////////////////////////////////////////////////////
132-
/// Like TGPicturePool::GetPicture() but, instead of returning null when the
126+
/// Like TGPicturePool::GetPicture() but, instead of returning null when the
133127
/// picture is not found, it returns a valid empty picture.
134128

135129
const TGPicture *TGPicturePool::GetPictureOrEmpty(const char *name)

0 commit comments

Comments
 (0)