CodeLite Initializaion analysis - 初始化流程分析(1)
转载请注明出处,该文章来源于cbforge.com by Bryan Wu. CodeLite IDE的主应用程序类实现在文件 /liteeditor/app.cpp中,系统初始化时,从wxApp继承的App类会调用OnInit成员函数,bool App::OnInit()
- If it is Linux or MAC system, block signal pipe first;
- wxSocketBase::Initialize();
- 打开fatal exception handler,假如系统crash,会调用wxApp::OnFatalException,在此处可以采集一些调试信息;
- InitXmlResource:通过wxMemoryFSHandler加载资源文件到内存,包括很多PNG文件和xml文件;
- 调用wxCmdLineParser解析命令行参数,命令行描述如下:
假如是h,会打印帮助并推出,如果有b,重新设置basedir。static const wxCmdLineEntryDesc cmdLineDesc[] = {
{wxCMD_LINE_SWITCH, “v“, “version”, “Print current version”, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
{wxCMD_LINE_SWITCH, “h“, “help”, “Print usage”, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
{wxCMD_LINE_OPTION, “l“, “line”, “Open the file at a given line number”, wxCMD_LINE_VAL_NUMBER, wxCMD_LINE_PARAM_OPTIONAL },
{wxCMD_LINE_OPTION, “b“, “basedir”, “The base directory of CodeLite”, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
{wxCMD_LINE_PARAM, NULL, NULL, “Input file”, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE|wxCMD_LINE_PARAM_OPTIONAL },
{wxCMD_LINE_NONE }
}; - 设置各种目录,包括homeDir,installPath,CurDir,StartupDir等;
- Load Menu resource, rc/menu.xrc
- Initialize the configuration file locater,ConfFileLocator::Instance()->Initialize
- 初始化Manager类,该类从Singleton Pattern template而来;
- read the last frame size from the configuration file and initialise editor configuration files;
- 加入SingleInstance为真,我们需要通过调用wxSingleInstanceChecker来检查CodeLite运行实例是否唯一;
- Update PATH environment variable with the install directory and MinGW default installation (if exists)
- 显示splash screen,图片存储在 /images/splashscreen.png(可选,配置在GeneralInfo中)
- 重头戏来了,Frame::Initialize,初始化Frame中会包括很多内容,下面详述;
- update the accelerators table;
- 显示由第14步初始化的Frame并置为top window;
- 刚才第5步中解析的结果中如果有line,和input file,会依次打开并跳转至line-1行;
- 最后一步:通过wxLogMessage打印Install path和Startup Path信息,Over。
以下是对第14步中提到的Frame的Initialize分析,class Frame : public wxFrame:
- initialize the environment variable configuration manager:EnvironmentConfig;
- validate the frame loaded pos & size;
- new Frame,创建Frame实例;主要代码如下
CreateGUIControls(); 主要的创建GUI部分代码,会在另外一篇文章中详细分析(ide.cbforge.com by Bryan Wu),待续…
ManagerST::Get(); // Dummy call
//allow the main frame to receive files by drag and drop
SetDropTarget( new FileDropTarget() );// Start the search thread
SearchThreadST::Get()->SetNotifyWindow(this);
SearchThreadST::Get()->Start(WXTHREAD_MIN_PRIORITY);// start the job queue
JobQueueSingleton::Instance()->Start(5);// the single instance job is a presisstent job, so the pool will contain only 4 available threads
JobQueueSingleton::Instance()->PushJob(new SingleInstanceThreadJob(this, ManagerST::Get()->GetStarupDirectory()));//start the editor creator thread
m_timer = new wxTimer(this, FrameTimerId);
m_timer->Start(1000); - change all .db files under the startup directory to be .tags
- add the welcome page if enabled
- LoadPlugins,非常重要的一步,关于加载插件会在另外一篇文章中详细分析(ide.cbforge.com by Bryan Wu.),待续…
- Create the file explorer,Over。
在Frame中包括几个重要的Pane:
- MainBook:其中包括NavBar, Notebook(container for pages),QuickFindBar等,打开文件并显示在这个Pane中;
- OutputPane:FindResultsTab,ReplaceInFilesPanel,BuildTab,ErrorsTab,ShellTab,DebugTab,TaskPanel…
- WorkspacePane:WindowStack,OpenWindowsPanel, FileExplorer,WorkspaceTab
- DebuggerPane:LocalVarsTree,SimpleTable,ThreadListPanel,MemoryView等
Related posts:
- CodeLite Plugin Internal(2)-Load: 插件加载分析
- CodeLite Plugin Internal(1) – IPlugin interface
- Debugging With CodeLite - CodeLite调试简介
- CodeLite IDE介绍
- C::B IDE的命令行参数
- Setting up Code::Blocks to work with SDL - 多媒体编程库
- A rough guide for wxWidgets programming
- CodeLite代码分析之 – Create New Project流程
- 删除工程中svn文件的脚本(Ruby版和Python版)
- CodeLite to CodeInsight task 1: Internationalization














