Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => CodeCompletion redesign => Topic started by: ollydbg on May 13, 2014, 08:58:11 am

Title: CC Code review: CodeCompletion::m_InitDone
Post by: ollydbg on May 13, 2014, 08:58:11 am
This bool variable was introduced in

Code
Revision: 8080bfca289338ecfa74cf13dd10c4ae96cc0e64
Author: rickg22 <[email protected]>
Date: 2006-1-23 14:14:56
Message:
Removed (yet another) bottleneck in Codecompletion with global includes.
Removed (confirmed now) 5-second delay at startup with Codecompletion enabled.
git-svn-id: http://svn.code.sf.net/p/codeblocks/code/[email protected] 2a5c6006-c6dd-42ca-98ab-0921f2732cef

@@ -248,11 +252,6 @@ bool CodeCompletion::BuildToolBar(wxToolBar* toolBar)
 void CodeCompletion::OnAttach()
 {
  m_NativeParsers.CreateClassBrowser();
-
- // parse all active projects
- ProjectManager* prjMan = Manager::Get()->GetProjectManager();
- for (unsigned int i = 0; i < prjMan->GetProjects()->GetCount(); ++i)
- m_NativeParsers.AddParser(prjMan->GetProjects()->Item(i));
 }
...
+void CodeCompletion::OnAppDoneStartup(CodeBlocksEvent& event)
+{
+    // Let the app startup before parsing
+    m_timer.Start(200,wxTIMER_ONE_SHOT);
+}
+
+void CodeCompletion::OnStartParsingProjects(wxTimerEvent& event)
+{
+ // parse all active projects
+ ProjectManager* prjMan = Manager::Get()->GetProjectManager();
+ for (unsigned int i = 0; i < prjMan->GetProjects()->GetCount(); ++i)
+ m_NativeParsers.AddParser(prjMan->GetProjects()->Item(i));
+    m_InitDone = true;
+}
+

Here, a new timer is added. Before this commit, the parsing was started in CodeCompletion::OnAttach(), after this commit, the parsing is started a bit later (after the application is fully started, and a time period later). Since starting parsing may take several seconds, so delay this task can make C::B start much faster.

Note: When C::B started, it usually do such things


Code
...
scan plugins
for (each plugin)
    run its OnAttach()
...
send event: APP_STARTUP_DONE

But this cause an issue, here is the steps:

1, C::B is started with CodeCompletion plguin disabled.
2, you open a project
3, you enable the Codecompletion plugin
4, *BUG* Codecompletion plugin does not run parsing on already opened project.