Hi rooters!
I have a pb with destructor of this object:
class NameSubWin: public TGTransientFrame // (derivee d une fenetre
GUI)
{
private:
TGCompositeFrame *fS0;
TGCompositeFrame *fSH1,*fSH2;
TGTextButton *fButtonOK,*fButtonCan;
TGLayoutHints *fL0;
TGLabel *fLmsg;
TGTextEntry *TEName;
TGTextBuffer *TBName;//! do not stream
public :
NameSubWin(const TGWindow *p, const TGWindow *main, UInt_t w,
UInt_t h,
UInt_t options = kMainFrame |
kVerticalFrame);
~NameSubWin();
Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
void CloseWindow(){delete this;}
ClassDef(NameSubWin,1)
};
The Methods are:
NameSubWin::NameSubWin(const TGWindow *p, const TGWindow *main, UInt_t
w,
UInt_t h,UInt_t options ): TGTransientFrame(p, main, w, h, options)
{
fS0 = new TGVerticalFrame(this, 500, 200);
fL0= new TGLayoutHints(kLHintsTop | kLHintsLeft |
kLHintsExpandX , 2, 2, 2, 2);
AddFrame(fS0, fL0);
fSH1=new TGHorizontalFrame(fS0, 200, 20);
fS0->AddFrame(fSH1,fL0);
fSH1->AddFrame(fLmsg=new TGLabel(fSH1, new TGString("Name:")),
fL0);
TEName = new TGTextEntry(fSH1, TBName = new
TGTextBuffer(100),1);
TBName->AddText(0, "");
TEName->Resize(200, TEName->GetDefaultHeight());
fSH1->AddFrame(TEName, fL0);
TEName->Associate(this);
//
// Frame for Ok/Cancel button
//
fSH2=new TGHorizontalFrame(fS0, 200, 20,kFixedWidth);
fS0->AddFrame(fSH2,new TGLayoutHints(kLHintsBottom |
kLHintsRight,0,0,10,0));
fButtonOK = new TGTextButton(fSH2, "&Ok",M_BUT_OK);
fButtonCan= new TGTextButton(fSH2,"&Cancel",M_BUT_CANCEL);
fSH2->AddFrame(fButtonOK, new TGLayoutHints(kLHintsTop |
kLHintsLeft | kLHintsExpandX,2, 2, 2, 2));
fSH2->AddFrame(fButtonCan, new TGLayoutHints(kLHintsTop |
kLHintsLeft | kLHintsExpandX,2, 2, 2, 2));
fButtonOK->Associate(this);
fButtonCan->Associate(this);
//***************************************************************************
// The REMAP Section
//***************************************************************************
MapSubwindows();
Resize(GetDefaultSize());
// position relative to the parent's window
Window_t wdum;
int ax, ay;
gGXW->TranslateCoordinates(main->GetId(), GetParent()->GetId(),
((TGFrame *) main)->GetWidth()/2,
(((TGFrame *) main)->GetHeight() - fHeight) >>
1,ax, ay, wdum);
Move(ax, ay);
SetWindowName("New Histo Name");
MapWindow();
fClient->WaitFor(this);
}
//
//----------------------------------------------------------------------------
//
NameSubWin::~NameSubWin()
{
delete fButtonOK ; delete fButtonCan;
delete fSH2;
//delete TEName;
//delete fLmsg;
delete fSH1;
delete fS0 ; delete fL0 ;
}
//
//----------------------------------------------------------------------------
//
Bool_t NameSubWin::ProcessMessage(Long_t msg, Long_t parm1, Long_t
parm2)
{
switch (GET_MSG(msg))
{
case kC_COMMAND:
switch (GET_SUBMSG(msg))
{
case kCM_BUTTON:
switch (parm1)
{
case M_BUT_CANCEL:
fOK2PLot=0;
CloseWindow();
break;
case M_BUT_OK:
fOK2PLot=1;
strcpy(histoname,TEName->GetBuffer()->GetString());
CloseWindow();
break;
}
break;
}
}
return kTRUE;
}
If Comment delete in the destructor are uncomment I have a
Fatal in <operator delete>: storage area overwritten
With the comment, if I push the cancel button all is ok but if I push
the OK button and if I have filled (with let say 1 character) the
TGTextEntry I got a
Error in <RootX11ErrorHandler>: BadWindow (invalid Window
parameter) (XID: 142606504)
And I don't know neither why nor what to do....
I seems to me that I am doing something which is very similar to the
guitest (that is of course working well) but apparently I miss
something.
Is there anybody to help me?
Thanks.
Olivier
--
=========================================================
|Olivier Meplan |E-mail:meplan@isn.in2p3.fr
| |
|ISN, 53 avenue des Martyrs | Tel +33(0)4 76-28-41-90
|F-38026 GRENOBLE cedex | Fax +33(0)4 76-28-40-04
=========================================================
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:41 MET