Bug #18804 2012-11-21 06:20
alatar_
Reuse thread
In debug build I got many asserts about reuse thread:
ASSERT INFO:
/var/tmp/portage/x11-libs/wxGTK-2.9.4.1/work/wxPython-src-2.9.4.0/src/unix/threadpsx.cpp(960): assert "GetState() == STATE_NEW" failed in Run(): thread may only be started once after Create()
BACKTRACE:
[1] wxOnAssert(char const*, int, char const*, char const*, wchar_t const*)
[2] wxThread::Run()
[3] CodeCompletion::OnParserEnd(wxCommandEvent&)
[4] wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const
[5] wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&)
[6] wxEvtHandler::SearchDynamicEventTable(wxEvent&)
[7] wxEvtHandler::TryHereOnly(wxEvent&)
[8] wxEvtHandler::DoTryChain(wxEvent&)
[9] wxEvtHandler::ProcessEvent(wxEvent&)
[10] Parser::ProcessParserEvent(ParserCommon::ParserState, int, wxString const&)
[11] Parser::OnAllThreadsDone(CodeBlocksEvent&)
[12] wxAppConsoleBase::CallEventHandler(wxEvtHandler*, wxEventFunctor&, wxEvent&) const
[13] wxEvtHandler::ProcessEventIfMatchesId(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&)
[14] wxEvtHandler::SearchDynamicEventTable(wxEvent&)
[15] wxEvtHandler::TryHereOnly(wxEvent&)
[16] wxEvtHandler::ProcessEventLocally(wxEvent&)
[17] wxEvtHandler::ProcessEvent(wxEvent&)
[18] wxEvtHandler::ProcessPendingEvents()
[19] wxAppConsoleBase::ProcessPendingEvents()
[20] wxApp::DoIdle()
[21] g_main_context_dispatch
[22] g_main_loop_run
[23] gtk_main
[24] wxGUIEventLoop::Run()
- Category
- Plugin::CodeCompletion
- Group
- Platform:Linux
- Status
- Closed
- Close date
- 2012-11-22 11:54
- Assigned to
- mortenmacfly
History
C::B is not yet fully compatible with wx2.9.4. please use wx2.8.12. BTW: you are also missing the most important: Version and platform information. Also: the question is, if that's our fault, or a wx fault. See what we check before: if ( m_CCEnableHeaders && !m_SystemHeadersThreads.empty() && !m_SystemHeadersThreads.front()->IsRunning() && m_NativeParser.Done() ) { m_SystemHeadersThreads.front()->Run(); } -> notice the "!m_SystemHeadersThreads.front()->IsRunning()".
>> -> notice the "!m_SystemHeadersThreads.front()->IsRunning()".
Here is a condition that runs thread after it`s stops. So Assert is correct ("thread may only be started once after Create()", not "Thread is running").
I`m not an expert in multithread programming, but as I know threads in wxWidgets should not be reused. I can not find this in the official wx2.8 docs, but here is quote from wxBook:
"you must delete the corresponding wxTHRead object yourself (once used, it cannot be reused)"
Cross-Platform GUI Programming with wxWidgets
Authors: Smart J., Hock K., Csomor S
Published year: 2005
http://flylib.com/books/en/3.138.1.144/1/
And here is documentation on wx 2.9:
"Finally, note that once a thread has completed and its Entry() function returns, you cannot call Run() on it again (an assert will fail in debug builds or wxTHREAD_RUNNING will be returned in release builds)."
http://docs.wxwidgets.org/trunk/classwx_thread.html#a5d894750ffaac8fc42ee85aeff8bb4c0