I am developing a program based on a TApplication. I just switched to macos, and I get a crash when closing the main window. Actually, if I open only the main window, I can close it without error, but if I open the main window, then click on a button to open a second window, then close this second window and finally close the main window, ROOT crash with this error message:
2020-01-13 17:11:30.581285+0100 Cubix[63028:750117] Fatal error: requested non-existing drawable 1169
2020-01-13 17:11:30.581368+0100 Cubix[63028:750117] This window not found among allocated/deleted drawables
Using a debugger, I found that this is coming from the line:
From what I found on the web, it seems to be related to cocoa. I tried to install root using the option -Dx11=ON -Dcocoa=OFF, but I have the following error, that I did not succeed to correct:
In file included from /Users/dudouet/Softs/ROOT/root/graf3d/glew/src/glew.c:49:
include/GL/glxew.h:94:10: fatal error: 'X11/Xlib.h' file not found
#include <X11/Xlib.h>
So, by trying to create a piece of code that could reproduce the problem, I found a solution. The second window that I am opening contains an object of class CXCanvas, inherited from TCanvas. To use it I was doing:
fRootCanvas = new TRootEmbeddedCanvas("NCCanvas", Main);
Main->AddFrame(fRootCanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 5, 5));
Int_t canvasid = fRootCanvas->GetCanvasWindowId();
fCanvas = new CXCanvas("NuclearChartCanvas", 10, 10,canvasid);
fCanvas->SetMainWindow(fMainWindow);
fRootCanvas->AdoptCanvas(fCanvas);
This is actually the part that made all crashed. To avoid the crash when exiting ROOT, I had to add: