Problem with mouse events

Iulian-Nicu Serbanoiu undergraver at gmail.com
Thu Oct 5 10:42:00 PDT 2006


try wxMessageBox( vUserLevel->GetValue() ); and see if it works. I don't
really have any other ideas.

HTH,

Iulian

On 10/5/06, Craig Deady <cdeady at systems-shop.com> wrote:
>
> Julian,
>
> The code crashes at the printf in the UserSelect routine. The printf is
> the only line of code and is there to show the problem. When the code
> tries to access the variable vUserLevel which is a wxTextCtrl object,
> the program seg faults. The object is initialized in the constructor
> before the event occurs. The other routine "OnStartrefClick" accesses
> the same variable without causing a seg fault.
>
> The variable is initialized in the constructor, here is the code:
>     vUserLevel =3D new wxTextCtrl(this, wxID_ANY, wxEmptyString,
> wxPoint(x+7,y+22),
>                                                         wxSize(150, 30),
> wxTE_READONLY);
>
>     vUserLevel->Connect(wxEVT_LEFT_DOWN,
> wxMouseEventHandler(MainPanel::UserSelect));
>
> Here is the stack trace:
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread -1208326448 (LWP 3257)]
> 0x08063b29 in MainPanel::UserSelect (this=3D0x97f72e0, event=3D at 0xbfa90a3=
4)
>     at ../GuiMain.cpp:535
> 535             printf("UserLevel =3D %s\n",vUserLevel->GetValue().c_str(=
));
> (gdb) bt
> #0  0x08063b29 in MainPanel::UserSelect (this=3D0x97f72e0,
> event=3D at 0xbfa90a34)
>     at ../GuiMain.cpp:535
> #1  0x081a6873 in wxAppConsole::HandleEvent (this=3D0x9708fb8,
>     handler=3D0x97f72e0, func=3D
>       {__pfn =3D 0x8063ac0 <MainPanel::UserSelect(wxMouseEvent&)>, __delta
> =3D 0},
>     event=3D at 0xbfa90a34) at
> /usr/lib/wxWidgets-2.6.3/src/common/appbase.cpp:324
> #2  0x0820f2f2 in wxEvtHandler::ProcessEventIfMatches (entry=3D at 0x97fa3a0,
>     handler=3D0x97f72e0, event=3D at 0xbfa90a34)
>     at /usr/lib/wxWidgets-2.6.3/src/common/event.cpp:1193
> #3  0x0820f707 in wxEvtHandler::SearchDynamicEventTable (this=3D0x97f72e0,
>     event=3D at 0xbfa90a34) at /usr/lib/wxWidgets-2.6.3
> /src/common/event.cpp:1371
> #4  0x08210c03 in wxEvtHandler::ProcessEvent (this=3D0x97f72e0,
>     event=3D at 0xbfa90a34) at /usr/lib/wxWidgets-2.6.3
> /src/common/event.cpp:1251
> #5  0x080adfe1 in gtk_window_button_press_callback (widget=3D0x9753228,
>     gdk_event=3D0x97235e0, win=3D0x97f72e0)
>     at /usr/lib/wxWidgets-2.6.3/src/gtk/window.cpp:1850
> #6  0x4411658e in gtk_marshal_BOOLEAN__VOID ()
>    from /usr/lib/libgtk-x11-2.0.so.0
> #7  0x43e04f8b in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
> #8  0x43e15e3d in g_signal_override_class_closure ()
>    from /usr/lib/libgobject-2.0.so.0
> #9  0x43e1710f in g_signal_emit_valist () from /usr/lib/libgobject-
> 2.0.so.0
> #10 0x43e17509 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
> #11 0x44201858 in gtk_widget_get_default_style ()
>    from /usr/lib/libgtk-x11-2.0.so.0
> #12 0x4410ff63 in gtk_propagate_event () from /usr/lib/libgtk-x11-2.0.so.0
> #13 0x441111b7 in gtk_main_do_event () from /usr/lib/libgtk-x11-2.0.so.0
> #14 0x43fa785a in gdk_add_client_message_filter ()
>    from /usr/lib/libgdk-x11-2.0.so.0
> #15 0x43d8d15d in g_main_context_dispatch () from /usr/lib/libglib-
> 2.0.so.0
> #16 0x43d903ef in g_main_context_check () from /usr/lib/libglib-2.0.so.0
> #17 0x43d90799 in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
> #18 0x44111634 in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0
> #19 0x0812ca81 in wxEventLoop::Run (this=3D0x9828a68)
>     at /usr/lib/wxWidgets-2.6.3/src/gtk/evtloop.cpp:80
> #20 0x080d25c6 in wxAppBase::MainLoop (this=3D0x9708fb8)
>     at /usr/lib/wxWidgets-2.6.3/src/common/appcmn.cpp:272
> #21 0x080d2121 in wxAppBase::OnRun (this=3D0x9708fb8)
>     at /usr/lib/wxWidgets-2.6.3/src/common/appcmn.cpp:340
> #22 0x081d482a in wxEntry (argc=3D at 0xbfa91220, argv=3D0xbfa912a4)
>     at /usr/lib/wxWidgets-2.6.3/src/common/init.cpp:439
> #23 0x08061030 in main (argc=3DCannot access memory at address 0x1
> ) at ../GuiMain.cpp:114
> (gdb)
>
> Thanks for your help,
> 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 =3D %s\n",vUserLevel->GetValue().c_str());
> >
> >     event.Skip();
> >     }
> >
> >
> >     void MainPanel::UserSelect(wxMouseEvent& event)
> >     {
> >         printf("UserLevel =3D %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
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wx-users/attachments/20061005/2d1=
bd4d6/attachment.htm


More information about the wx-users mailing list