Bug in TImage::Append in batch mode

Dear all,

The following code works fine if interpreted. It creates two images with the plots properly displayed:

[code] TCanvas* c1 = new TCanvas(“test1”);
TH1F h1(“h1”, “h1”, 100, 0, 99);

TCanvas* c2 = new TCanvas(“test2”);
TH1F h2(“h2”, “h2”, 100, 0, 99);

TImage *image1 = TImage::Create();
TImage *image2 = TImage::Create();
image1->Append(image2, “/”);
image1->WriteImage(“test2.png”, TImage::kPng);
image1->Append(image2, “+”);
image1->WriteImage(“test3.png”, TImage::kPng);[/code]

The exact same code in a “main” and compiled gives a black box when I use Append with option “/”.

To reproduce :

  1. Get the attached cpp file
  2. Compile it : g++ -g -I/opt/root/include -pthread -m64 -fPIC -W -Wall -Wextra -Wconversion -Wdisabled-optimization -Wno-unused -Wall -Wshadow -Wextra -Wredundant-decls -L/opt/root/lib -lGpad -lHist -lGraf -lGraf3d -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lRIO -lNet -lThread -lCore -lCint -lm -ldl ex_appendbug.cpp
  3. Run it : ./a.out
  4. Open test2.png and test3.png, and see the black box instead of upper left histo.

Platform: SLC5 64 bits


ex_appendbug.cpp (1.17 KB)

When you make a standalone program you need a TApplication.
Have a look at $ROOTSYS/test/stressGraphics.cxx to see an example.


Thank you for your reply, but if I use a TApplication, I get windows displayed, won’t I ?

The program is meant to be running on a server by a cron job. I am afraid it will make problems (?).
What do you think ?


Addendum :
The Append works with the option “+” but not the “/”. It makes me think that there is another problem than the missing TApplication.

No, stressGraphics has not windows displayed. See the code and you will understand.

Thank you, I understand now, I have to create a TApplication and use gROOT->SetBatch().

Nevertheless, I experience the same behaviour : Append works with “+” not with “/”.

I attach the example with the TApplication.

ex_appendbug.cpp (1.15 KB)

Your example does not work in interpreted mode (using root) when you run root in batch mode.
I have no idea why …
I never used this Append method before.

Why don’t you simply divide the canvas using Divide() ?

I used to do exactly this : collect several canvases, create a new one, split it, and “drawclonepad” the initial canvases on the subpads. However, I get a memory leak with drawclonepad as reported in this other thread : Memory leak in TCanvas::DrawClonePad

Therefore, I thought I would try a different approach meanwhile we discuss the memory leak. And I found this issue with “Append”. I definitely think that it is a bug but I agree that it might not be the highest priority :slight_smile:

Thank you