TCanvas::Emit("Closed") executed twice?

Hi rooters,
seems to me that TCanvas::Emit(“Closed”)
is called twice. (root 6.12.04 and earlier)
Attached a little macro:
.L mycanvas.C+
MyCanvas *mc = new MyCanvas()
then close canvas with WM cross.
Same happens if the canvas is deleted from the command line.
Cheers
Otto
mycanvas.C (1.1 KB)

run-in in debug I see that

MyCanvas::CanvasClosed()

is called twice from:

  1. void TCanvas::Closed()
  2. void TPad::Close(Option_t *)

Hi,
in TPad::Close(Option_t *) line: 985 we have:

// emit signal
if (IsA() != TCanvas::Class())
Closed();

so in this case (TCanvas) the signal should be suppressed.
Otto

But it seems that’s what this code does: in case the object is a TCanvas, Closed() is not called … right ?

in TPad::Close(Option_t *) line: 985 we have:

// emit signal
if (IsA() != TCanvas::Class())  Closed();

The conditional statement is ineffective in this case. TPad::Close is called from the TPad destructor which is called as a base destructor from the TCanvas destructror. By the time the TPad destructor starts, the object has (on some platform) ‘forgotten’ that it once was a TCanvas.

ok, I understand.
The question is:
Do we need the Emit(“Closed”) in TCanvas.cxx:802 at all
if it is emitted in TPad anyway.

I use for the moment a workaround:
When I receive “Closed” I do a Disconnect(“Closed”…
then I dont see another one.

Otto

Hi Otto,

Hard to tell if deleting it will generate side effects or not. It seems it was introduced 13 years ago by this patch.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.