Skip to content

Commit 1e4bcdf

Browse files
ferdymercuryguitargeek
authored andcommitted
[asimage] more robust handling of batch option
1 parent b6e1ee4 commit 1e4bcdf

1 file changed

Lines changed: 15 additions & 32 deletions

File tree

graf2d/asimage/src/TASImage.cxx

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2226,54 +2226,37 @@ void TASImage::GetZoomPosition(UInt_t &x, UInt_t &y, UInt_t &w, UInt_t &h) const
22262226

22272227
Bool_t TASImage::InitVisual()
22282228
{
2229-
Bool_t inbatch = fgVisual && fgBatch; // was in batch
2230-
Bool_t noX = gROOT->IsBatch() || gVirtualX->InheritsFrom("TGWin32");
2229+
Bool_t noX = gROOT->IsBatch() || !gVirtualX->InheritsFrom("TGX11");
22312230

2232-
// was in batch, but switched to gui
2233-
if (inbatch && !noX) {
2234-
destroy_asvisual(fgVisual, kFALSE);
2235-
fgVisual = nullptr;
2236-
fgBatch = false;
2237-
}
2238-
2239-
if (fgVisual && (fgVisual->dpy || fgBatch)) { // already initialized
2231+
if (fgVisual && (noX == fgBatch))
22402232
return kTRUE;
2241-
}
22422233

2243-
// batch or win32 mode
2244-
if (!fgVisual && noX) {
2245-
fgVisual = create_asvisual(nullptr, 0, 0, nullptr);
2246-
fgVisual->dpy = nullptr; // fake (not used)
2247-
fgBatch = true;
2248-
return kTRUE;
2249-
}
2234+
if (fgVisual)
2235+
destroy_asvisual(fgVisual, kFALSE);
2236+
fgVisual = nullptr;
2237+
fgBatch = false;
22502238

22512239
#ifndef WIN32
2252-
#ifdef R__HAS_COCOA
2253-
fgVisual = create_asvisual(nullptr, 0, 0, nullptr);
2254-
fgVisual->dpy = nullptr; // fake (not used)
2255-
fgBatch = true;
2256-
#else
2240+
#ifndef R__HAS_COCOA
22572241
Display *disp = (Display*) gVirtualX->GetDisplay();
22582242
Int_t screen = gVirtualX->GetScreen();
22592243
Int_t depth = gVirtualX->GetDepth();
22602244
Visual *vis = (Visual*) gVirtualX->GetVisual();
22612245
Colormap cmap = (Colormap) gVirtualX->GetColormap();
22622246

2263-
if (!vis || cmap == 0) {
2264-
destroy_asvisual(fgVisual, kFALSE);
2265-
fgVisual = create_asvisual(nullptr, 0, 0, nullptr);
2266-
} else {
2247+
if (vis && cmap)
22672248
fgVisual = create_asvisual_for_id(disp, screen, depth,
22682249
XVisualIDFromVisual(vis), cmap, nullptr);
2269-
}
22702250
#endif
2271-
#else
2272-
fgVisual = create_asvisual(nullptr, 0, 0, nullptr);
2273-
fgVisual->dpy = nullptr; // fake (not used)
2274-
fgBatch = true;
22752251
#endif
22762252

2253+
if (!fgVisual) {
2254+
// create dummy fgVisual for batch mode
2255+
fgVisual = create_asvisual(nullptr, 0, 0, nullptr);
2256+
fgVisual->dpy = nullptr; // fake (not used)
2257+
fgBatch = true;
2258+
}
2259+
22772260
return kTRUE;
22782261
}
22792262

0 commit comments

Comments
 (0)