Child Threads Writing to Parent's Control Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Tyler
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 246
Joined: Fri Sep 03, 2004 12:37 am
Contact:

Child Threads Writing to Parent's Control

Post by Tyler » Mon Sep 05, 2005 3:50 pm

Has anyone run into this bug before?
C:\wxWidgets-2.6.1\src\msw\textctrl.cpp(122): assert "m_count == -1" failed: wrong initial m_updatesCount value [in child thread]
I keep getting this assertion when trying to write to a wxTextCtrl in my top level window from a child thread.

SnakeChomp
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 235
Joined: Sun Oct 10, 2004 2:53 am
Contact:

Post by SnakeChomp » Mon Sep 05, 2005 4:07 pm

Doing this is not a good idea because you will run into common multithreading problems like reading from something that you are currently writing to. You aren't even supposed to use gui functions within a child thread unless you are inbetween calls to ::wxMutexGuiEnter() and ::wxMutexGuiLeave(), which enable you to use GUI functions from child threads.

What you should be doing is sending an event to the main thread instructing it to write a given string into your textbox, not writing to it directly from a child thread.

Tyler
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 246
Joined: Fri Sep 03, 2004 12:37 am
Contact:

Post by Tyler » Mon Sep 05, 2005 4:14 pm

Thanks! That cleared things up a lot.

Post Reply