Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign
wxNewId() in a header file is wrong, right?
ollydbg:
I found such code snippet in plugins\codecompletion\systemheadersthread.h
--- Code: ---namespace SystemHeadersThreadHelper
{
static long idSystemHeadersThreadCompleted = wxNewId();
static long idSystemHeadersThreadUpdate = wxNewId();
static long idSystemHeadersThreadError = wxNewId();
}
--- End code ---
I think it is wrong, because wxNewId() will return different value between each translation unit(cpp file) include (either directly or indirectly) the systemheadersthread.h.
What's your idea? Thanks.
thomas:
This is probably only included once (otherwise it wouldn't work at all!), so it's kind of OK. But woe if this assumption isn't true one day in the future.
ollydbg:
Strange:
We have
--- Code: ---
Connect(SystemHeadersThreadHelper::idSystemHeadersThreadUpdate, wxCommandEventHandler(CodeCompletion::OnSystemHeadersThreadUpdate) );
Connect(SystemHeadersThreadHelper::idSystemHeadersThreadCompleted, wxCommandEventHandler(CodeCompletion::OnSystemHeadersThreadCompletion));
Connect(SystemHeadersThreadHelper::idSystemHeadersThreadError, wxCommandEventHandler(CodeCompletion::OnSystemHeadersThreadError) );
}
--- End code ---
In CodeCompletion.cpp
and
--- Code: --- // check the dir is ready for traversing
wxDir dir(dirs[i]);
if ( !dir.IsOpened() )
{
wxCommandEvent evt(wxEVT_COMMAND_MENU_SELECTED, SystemHeadersThreadHelper::idSystemHeadersThreadError);
evt.SetClientData(this);
evt.SetString(wxString::Format(_T("SystemHeadersThread: Unable to open: %s"), dirs[i].wx_str()));
wxPostEvent(m_Parent, evt);
continue;
}
--- End code ---
in systemheadersthread.cpp.
The header file was included at least in both codecompletion.cpp and systemheadersthread.cpp.
Strange. It looks like it is already a bug. I'm going to test it.
ollydbg:
--- Quote from: ollydbg on June 03, 2013, 02:34:13 pm ---Strange. It looks like it is already a bug. I'm going to test it.
--- End quote ---
I set breakpoints in the function body of:
--- Code: ---CodeCompletion::OnSystemHeadersThreadUpdate
CodeCompletion::OnSystemHeadersThreadCompletion
CodeCompletion::OnSystemHeadersThreadError
--- End code ---
But they never get hit.
golgepapaz:
It's obvious that the handler is registered to different eventID than the eventID that is
actually send (if it is ever sent of course.).Making them extern and providing the definition in
the cpp file is the obvious solution.
Navigation
[0] Message Index
[#] Next page
Go to full version