Experiencing crashes with TGNumberEntry

Hi,
I’m having some problems with TGNumberEntry. If I click on the Number Entry field, it creates a blinking cursor in the box. If I then close the window, leaving the cursor in the entry field, my ROOT application crashes with the following error:
Error in : BadWindow (invalid Window parameter) (TGNumberEntryField XID: 62915024, XREQ: 61)

If I click somewhere outside of the entry field before closing the window so that none of the entry fields have a blinking cursor, the application continues to function normally.

I’m running ROOT 5.10 on Fedora Core 4 with most of the latest packages. The offending code is somewhere in the constructor of EntryTestDlg - I created a stripped down and modified guitest.cxx to better illustrate my problem which I attached.

TIA!
Tim[/code]
guitest.tar.gz (3.28 KB)

Hi,

I don’t see any problem with CVS Head on Windows.
Will check on linux on Monday and let you know.

Cheers,
Bertrand.

Hi,
TGCanvas is not an owner of the canvas container, i.e.
container is not a subframe of scrolled canvas.
Container frame must be deleted (probably this case is badly docunmented).
The following code should help :


/// v.o. ///// canvas container frame ////////
static TGCompositeFrame   *TBFrame;

EntryTestDlg::EntryTestDlg(const TGWindow * p, const TGWindow * main)
 : TGTransientFrame(p, main, 10, 10, kHorizontalFrame)
{
    Int_t              i,N;
    TGLabel            *tglabel;
    char               txt[32];
    TGNumberEntry      *tne[2];
    TGCheckButton      *cb;

   // use hierarchical cleani
   SetCleanup(kDeepCleanup);

/*********************************************************************/

    EditList = new TList();

    N = 10;

    TGCanvas *fCanvasWindow = new TGCanvas(this, 400, 600);

    TBFrame = new TGCompositeFrame(fCanvasWindow->GetViewPort(),
                    10,10, kHorizontalFrame);
    fCanvasWindow->SetContainer(TBFrame);

   //// v.o. -  automatically delete all subframes of canvas container frame 
    TBFrame->SetCleanup(kDeepCleanup);

    /*
     * N+1 Rows since we have a label header first in the
     * scrolled window.
     */
    TBFrame->SetLayoutManager(new TGMatrixLayout(TBFrame, N+1, 4, 2));

    tglabel = new TGLabel(TBFrame, new TGHotString("ID"));
    TBFrame->AddFrame(tglabel);
    tglabel = new TGLabel(TBFrame, new TGHotString("Depth"));
    TBFrame->AddFrame(tglabel);
    tglabel = new TGLabel(TBFrame, new TGHotString("Speed"));
    TBFrame->AddFrame(tglabel);
    tglabel = new TGLabel(TBFrame, new TGHotString("Mark"));
    TBFrame->AddFrame(tglabel);

    for (i=0; i <N>AddFrame(tglabel);

        tne[0] = new TGNumberEntry(TBFrame,
                        500, 8, i,
                        TGNumberFormat::kNESRealOne,
                        TGNumberFormat::kNEAAnyNumber,
                        TGNumberFormat::kNELLimitMinMax,
                        0.0,
                        50000.0);
        TBFrame->AddFrame(tne[0]);

        tne[1] = new TGNumberEntry(TBFrame,
            1500, 8, i+1000,
            TGNumberFormat::kNESRealOne,
            TGNumberFormat::kNEAPositive,
            TGNumberFormat::kNELLimitMinMax,
            1000.0,
            1600.0);
        TBFrame->AddFrame(tne[1]);

        // Put in checkbox for indicating deletion.
        cb = new TGCheckButton (TBFrame, new TGHotString("Delete"));
        TBFrame->AddFrame(cb);

        EditList->Add(new PointTracker(i, tne, cb));
    }
    TBFrame->Resize();
    AddFrame(fCanvasWindow, new TGLayoutHints(kLHintsRight,
                       2, 2, 2, 2));
/****************************************************************************/

   // set dialog box title
   SetWindowName("Number Entry Test");
   SetIconName("Number Entry Test");
   SetClassHints("NumberEntryDlg", "NumberEntryDlg");
   // resize & move to center
   MapSubwindows();
   UInt_t width = GetDefaultWidth();
   UInt_t height = GetDefaultHeight();
   Resize(width, height);

   CenterOnParent();

   // make the message box non-resizable
   SetWMSize(width, height);
   SetWMSizeHints(width, height, width, height, 0, 0);
   SetMWMHints(kMWMDecorAll | kMWMDecorResizeH | kMWMDecorMaximize |
               kMWMDecorMinimize | kMWMDecorMenu,
               kMWMFuncAll | kMWMFuncResize | kMWMFuncMaximize |
               kMWMFuncMinimize, kMWMInputModeless);

   MapWindow();
   fClient->WaitFor(this);
}

EntryTestDlg::~EntryTestDlg()
{
   // dtor

    delete EditList;
 
    ////// v.o. ////////////delete container frame 
    delete TBFrame;
}

Hi,

Valeriy is right. His suggestion solves the problem.

Cheers,
Bertrand.