Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign
Time to refresh the CC Toolbar
ollydbg:
I just enable the debug log in codecompletion.cpp
--- Code: ---#define CC_CODECOMPLETION_DEBUG_OUTPUT 1
--- End code ---
I see that the CC toolbar get refreshed many times if I click in the same function body.
E.g.
--- Code: ---wxString func()
{
wxString rv;
rv += wxT('a'); //*** first step: click here
rv += wxT('b');
rv += wxT('c'); //*** second step: click here
return rv;
}
--- End code ---
Here, the click is all in the same function body, but I see that the function:
--- Code: ---void CodeCompletion::ParseFunctionsAndFillToolbar()
--- End code ---
called multiply times.
Is that necessary? We don't need to refresh the toolbar if we click in the same function body.
ollydbg:
--- Code: ---void CodeCompletion::EditorEventHook(cbEditor* editor, wxScintillaEvent& event)
{
.....
.....
if (control->GetCurrentLine() != m_CurrentLine)
{
if (m_NeedReparse)
{
TRACE(_T("EditorEventHook: Starting m_TimerRealtimeParsing."));
m_TimerRealtimeParsing.Start(REALTIME_PARSING_DELAY, wxTIMER_ONE_SHOT);
m_CurrentLength = control->GetLength();
m_NeedReparse = false;
}
if (event.GetEventType() == wxEVT_SCI_UPDATEUI)
{
m_ToolbarNeedRefresh = true;
TRACE(_T("EditorEventHook: Starting m_TimerToolbar."));
if (m_TimerEditorActivated.IsRunning())
m_TimerToolbar.Start(EDITOR_ACTIVATED_DELAY + 1, wxTIMER_ONE_SHOT);
else
m_TimerToolbar.Start(TOOLBAR_REFRESH_DELAY, wxTIMER_ONE_SHOT);
}
}
// allow others to handle this event
event.Skip();
}
--- End code ---
Look, this value is force to be true
--- Code: ---m_ToolbarNeedRefresh = true;
--- End code ---
, even we have later set it to false.
--- Code: ---void CodeCompletion::ParseFunctionsAndFillToolbar()
{
.....
.....
// Does the toolbar need a refresh?
if (m_ToolbarNeedRefresh || m_LastFile != filename)
{
// Update the last editor and changed flag...
if (m_ToolbarNeedRefresh)
m_ToolbarNeedRefresh = false;
if (m_LastFile != filename)
{
TRACE(_T("ParseFunctionsAndFillToolbar() : Update last file is %s"), filename.wx_str());
m_LastFile = filename;
}
// ...and refresh the toolbars.
m_Function->Clear();
if (m_Scope)
{
m_Scope->Freeze();
m_Scope->Clear();
// add to the choice controls
for (unsigned int idxSc = 0; idxSc < m_ScopeMarks.size(); ++idxSc)
{
int idxFn = m_ScopeMarks[idxSc];
const FunctionScope& fs = m_FunctionsScope[idxFn];
m_Scope->Append(fs.Scope);
}
m_Scope->Thaw();
}
else
{
m_Function->Freeze();
for (unsigned int idxFn = 0; idxFn < m_FunctionsScope.size(); ++idxFn)
{
const FunctionScope& fs = m_FunctionsScope[idxFn];
m_Function->Append(fs.Scope + fs.Name);
}
m_Function->Thaw();
}
}
// Find the current function and update
FindFunctionAndUpdate(ed->GetControl()->GetCurrentLine());
// Control the toolbar state
EnableToolbarTools(fileParseFinished);
}
--- End code ---
Look:
--- Code: --- if (m_ToolbarNeedRefresh)
m_ToolbarNeedRefresh = false;
--- End code ---
Here
--- Code: ---m_ToolbarNeedRefresh = false;
--- End code ---
in this function, but as I can see, this member variable is always be set in the editor hook handler (CodeCompletion::EditorEventHook).
MortenMacFly:
...I think the problem here was the case, that the file was modified from externally. Then, you don't know where you are, the content could have been change completely. Thus, the toolbar better does a refresh.
ollydbg:
--- Quote from: MortenMacFly on December 21, 2012, 08:46:13 am ---...I think the problem here was the case, that the file was modified from externally. Then, you don't know where you are, the content could have been change completely. Thus, the toolbar better does a refresh.
--- End quote ---
I don't think this is related to my original question.
Currently, I think if I can detect the click (caret position) remains in the same function body, we don't need to update the toolbar. If you see your screen carefully, you will see it refresh everytime when you click the caret(event in the same function body).
oBFusCATed:
I've just had slowness, probably caused by the toolbar in one of the larger files of C::B, probably codecompletion.cpp.
No external files has have been modified, but every move of the cursor caused a slowdown and a flicker of the toolbar.
Navigation
[0] Message Index
[#] Next page
Go to full version