Dear Rooters!
We have a GUI application which uses 2 TCanvas. These canvases are periodically updated during an event loop. The problem is that a user can close the TCanvas during the loop progress. So we need to determine TCanvas state during our update.
First we found out, that if a User closes TCanvas, the object is still exists so we cannot use: if(!fCanvas)…
And we haven’t found how to check TCanvas state.
We have tried to implement some GetMainCanvas() function that should get properly created canvas:
void SlotMainCanvasClosed()
{
// main canvas closed
kMainCanvasValid = false;
}[/code]
But when a user closes TCanvas (window) , SlotMainCanvasClosed() doesn’t called so kMainCanvasValid is always true. We have thoroughly checked this slot behavior .
Where is the problem or how to solve the problem with TCanvas state tracking?
P.S. We have thought about checking a list of canvases but do not want to iterate through the list each time we need to update TCanvas
P.P.S We use ROOT 5.20 version
[quote=“bellenot”]Weird… does your MyMainFrame class inherits from TGMainFrame? Do you generate dictionary for it? (you have to if you want to use signal-slot)
Bertrand.[/quote]
Yes, I generate a dictionary for it. Also I use signal slots (for example for buttons etc.) in the class and it works in all other cases except closing Canvases. The class does not inherits from TGMainFrame, it inherits from TQObject and uses TGMainFrame as a field.
Ehmm… First of all there is no such member like GetCanvasImpl(). Second of all even if it was if the canvas has been closed the memory is freed (I suppose) and your code would produce a segmentation violation.