A working patch (fix some bugs in kipade' original patch), it seems to work, I don't see time lags (browser tree even set to show everything in a sample wx3.0 prj).
src/plugins/codecompletion/BuildTreeEvent.h | 66 ++++++++++++++++++++++
src/plugins/codecompletion/classbrowser.cpp | 18 ++++++
src/plugins/codecompletion/classbrowser.h | 3 +
.../codecompletion/classbrowserbuilderthread.cpp | 14 ++++-
.../codecompletion/classbrowserbuilderthread.h | 1 +
5 files changed, 99 insertions(+), 3 deletions(-)
diff --git a/src/plugins/codecompletion/BuildTreeEvent.h b/src/plugins/codecompletion/BuildTreeEvent.h
new file mode 100644
index 0000000..73d0b1a
--- /dev/null
+++ b/src/plugins/codecompletion/BuildTreeEvent.h
@@ -0,0 +1,66 @@
+#ifndef __BUILD_TREE_H__
+#define __BUILD_TREE_H__
+
+/*
+ * Simple BuildTree event for ClassBrowser
+ *
+ * Author: ZhiYu
+ */
+
+#include <wx/event.h>
+#include "classbrowserbuilderthread.h"
+
+extern const wxEventType cbBUILD_CLASSTREE_EVENT;
+// the below does not work, see:
+// http://permalink.gmane.org/gmane.comp.lib.wxwindows.general/62431
+//DECLARE_EVENT_TYPE(cbBUILD_CLASSTREE_EVENT, wxID_ANY)
+
+class cbBuildTreeEvent : public wxCommandEvent
+{
+public:
+ cbBuildTreeEvent(ClassBrowserBuilderThread* builderThreadObject = NULL,
+ wxEventType cmdType = cbBUILD_CLASSTREE_EVENT)
+ :wxCommandEvent(cmdType),
+ clsBuilderThread(builderThreadObject)
+ {
+ }
+
+ cbBuildTreeEvent(const cbBuildTreeEvent& rhs)
+ : wxCommandEvent(rhs),
+ clsBuilderThread(rhs.clsBuilderThread)
+
+ {
+ }
+
+ ClassBrowserBuilderThread* GetBuilderThreadObject() const
+ {
+ return clsBuilderThread;
+ }
+ virtual wxEvent *Clone() const
+ {
+ return new cbBuildTreeEvent(*this);
+ }
+//private:
+ ClassBrowserBuilderThread* clsBuilderThread;
+ DECLARE_DYNAMIC_CLASS( cbBuildTreeEvent )
+};
+
+//following lines are only for you if you did not like use event table
+
+typedef void (wxEvtHandler::*cbBuildTreeFunction)(cbBuildTreeEvent&);
+
+
+#define cbBuildTreeEventHandler(func) \
+ (wxObjectEventFunction)(wxEventFunction) \
+ wxStaticCastEvent(cbBuildTreeFunction, &func)
+
+
+
+#define EVT_CBBUILD_CLASSTREE(id, fn) \
+ DECLARE_EVENT_TABLE_ENTRY(cbBUILD_CLASSTREE_EVENT, id, wxID_ANY, \
+ (wxObjectEventFunction) (wxEventFunction) (cbBuildTreeFunction) \
+ wxStaticCastEvent( cbBuildTreeFunction, & fn ), (wxObject *) NULL ),
+
+
+
+#endif
diff --git a/src/plugins/codecompletion/classbrowser.cpp b/src/plugins/codecompletion/classbrowser.cpp
index cd96467..498113d 100644
--- a/src/plugins/codecompletion/classbrowser.cpp
+++ b/src/plugins/codecompletion/classbrowser.cpp
@@ -44,6 +44,7 @@
#include "nativeparser.h"
#include "parser/ccdebuginfo.h"
+#include <stdio.h>
#define CC_CLASS_BROWSER_DEBUG_OUTPUT 0
@@ -76,6 +77,15 @@
#define TRACE2(format, args...)
#endif
+// below is used on wx3.x only
+//wxDEFINE_EVENT(cbBUILD_CLASSTREE_EVENT,cbBuildTreeEvent);
+
+IMPLEMENT_DYNAMIC_CLASS(cbBuildTreeEvent, wxCommandEvent)
+DEFINE_EVENT_TYPE(cbBUILD_CLASSTREE_EVENT)
+
+
+
+
int idMenuJumpToDeclaration = wxNewId();
int idMenuJumpToImplementation = wxNewId();
int idMenuRefreshTree = wxNewId();
@@ -127,6 +137,7 @@ BEGIN_EVENT_TABLE(ClassBrowser, wxPanel)
EVT_MENU(idCBBottomTree, ClassBrowser::OnCBViewMode)
EVT_COMMAND(idThreadEvent, wxEVT_COMMAND_ENTER, ClassBrowser::OnThreadEvent)
+ EVT_CBBUILD_CLASSTREE(wxID_ANY,ClassBrowser::OnBuileTree)
END_EVENT_TABLE()
// class constructor
@@ -971,3 +982,10 @@ void ClassBrowser::OnThreadEvent(wxCommandEvent& event)
break;
}
}
+
+void ClassBrowser::OnBuileTree(cbBuildTreeEvent& event)
+{
+ ClassBrowserBuilderThread* thread = event.GetBuilderThreadObject();
+ if(thread)
+ thread->BuildTree();
+}
diff --git a/src/plugins/codecompletion/classbrowser.h b/src/plugins/codecompletion/classbrowser.h
index 9715c07..1a272c7 100644
--- a/src/plugins/codecompletion/classbrowser.h
+++ b/src/plugins/codecompletion/classbrowser.h
@@ -16,6 +16,7 @@
#include "classbrowserbuilderthread.h"
#include "parser/parser.h"
#include "parser/token.h"
+#include "BuildTreeEvent.h"
class NativeParser;
class wxComboBox;
@@ -90,6 +91,8 @@ private:
void OnDebugSmartSense(wxCommandEvent& event);
void OnSetSortType(wxCommandEvent& event);
+ void OnBuileTree(cbBuildTreeEvent& event);
+
void OnSearch(wxCommandEvent& event);
bool FoundMatch(const wxString& search, wxTreeCtrl* tree, const wxTreeItemId& item);
wxTreeItemId FindNext(const wxString& search, wxTreeCtrl* tree, const wxTreeItemId& start);
diff --git a/src/plugins/codecompletion/classbrowserbuilderthread.cpp b/src/plugins/codecompletion/classbrowserbuilderthread.cpp
index 24f05cb..5b74337 100644
--- a/src/plugins/codecompletion/classbrowserbuilderthread.cpp
+++ b/src/plugins/codecompletion/classbrowserbuilderthread.cpp
@@ -26,11 +26,12 @@
#include <projectmanager.h>
#endif
+#include "BuildTreeEvent.h"
#include "classbrowserbuilderthread.h"
// sanity check for the build tree functions, this function should only be called in a worker thread
// also, there should be no termination requested, otherwise, it will return false
-#define CBBT_SANITY_CHECK ((!::wxIsMainThread() && m_TerminationRequested) || Manager::IsAppShuttingDown())
+#define CBBT_SANITY_CHECK (( m_TerminationRequested) || Manager::IsAppShuttingDown())
#define CC_BUILDERTHREAD_DEBUG_OUTPUT 0
@@ -63,6 +64,8 @@
#define TRACE2(format, args...)
#endif
+#include "BuildTreeEvent.h"
+
ClassBrowserBuilderThread::ClassBrowserBuilderThread(wxEvtHandler* evtHandler, wxSemaphore& sem) :
wxThread(wxTHREAD_JOINABLE),
m_Parent(evtHandler),
@@ -184,7 +187,7 @@ void ClassBrowserBuilderThread::Init(NativeParser* np,
}
// Thread function
-
+#include <stdio.h>
void* ClassBrowserBuilderThread::Entry()
{
while (!m_TerminationRequested && !Manager::IsAppShuttingDown() )
@@ -206,7 +209,10 @@ void* ClassBrowserBuilderThread::Entry()
::wxMutexGuiEnter();
}
- BuildTree();
+ //BuildTree();
+ cbBuildTreeEvent evt(this,cbBUILD_CLASSTREE_EVENT);
+ if(m_Parent)
+ m_Parent->AddPendingEvent(evt);
if (platform::gtk || platform::macosx)
{
@@ -447,6 +453,8 @@ void ClassBrowserBuilderThread::BuildTree()
// 6.) Hide&Freeze trees shown
if (m_BrowserOptions.treeMembers)
{
+ if(m_CCTreeCtrlBottom==NULL)
+ wxMessageBox(wxT("kcynice:classbrowserbuilderthread.cpp::BuildTree m_CCTreeCtrlBottom is null"));
m_CCTreeCtrlBottom->Hide();
m_CCTreeCtrlBottom->Freeze();
}
diff --git a/src/plugins/codecompletion/classbrowserbuilderthread.h b/src/plugins/codecompletion/classbrowserbuilderthread.h
index 9369a27..3acfcb8 100644
--- a/src/plugins/codecompletion/classbrowserbuilderthread.h
+++ b/src/plugins/codecompletion/classbrowserbuilderthread.h
@@ -20,6 +20,7 @@
*/
class ClassBrowserBuilderThread : public wxThread
{
+ friend class ClassBrowser;
public:
/** the builder threads' event sent to the GUI(class browser window)*/
enum EThreadEvent