Author Topic: two questions about rev 7778, the change of class browser build thread  (Read 9344 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Hi, Morten.
Q1:
I see the classbrowser.cpp, in function void ClassBrowser::ThreadedBuildTree(cbProject* activeProject)
Why do you first pause the thread, then post the semaphore, and finally resume the thread?
Why not just post the semaphore directly as before rev 7778? I don't think the pause of the thread is necessary.


Q2:
You add the comment in the plugins\codecompletion\classbrowserbuilderthread.cpp
Code
    // Initialisation is done after Init() and at least *one* call to BuildTree().
    // Also, in Init() m_InitDone is set to false, directly followed by a
    // re-launch of the thread resulting in a call to BuildTree() due to
    // posting the semaphore from ClassBrowser.
    m_InitDone = true;
But I don't see the m_InitDone will changed to false later. In-fact this variable was initialized as false value, and once it was set to true, it never changed to false. Can you explain?

Thanks.




« Last Edit: May 11, 2014, 03:03:52 pm by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Why not just post the semaphore directly as before rev 7778? I don't think the pause of the thread is necessary.
I don't recall exactly, but IMHO the pause fixed a crash. You can try what happens if you remove it. Especially when you close/re-open projects.

   m_InitDone = true;
But I don't see the m_InitDone will changed to false later. In-fact this variable was initialized as false value, and once it was set to true, it never changed to false. Can you explain?
...simply because the one-time initialisation has finished?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ