(I’m using Root 5.26 on Windows.)
I’m having a crash when I try to Update() a specific canvas that I have loaded via TFile->Get(). (The file was created by canvas->SaveAs();).
The problem seems due to having a custom palette when I created the histogram in this canvas.
I need custom palettes for my different histograms, and used a technique I found in this forum to create the different palettes, using TExec:
tStr1.Form(“gStyle->SetPalette(%d, (Int_t*)0x%x);”, 10, pkr_palette);
fE_palette_pkr = new TExec(“fE_palette_pkr”, tStr1 );
When the histogram is created, to get my custom palette, I call:
th2d->Draw(“SURF1 Z SAME”);
then I save the canvas with: Canvas->SaveAs(Namestr.Data());
In a different program, I open the root file that I saved the canvas into, get the canvas, attach it to an embeddedcanvas, and update it:
tfile1 = new TFile(tStr3);
When the Update() occurs, there is a crash in
TColor::SetPalette(Int_t ncolors, Int_t *colors)
because colors is the address of the color table when the histogram and canvas were created.
Is there some way to save the original custom palette with the canvas?
Or do I have to re-create the custom palette and use it before I call Update()?
(which would be a problem, because the program that loads and displays the canvas doesn’t have the information that the original custom palette was created from)
I’m not including an actual working (failing) example of this because the code is quite large. But if it’s needed, I will try to make a small running example.