From: Thomas Zehbe on
Am Mittwoch, 25. Oktober 2006 11:33 schrieb Fibre Optic:
> Thomas Zehbe wrote:
> > How many tabs has the notebook? If there are only 2, you would try to
> > select the third, which doesn't exist.
>
> the notebook has 6 tabs
>
> > Is notebook a valid pointer in this context? Does it point to a notebook?
>
> i think it is valid pointer, at list
Can you examine the notebookobjects content in the debugger? Thinking is
always based on assumptions which could e wrong.

>
> > Is the crash gone if you comment the line out?
>
> yes!
Does it crash if you do notebook->GetId() or any other call instead the set?

The docs say that SetSelection does: "The call to this function generates the
page changing events." Is there a handler defined for it in MyListCtrl?
>
> > Are there event functions OnSelect in the notebook?
>
> I have prepared only the following event handler:
>
> // Event table for MyListCtrl
> BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl)
> EVT_LIST_ITEM_SELECTED(LIST_CTRL, MyFrame::OnSelectedT)
> END_EVENT_TABLE()
>
> IOs it ok that OnSelectedT method is member of MyFrame?
Yes.
>
> > Does it crash, if you do a "notebook->SetSelection(2);" in another part
> > of the program?
>
> I have added the line in to body of MyFrame::OnAbout it works perfectly !!!
What does selection 2 show? Is there anything initialized while being exposed?
My guess still is, that notebook isn't initialized or is overriden. Either the
pointer or the content on the heap, where the object is (probably) allocated.

Did you check that the adress notebook points remains the same at all times?
When and how do you initialize that object?

I recomend to start the program in the debugger to get a complete call stack
at crash time to see, where in the wxLib it dies.

Regards,

Thomas

>
> > All these could be usefull to isolate the error.
> > Hope it helps.
>
> Any ideas ?
>
> Regards,
> Fibre Optic
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

--
Dipl.-Ing. Thomas Zehbe
INGENION GmbH
Kuhweide 6
31552 Apelern
Fon: 05043 / 40 57 90 4
Fax: 05043 / 40 57 90 7

---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

From: Fibre Optic on
Thomas Zehbe wrote:
> Am Mittwoch, 25. Oktober 2006 11:33 schrieb Fibre Optic:
>> Thomas Zehbe wrote:
>>> How many tabs has the notebook? If there are only 2, you would try to
>>> select the third, which doesn't exist.
>> the notebook has 6 tabs
>>
>>> Is notebook a valid pointer in this context? Does it point to a notebook?
>> i think it is valid pointer, at list
> Can you examine the notebookobjects content in the debugger? Thinking is
> always based on assumptions which could e wrong.
>
>>> Is the crash gone if you comment the line out?
>> yes!
> Does it crash if you do notebook->GetId() or any other call instead the set?
YES
>
> The docs say that SetSelection does: "The call to this function generates the
> page changing events." Is there a handler defined for it in MyListCtrl?
>>> Are there event functions OnSelect in the notebook?
>> I have prepared only the following event handler:
>>
>> // Event table for MyListCtrl
>> BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl)
>> EVT_LIST_ITEM_SELECTED(LIST_CTRL, MyFrame::OnSelectedT)
>> END_EVENT_TABLE()
>>
>> IOs it ok that OnSelectedT method is member of MyFrame?
> Yes.
>>> Does it crash, if you do a "notebook->SetSelection(2);" in another part
>>> of the program?
>> I have added the line in to body of MyFrame::OnAbout it works perfectly !!!
> What does selection 2 show? Is there anything initialized while being exposed?
> My guess still is, that notebook isn't initialized or is overriden. Either the
> pointer or the content on the heap, where the object is (probably) allocated.
>
> Did you check that the adress notebook points remains the same at all times?
> When and how do you initialize that object?
>
> I recomend to start the program in the debugger to get a complete call stack
> at crash time to see, where in the wxLib it dies.
>
> Regards,
>
> Thomas
>


I have added the following lines into MyApp::OnInit() method:

frame->notebook->SetSelection(2);
printf("ID: %d\n",frame->notebook->GetId());
printf("Pointer address: %d\n",frame->notebook);

and these line into MyFrame::OnAbout method:

notebook->SetSelection(2);
printf("ID: %d\n",notebook->GetId());
printf("Pointer address: %d\n",notebook);

and these lines into MyFrame::OnSelectedT method:

printf("!!! SELECTEDt !!!\n");
printf("Pointer address: %d\n",notebook);
printf("ID: %d\n",notebook->GetId())


After program execution I see the following out put:

ID: -202 <----- MyApp::OnInit()
Pointer address: 2555288

ID: -202 <----- MyFrame::OnAbout()
Pointer address: 2555288

!!! SELECTEDt !!! <----- MyFrame::OnSelectedT()
Pointer address: 539042081

to me it looks like the pointer of notebook has been hanged... Am i
right? Is it root of program crash?

Regards,
Fibre Optic
From: Thomas Zehbe on
Am Mittwoch, 25. Oktober 2006 15:59 schrieb Fibre Optic:
> Thomas Zehbe wrote:
> > Am Mittwoch, 25. Oktober 2006 11:33 schrieb Fibre Optic:
> >> Thomas Zehbe wrote:
> >>> How many tabs has the notebook? If there are only 2, you would try to
> >>> select the third, which doesn't exist.
> >>
> >> the notebook has 6 tabs
> >>
> >>> Is notebook a valid pointer in this context? Does it point to a
> >>> notebook?
> >>
> >> i think it is valid pointer, at list
> >
> > Can you examine the notebookobjects content in the debugger? Thinking is
> > always based on assumptions which could e wrong.
> >
> >>> Is the crash gone if you comment the line out?
> >>
> >> yes!
> >
> > Does it crash if you do notebook->GetId() or any other call instead the
> > set?
>
> YES
>
> > The docs say that SetSelection does: "The call to this function generates
> > the page changing events." Is there a handler defined for it in
> > MyListCtrl?
> >
> >>> Are there event functions OnSelect in the notebook?
> >>
> >> I have prepared only the following event handler:
> >>
> >> // Event table for MyListCtrl
> >> BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl)
> >> EVT_LIST_ITEM_SELECTED(LIST_CTRL, MyFrame::OnSelectedT)
> >> END_EVENT_TABLE()
> >>
> >> IOs it ok that OnSelectedT method is member of MyFrame?
> >
> > Yes.
> >
> >>> Does it crash, if you do a "notebook->SetSelection(2);" in another part
> >>> of the program?
> >>
> >> I have added the line in to body of MyFrame::OnAbout it works perfectly
> >> !!!
> >
> > What does selection 2 show? Is there anything initialized while being
> > exposed? My guess still is, that notebook isn't initialized or is
> > overriden. Either the pointer or the content on the heap, where the
> > object is (probably) allocated.
> >
> > Did you check that the adress notebook points remains the same at all
> > times? When and how do you initialize that object?
> >
> > I recomend to start the program in the debugger to get a complete call
> > stack at crash time to see, where in the wxLib it dies.
> >
> > Regards,
> >
> > Thomas
>
> I have added the following lines into MyApp::OnInit() method:
>
> frame->notebook->SetSelection(2);
> printf("ID: %d\n",frame->notebook->GetId());
> printf("Pointer address: %d\n",frame->notebook);
>
> and these line into MyFrame::OnAbout method:
>
> notebook->SetSelection(2);
> printf("ID: %d\n",notebook->GetId());
> printf("Pointer address: %d\n",notebook);
>
> and these lines into MyFrame::OnSelectedT method:
>
> printf("!!! SELECTEDt !!!\n");
> printf("Pointer address: %d\n",notebook);
> printf("ID: %d\n",notebook->GetId())
>
>
> After program execution I see the following out put:
>
> ID: -202 <----- MyApp::OnInit()
> Pointer address: 2555288
>
> ID: -202 <----- MyFrame::OnAbout()
> Pointer address: 2555288
>
> !!! SELECTEDt !!! <----- MyFrame::OnSelectedT()
> Pointer address: 539042081
>
> to me it looks like the pointer of notebook has been hanged... Am i
> right? Is it root of program crash?
Yes! Could it be, that you define a second notbook* variable in the
OnSelectedT() event function? And use it without initialization? The number
looks a bit like memory garbage.
What I mean is a sequence like that:
MyFrame::OnSelectedT()
{
wxNotebook* notebook;
notebook->SetSelection(2);
crash ...

If you comment out the "notebook->SetSelection(2);" go once in the
OnSelectedT() function and then try to to do a "notebook->SetSelection(2);"
from another part of the program and it then works, you definitly have 2
notebook pointers.

If not not, then another piece of code in your frame overrides accidently the
content of the notbooks pointer variable. This mabe hard to find. Have a
close look to your code and try to use the debugger step by step to see when
the pointer gets dammaged.

Regards,

Thomas


>
> Regards,
> Fibre Optic
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

--
Dipl.-Ing. Thomas Zehbe
INGENION GmbH
Kuhweide 6
31552 Apelern
Fon: 05043 / 40 57 90 4
Fax: 05043 / 40 57 90 7

---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

From: Thomas Zehbe on
Am Mittwoch, 25. Oktober 2006 16:32 schrieb Eric Jensen:
> Hello Fibre,
>
> Wednesday, October 25, 2006, 3:59:28 PM, you wrote:
>
> FO> Thomas Zehbe wrote:
> >> Am Mittwoch, 25. Oktober 2006 11:33 schrieb Fibre Optic:
> >>> Thomas Zehbe wrote:
> >>>> How many tabs has the notebook? If there are only 2, you would try to
> >>>> select the third, which doesn't exist.
> >>>
> >>> the notebook has 6 tabs
> >>>
> >>>> Is notebook a valid pointer in this context? Does it point to a
> >>>> notebook?
> >>>
> >>> i think it is valid pointer, at list
> >>
> >> Can you examine the notebookobjects content in the debugger? Thinking is
> >> always based on assumptions which could e wrong.
> >>
> >>>> Is the crash gone if you comment the line out?
> >>>
> >>> yes!
> >>
> >> Does it crash if you do notebook->GetId() or any other call instead the
> >> set?
>
> FO> YES
>
> >> The docs say that SetSelection does: "The call to this function
> >> generates the page changing events." Is there a handler defined for it
> >> in MyListCtrl?
> >>
> >>>> Are there event functions OnSelect in the notebook?
> >>>
> >>> I have prepared only the following event handler:
> >>>
> >>> // Event table for MyListCtrl
> >>> BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl)
> >>> EVT_LIST_ITEM_SELECTED(LIST_CTRL, MyFrame::OnSelectedT)
> >>> END_EVENT_TABLE()
> >>>
> >>> IOs it ok that OnSelectedT method is member of MyFrame?
> >>
> >> Yes.
> >>
> >>>> Does it crash, if you do a "notebook->SetSelection(2);" in another
> >>>> part of the program?
> >>>
> >>> I have added the line in to body of MyFrame::OnAbout it works perfectly
> >>> !!!
> >>
> >> What does selection 2 show? Is there anything initialized while being
> >> exposed? My guess still is, that notebook isn't initialized or is
> >> overriden. Either the pointer or the content on the heap, where the
> >> object is (probably) allocated.
> >>
> >> Did you check that the adress notebook points remains the same at all
> >> times? When and how do you initialize that object?
> >>
> >> I recomend to start the program in the debugger to get a complete call
> >> stack at crash time to see, where in the wxLib it dies.
> >>
> >> Regards,
> >>
> >> Thomas
>
> FO> I have added the following lines into MyApp::OnInit() method:
>
> FO> frame->notebook->SetSelection(2);
> FO> printf("ID: %d\n",frame->notebook->GetId());
> FO> printf("Pointer address: %d\n",frame->notebook);
>
> FO> and these line into MyFrame::OnAbout method:
>
> FO> notebook->SetSelection(2);
> FO> printf("ID: %d\n",notebook->GetId());
> FO> printf("Pointer address: %d\n",notebook);
>
> FO> and these lines into MyFrame::OnSelectedT method:
>
> FO> printf("!!! SELECTEDt !!!\n");
> FO> printf("Pointer address: %d\n",notebook);
> FO> printf("ID: %d\n",notebook->GetId())
>
>
> FO> After program execution I see the following out put:
>
> FO> ID: -202 <----- MyApp::OnInit()
> FO> Pointer address: 2555288
>
> FO> ID: -202 <----- MyFrame::OnAbout()
> FO> Pointer address: 2555288
>
> FO> !!! SELECTEDt !!! <----- MyFrame::OnSelectedT()
> FO> Pointer address: 539042081
>
> FO> to me it looks like the pointer of notebook has been hanged... Am i
> FO> right? Is it root of program crash?
>
> FO> Regards,
> FO> Fibre Optic
>
> >>> // Event table for MyListCtrl
> >>> BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl)
> >>> EVT_LIST_ITEM_SELECTED(LIST_CTRL, MyFrame::OnSelectedT)
> >>> END_EVENT_TABLE()
> >>>
> >>> IOs it ok that OnSelectedT method is member of MyFrame?
> >>
> >> Yes.
>
> No, it's not ok. The 'this' pointer in the OnSelected method will be a
> pointer to the MyListCtrl instance. The MyFrame::OnSelectedT method
> itself will of course "think" that 'this' points to a MyFrame instance.
> That's causing the crash.
I don't agree, at least not completly. Of course if one uses the this pointer
in the function it must be clear that it's the frame, and not the listctrl.
And it's ok to do a myListCtrl->DoAnything() in the frames event function, if
myListCtrl is a member of the frame.

Regards,

Thomas

>
> You have 2 options:
> a) make the method static (so that you can't use 'this'), and rewrite
> it (use Event::GetEventObject() to get the MyListCtrl object, from
> there you can use GetParent() to get the MyFrame and so on)
>
> b) instead of the event table macro, use MyListCtrl->Connect() and set
> the eventsink parameter to MyFrame.
>
> Eric
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

--
Dipl.-Ing. Thomas Zehbe
INGENION GmbH
Kuhweide 6
31552 Apelern
Fon: 05043 / 40 57 90 4
Fax: 05043 / 40 57 90 7

---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org
For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org

From: Fibre Optic on
Eric Jensen wrote:

> No, it's not ok. The 'this' pointer in the OnSelected method will be a
> pointer to the MyListCtrl instance. The MyFrame::OnSelectedT method
> itself will of course "think" that 'this' points to a MyFrame instance.
> That's causing the crash.
>
> You have 2 options:
> a) make the method static (so that you can't use 'this'), and rewrite
> it (use Event::GetEventObject() to get the MyListCtrl object, from
> there you can use GetParent() to get the MyFrame and so on)
>
> b) instead of the event table macro, use MyListCtrl->Connect() and set
> the eventsink parameter to MyFrame.

b)

MyListCtrl is my class definition. Do you mean 'navigation' which is
object of the MyListCtrl class? If yes, wow should look the
navigation->Connect line?


navigation->Connect(LIST_CTRL, EVT_LIST_ITEM_SELECTED,
wxCommandEventHandler(MyFrame::OnSelectedT));

EVT_LIST_ITEM_SELECTED does not work with dynamic event routing, what i
shoul use in this context ?

Regards,
Fibre Optic