Adding embedded canvas causes RootX11ErroHandler BadDrawable

I have attached some code that I am having difficulty with. By and large I think I’ve followed the rules correctly.

This code is a class called OScope and will create a main frame and attach at the moment one single panel. I’m trying to fashion it so I can create multiple traces in seperate panels.

The main frame is set up, and then constructs a OScopePanel class. Inside the OScopePanel class a TRootEmbeddedCanvas is created in which I draw a TGraph on.

The problem occurs on exit. Experimentation leads me to believe that the problem is caused when the TRootEmbeddedCanvas is added. When the class is destroyed I get the error:

Error in : BadDrawable (invalid Pixmap or Window parameter) (XID: 37749026, XREQ: 62)

Which I take to be destroying the pixmap twice. I’m not sure how to prevent this so I turn to the experts, Thanks in advance.

To run the code do:

.L scope.cpp
OScope *os = new OScope(gClient->GetRoot(), 600, 800);

Then use the file menu/exit to close it out.

Chris
scope.h (4.61 KB)
scope.cpp (17.6 KB)

I’ve reduced the problem even further. I just create a TGMainFrame and add a TRootEmbededCanvas and I get the problem when I close the window.

Note: that I do a delete on the parent class. Ultimately, I want to make sure I get rid of all the extra baggage in the class.
scope.cpp (7.86 KB)

Hi Clirakis,

I suffered the same error, which is solved by adding
two statements shown in example.c of the ROOT user guide page-362.

You can “exit” by the following CloseWindow():

void OScope::CloseWindow()
{
printf(“CLOSE WINDOW!\n”);

fTop->Cleanup(); delete fTop ; // Yuki Adds :smiley: 

delete this;

}

Thanks,

Yuki