Patch #3302 2012-07-07 13:03
carjay
IncrementalSearch::OnAttach check for nonexisting menuitem- Download
- 3302-IncrementalSea.patch (1.1 KB)
diff --git a/src/plugins/contrib/IncrementalSearch/IncrementalSearch.cpp b/src/plugins/contrib/IncrementalSearch/IncrementalSearch.cpp
index 548cf52..ed348b2 100644
--- a/src/plugins/contrib/IncrementalSearch/IncrementalSearch.cpp
+++ b/src/plugins/contrib/IncrementalSearch/IncrementalSearch.cpp
@@ -96,7 +96,10 @@ void IncrementalSearch::OnAttach()
// (see: does not need) this plugin...
m_pEditor = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
wxMenuBar* mbar = Manager::Get()->GetAppFrame()->GetMenuBar();
- mbar->Enable(idIncSearchFocus, m_pEditor && m_pEditor->GetControl());
+ if (mbar->FindItem(idIncSearchFocus)) // if BuildMenu is called afterwards this may not exist yet
+ {
+ mbar->Enable(idIncSearchFocus, m_pEditor && m_pEditor->GetControl());
+ }
Manager::Get()->RegisterEventSink(cbEVT_EDITOR_ACTIVATED, new cbEventFunctor<IncrementalSearch, CodeBlocksEvent>(this, &IncrementalSearch::OnEditorEvent));
Manager::Get()->RegisterEventSink(cbEVT_EDITOR_DEACTIVATED, new cbEventFunctor<IncrementalSearch, CodeBlocksEvent>(this, &IncrementalSearch::OnEditorEvent));
History
carjay 2012-07-07 13:04
The IncrementalSearch plugin tries to enable an "idIncSearchFocus"-menuitem in its OnAttach()-function.
This menuitem is created in its BuildMenu()-function which is only called later so it does not exist yet.
Using a wxWidgets with debug asserts this causes an "../wxwidgets2.8-2.8.11.0/src/common/menucmn.cpp(1078): assert "item" failed in Enable(): attempt to enable an item which doesn't exist" assertion.
Since the code in question may be there for compatibility reasons (different historical call sequence?) I added a check for existence.
Of course this code can also be deleted completely if no longer necessary. BuildMenu will set this, too.
mortenmacfly 2012-07-17 14:16
Applied in SVN head. thanks!