Hi, I'm having a serious problem I need help with.
I'm part of the Code::Blocks IDE development team, and my current problem is the class browser, after saving a file it freezes the GUI for 2 or 3 seconds and it's very annoying. The problem is, I don't know how to fix it.
Here's what happens:
After saving a file, the parser updates the class browser's wxTreeCtrl (adding and sorting items), but it's done in the main thread. Due to the amount of information processed (>10,000 items in the tree for large projects, >50,000 with global includes), it takes VERY LONG.
(And using wxApp::Yield is out of the question, it's caused us many headaches before).
My question is: How can I update a GUI object from a thread? My idea was creating a temporary invisible wxTreeCtrl, but I'm not sure how this could be accomplished.
Any help?
wxTreeCtrl and multithreading - need help ASAP Topic is solved
Hi rickg22,
That's generally a tricky situation. Did you have a look at and ?
From what I gather, people experienced varied results with them. Last time I used them was somewhere in the early 2.5 branch and it didn't quite work like wanted, but it still might help.
HTH, Chris
P.S.: Good work with C::B, I'm using it myself
edit and PPS:
You may also experiment with Freeze() and Thaw().
That's generally a tricky situation. Did you have a look at
Code: Select all
wxMutexGuiEnter()
Code: Select all
wxMutexGuiLeave()
From what I gather, people experienced varied results with them. Last time I used them was somewhere in the early 2.5 branch and it didn't quite work like wanted, but it still might help.
HTH, Chris
P.S.: Good work with C::B, I'm using it myself

edit and PPS:
You may also experiment with Freeze() and Thaw().
this->signature=NULL;
I strongly advice to stay off the GUI when you are in a seperate thread. This really can cause weird unpredictable behaviour.
What I would do, is update a tree hiararchy in the thread that is responsible for the classes and scanning (I do not know how that is done in C::B) once you are done with gathering info, send the tree in total to the main GUI thread by a messaging synchronisation.
This way the main GUI can update the whole control in one go, and I think Freeze / Thaw can help you with postponing the paint events.
A tree class structure is easily made, as you only need 3-4 classes, and an array definition that points to the base class.
Returning a complete structure for the GUI component to be updated might give you a speed gain.
- Jorgen
What I would do, is update a tree hiararchy in the thread that is responsible for the classes and scanning (I do not know how that is done in C::B) once you are done with gathering info, send the tree in total to the main GUI thread by a messaging synchronisation.
This way the main GUI can update the whole control in one go, and I think Freeze / Thaw can help you with postponing the paint events.
A tree class structure is easily made, as you only need 3-4 classes, and an array definition that points to the base class.
Code: Select all
class treebase
{
// basic functions and info for the name, count etc
};
class treeitem: public treebase
{
// functions for the children that are not recursive
};
class treenode: public treebase
{
// functions for the nodes
private:
vector<treebase *> m_items;
}
class treeroot: public treenode
{
// special functions to populate
}
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
good luck! and happy new year!
- Jorgen
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb