Runtime error on SetStatusBar from a Toolbar button event

12 views
Skip to first unread message

TSalm

unread,
Aug 5, 2011, 5:50:32 PM8/5/11
to wx-u...@googlegroups.com
Hi,

In my class constructor derived from wxFrame, I create a status bar and
set a text in it :
statusbar = new wxStatusBar(window, wxID_ANY,wxST_SIZEGRIP);
window->SetStatusBar( statusbar );
SetStatusText(txt);

No problem at this time.

But when I try to set the statusbar text when a event occurs, an Access
Violation is throwing :
void
gui::WindowMainActions::DoInvisibleSelected
(wxCommandEvent& WXUNUSED(event))
{
statusbar->SetStatusText("Rendre invisible");
}

Why does this access violation throw ?

TIA,
-TSalm

Vadim Zeitlin

unread,
Aug 5, 2011, 5:50:29 PM8/5/11
to wx-u...@googlegroups.com
On Fri, 05 Aug 2011 23:50:32 +0200 TSalm <TS...@free.fr> wrote:

T> Why does this access violation throw ?

Only you can tell us:

http://www.wxwidgets.org/support/mlhowto.htm#crashes

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/

TSalm

unread,
Aug 5, 2011, 6:05:55 PM8/5/11
to wx-u...@googlegroups.com
Le 05/08/2011 23:50, TSalm a �crit :
What a rude answer Vadim ;-)
In fact, sorry clumsiness, I'm a newbie about C++ and about
wxWidget...but I must start from somewhere, no? :-)

Well. In addition, here is a backtrace :
(gdb) bt
#0 0x0040187b in _fu497___ZSt4cout (this=0xabababab, txt=...) at
D:\dev\WinList\WinList v2 maquette\winlist 2 maquette\src\gui\Sta
#1 0x00402552 in gui::WindowMainActions::DoCloseSelected (this=0x1974878)
at D:\dev\WinList\WinList v2 maquette\winlist 2
maquette\src\gui\WindowMain.cpp:31
#2 0x004d6cf9 in
wxEvtHandler::ProcessEventIfMatches(wxEventTableEntryBase const&,
wxEvtHandler*, wxEvent&) ()
#3 0x004d7028 in wxEvtHandler::SearchDynamicEventTable(wxEvent&) ()
#4 0x004d70cf in wxEvtHandler::ProcessEvent(wxEvent&) ()
#5 0x004688a8 in wxToolBarBase::OnLeftClick(int, bool) ()
#6 0x004643f0 in wxToolBar::MSWCommand(unsigned int, unsigned short) ()
#7 0x0041670b in wxFrame::MSWWindowProc(unsigned int, unsigned int,
long) ()
#8 0x00419bf5 in wxWndProc ()
#9 0x77ccf8d2 in USER32!GetMessageW () from C:\Windows\system32\user32.dll
#10 0x77ccf794 in USER32!GetWindowLongW () from
C:\Windows\system32\user32.dll
#11 0x00419b7c in wxAssociateWinWithHandle(HWND__*, wxWindow*) ()
#12 0x77cd0a05 in USER32!GetWindowThreadProcessId () from
C:\Windows\system32\user32.dll
#13 0x77cd0afa in USER32!SendMessageW () from C:\Windows\system32\user32.dll
#14 0x74b3cd03 in CreatePropertySheetPageW ()
from
C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.6001.18000_none_886786f450a74a05\comctl32.dll
#15 0x74b1b16e in FlatSB_GetScrollInfo ()
from
C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.6001.18000_none_886786f450a74a05\comctl32.dll
#16 0x77ccf8d2 in USER32!GetMessageW () from C:\Windows\system32\user32.dll
#17 0x77ccf794 in USER32!GetWindowLongW () from
C:\Windows\system32\user32.dll
#18 0x74b17ae0 in DllGetVersion ()
from
C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.6001.18000_none_886786f450a74a05\comctl32.dll
#19 0x77cd06f6 in USER32!CallWindowProcW () from
C:\Windows\system32\user32.dll
#20 0x77cdba01 in USER32!CallWindowProcA () from
C:\Windows\system32\user32.dll
#21 0x004173c4 in wxWindow::MSWDefWindowProc(unsigned int, unsigned int,
long) ()
#22 0x0041e58d in wxWindow::MSWWindowProc(unsigned int, unsigned int,
long) ()
#23 0x00419bf5 in wxWndProc ()
#24 0x77ccf8d2 in USER32!GetMessageW () from C:\Windows\system32\user32.dll
#25 0x77ccf794 in USER32!GetWindowLongW () from
C:\Windows\system32\user32.dll
#26 0x00419b7c in wxAssociateWinWithHandle(HWND__*, wxWindow*) ()
#27 0x77cd0008 in USER32!PeekMessageW () from C:\Windows\system32\user32.dll
#28 0x77cc5a2c in USER32!DispatchMessageA () from
C:\Windows\system32\user32.dll
#29 0x00455d9a in wxEventLoop::ProcessMessage(tagMSG*) ()
#30 0x00455a9c in wxEventLoop::Dispatch() ()
#31 0x004759ee in wxEventLoopManual::Run() ()
#32 0x00429d4f in wxAppBase::MainLoop() ()
#33 0x00509672 in wxEntryReal(int&, char**) ()
#34 0x00428c40 in wxEntry(HINSTANCE__*, HINSTANCE__*, char*, int) ()
#35 0x0040285d in WinMain (hInstance=0x400000, hPrevInstance=0x0,
lpCmdLine=0x8f2f86 "", nCmdShow=10)
at D:\dev\WinList\WinList v2 maquette\winlist 2 maquette\src\main.cpp:8
#36 0x0056e5b6 in main ()

Does someone has an idea ?

Vadim Zeitlin

unread,
Aug 5, 2011, 6:08:44 PM8/5/11
to wx-u...@googlegroups.com
On Sat, 06 Aug 2011 00:05:55 +0200 TSalm <TS...@free.fr> wrote:

T> > Why does this access violation throw ?
T> What a rude answer Vadim ;-)

Believe me it wasn't, at least not in comparison with what I initially
wanted to write. Of course, there is always an alternative of not replying
at all which works pretty well too. But if you do want to get help you need
to make an effort too.

T> In fact, sorry clumsiness, I'm a newbie about C++ and about
T> wxWidget...but I must start from somewhere, no? :-)

This has really nothing to do with wxWidgets nor C++. The canonical text
about this is http://www.catb.org/~esr/faqs/smart-questions.html and it
doesn't mention neither of them.

T> Well. In addition, here is a backtrace :
T> (gdb) bt
T> #0 0x0040187b in fu497__ZSt4cout (this=0xabababab, txt=...) at
T> D:\dev\WinList\WinList v2 maquette\winlist 2 maquette\src\gui\Sta
T> #1 0x00402552 in gui::WindowMainActions::DoCloseSelected (this=0x1974878)
T> at D:\dev\WinList\WinList v2 maquette\winlist 2
T> maquette\src\gui\WindowMain.cpp:31

Your stack looks good and the value of "this" in the second frame is
reasonable while its value in the first one is clearly completely off. So
the obvious idea is that your status bar pointer is not initialized/set
correctly.

FWIW if you tried reproducing the problem in the sample, as the mailing
list HOWTO link I posted before recommends, you would have almost certainly
found the problem in less time than you needed to write these 2 messages.

TSalm

unread,
Aug 13, 2011, 4:37:21 PM8/13/11
to wx-u...@googlegroups.com
Le 06/08/2011 00:08, Vadim Zeitlin a �crit :
Thanks, you've got good advices.
But I'm searching for a long time but find nothing :-(
I want to believe in magic of the world wide web...
I join a code which reproduce the problem, if someone can see something
more than a newbie like me.

TIA
-TSalm

OneFileMain.cpp

Eric Jensen

unread,
Aug 13, 2011, 4:47:05 PM8/13/11
to TSalm
Hello TSalm,

Saturday, August 13, 2011, 10:37:21 PM, you wrote:

T> Le 06/08/2011 00:08, Vadim Zeitlin a �crit :

T> Thanks, you've got good advices.
T> But I'm searching for a long time but find nothing :-(
T> I want to believe in magic of the world wide web...
T> I join a code which reproduce the problem, if someone can see something
T> more than a newbie like me.

http://wiki.wxwidgets.org/WxFAQ#Why_does_my_app_crash_in_the_callback_of_an_event_bound_with_Connect.28.29_.3F

Basically, all your Connect() calls in gui::Toolbar::AttachEvents()
need additional parameters ", NULL, this);" at the end.

HTH
Eric


TSalm

unread,
Aug 14, 2011, 5:09:11 AM8/14/11
to wx-u...@googlegroups.com
This is in fine as simple as saying hello ! I was really lost.
A great thank to Eric !
Reply all
Reply to author
Forward
0 new messages