Problem with mouse events - more info
Craig Deady
cdeady at systems-shop.com
Thu Oct 5 07:42:11 PDT 2006
Julian,
If I do the following in the mouse event, it works fine:
wxTextCtrl* UL = (wxTextCtrl*)FindWindowById(ID_UserLevel);
printf("UserLevel = %s\n",UL->GetValue().c_str());
But trying to access the object vUserLevel directly will cause a seg
fault. Like:
printf("UserLevel = %s\n",vUserLevel->GetValue().c_str());
Recall that vUserLevel is initialized in the constructor and also the
declaration is in the class structure to make the variable visible to
all members of the class.
Craig
Iulian-Nicu Serbanoiu wrote:
> what part of the code crashes/where ?
>
> a stack trace in gdb would be good.
>
> try removing the printf. check if the objects are initialized (
> vUserLevel not initialized for example could be the cause of the crash ).
>
> HTH,
>
> Iulian
>
>
> On 10/4/06, *Craig Deady* <cdeady at systems-shop.com
> <mailto:cdeady at systems-shop.com>> wrote:
>
> I have the following two sample code fragments. The first code
> fragment
> works fine, the second one causes a Segmentation fault. The only
> difference is that the second responds to a mouse down event on a
> wxTextCtrl object and the first is a clicked event on a button.
> Any ideas why I am getting the Segmentation fault?
> Linux 2.6 (Fedora Core 5) & wxWidgets 2.6.3
>
> Thanks,
> Craig
>
> void MainPanel::OnStartrefClick( wxCommandEvent& event )
> {
> printf("UserLevel = %s\n",vUserLevel->GetValue().c_str());
>
> event.Skip();
> }
>
>
> void MainPanel::UserSelect(wxMouseEvent& event)
> {
> printf("UserLevel = %s\n",vUserLevel->GetValue().c_str());
>
> event.Skip();
> }
>
> --
> Craig Deady
>
>
--
Craig Deady
cdeady at systems-shop.com
C & D Systems
118 England Rd.
Rochester, NH 03867-4616 USA
Tel: +1 603-330-3939
Fax: +1 603-330-0556
www.systems-shop.com
More information about the wx-users
mailing list