Re: TGTextView window close signal connect

From: Nicolas Produit <Nicolas.Produit_at_unige.ch>
Date: Thu, 29 Jul 2010 08:47:36 +0200


Hi,

here is the example:

crash.C:



void CloseWindow(){
  printf("Quitting by user request\n");
  gApplication->Terminate(0);
}

void crash(){
  TGTextView* cond=new TGTextView(gClient->GetRoot());

  cond->MapSubwindows();
  cond->MapWindow();
  cond->MoveResize(900,600,300,300);
  cond->GetCanvas()->Connect("Destroyed()",NULL,NULL,"CloseWindow()");
  TCanvas* c1=new TCanvas();
  c1->Connect("Closed()",NULL,NULL,"CloseWindow()"); }

session where the canvas was closed in clicking the window close on the c1 canvas. Everything is nice and smooth.

produit_at_produit-dell:~/bla$ root


ROOT 5.26/00 (trunk_at_31882, Dec 14 2009, 20:18:36 on linux)

CINT/ROOT C/C++ Interpreter version 5.17.00, Dec 21, 2008 Type ? for help. Commands must be C++ statements. Enclose multiple statements between { }.

root [0] .L crash.C
root [1] crash()
root [2] Quitting by user request

produit_at_produit-dell:~/bla$

session where the TGTextView was closed in clicking the window close on the TGTextView window. We get an error.

produit_at_produit-dell:~/bla$ root


ROOT 5.26/00 (trunk_at_31882, Dec 14 2009, 20:18:36 on linux)

CINT/ROOT C/C++ Interpreter version 5.17.00, Dec 21, 2008 Type ? for help. Commands must be C++ statements. Enclose multiple statements between { }.

root [0] .L crash.C
root [1] crash()
root [2] Error in <RootX11IOErrorHandler>: fatal X11 error (connection
to server lost?!)

root [2] .q
produit_at_produit-dell:~/bla$

On Wed, 2010-07-28 at 19:12 +0200, Bertrand Bellenot wrote:

> Hi Nicolas,
> 
> You have to be careful when using signals slots with objects being 
> destroyed, since the actual X window may already be gone and the slot 
> still trying to access it...
> Anyway, it is hard to tell exactly what's going on with so little 
> information. Could you provide a short running macro reproducing the 
> problem?
> 
> Cheers, Bertrand.
> 
> On 7/28/2010 5:59 PM, Nicolas Produit wrote:
> > Hi,
> >
> > is it possible to Connect to a window close event of an object of type
> > TGTextView?
> >
> > I tried:
> >
> > cond=new TGTextView(gClient->GetRoot());
> > cond->MapSubwindows();
> > cond->MapWindow();
> > cond->MoveResize(900,600,300,300);
> > cond->GetCanvas()->Connect("Destroyed()","MonitorFrame",this,"CloseWindow()");
> >
> > this does not give error messages so it seems the Destroyed() signal
> > from the TQObject can be connected but then when killing the window I
> > get a:
> > Error in<RootX11IOErrorHandler>: fatal X11 error (connection to server
> > lost?!)
> > rather to a call to my subroutine (the subroutine work for connected
> > TCanvas on signal Closed())
> >
> > Thanks
> >
> >    
> 

-- 
Nicolas Produit
ISDC, Data Centre for Astrophysics   Phone:+41 22 379 2140
16, Chemin d'Ecogia                  Fax:  +41 22 379 2133
CH-1290 Versoix                      www:  http://isdc.unige.ch/~produit
Received on Thu Jul 29 2010 - 08:47:41 CEST

This archive was generated by hypermail 2.2.0 : Thu Jul 29 2010 - 17:50:02 CEST