Patch #2886 2009-12-27 21:51
techy
Fixes for browsetracker (debug14)- Download
- 2886-Fixes_for_brow.patch (2.3 KB)
Index: src/plugins/contrib/BrowseTracker/BrowseTracker.cpp
===================================================================
--- src/plugins/contrib/BrowseTracker/BrowseTracker.cpp (revision 5986)
+++ src/plugins/contrib/BrowseTracker/BrowseTracker.cpp (working copy)
@@ -215,8 +215,7 @@
m_InitDone = false;
m_CurrEditorIndex = 0;
m_LastEditorIndex = MaxEntries-1;
- m_apEditors.Alloc(MaxEntries);
- for (int i=0; i<MaxEntries ; ++i ) m_apEditors[i] = 0;
+ m_apEditors.SetCount(MaxEntries, 0);
m_nBrowsedEditorCount = 0;
m_UpdateUIFocusEditor = 0;
m_nRemoveEditorSentry = 0;
@@ -504,11 +503,11 @@
int menuId = item->GetId();
wxString menuLabel = item->GetLabel();
///LOGIT( _T("BT OnContextMenu insert[%s]"),menuLabel.c_str() );
- wxMenuItem* pContextItem= new wxMenuItem(0, menuId, menuLabel);
+ wxMenuItem* pContextItem= new wxMenuItem(sub_menu, menuId, menuLabel);
sub_menu->Append( pContextItem );
}
popup->AppendSeparator();
- pbtMenuItem = new wxMenuItem(0, wxID_ANY, _("Browse Tracker"), _T(""), wxITEM_NORMAL);
+ pbtMenuItem = new wxMenuItem(sub_menu, wxID_ANY, _("Browse Tracker"), _T(""), wxITEM_NORMAL);
pbtMenuItem->SetSubMenu(sub_menu);
popup->Append(pbtMenuItem);
@@ -2181,7 +2180,7 @@
tmpArray.Alloc(MaxEntries);
// copy current editors & clear for compression
for (int i = 0; i<MaxEntries; ++i)
- { tmpArray[i] = m_apEditors[i];
+ { tmpArray.Add(m_apEditors[i]);
m_apEditors[i] = 0;
}//for
m_CurrEditorIndex = 0;
Index: src/plugins/contrib/BrowseTracker/BrowseMarks.cpp
===================================================================
--- src/plugins/contrib/BrowseTracker/BrowseMarks.cpp (revision 5986)
+++ src/plugins/contrib/BrowseTracker/BrowseMarks.cpp (working copy)
@@ -65,9 +65,7 @@
//LOGIT( _T("BT BrowseMarks[%s][%s]"),m_filePath.c_str() ,m_fileShortName.c_str() );
//#endif
- m_EdPosnArray.Alloc(MaxEntries);
- for (int i=0; i < MaxEntries; ++i )
- m_EdPosnArray[i] = -1;
+ m_EdPosnArray.SetCount(MaxEntries, -1);
m_currIndex = 0; //index of current entry
m_lastIndex = MaxEntries-1; //index for insertion of new browse marks
m_pEdMgr = Manager::Get()->GetEditorManager();
History
The problems in browsetracker are a result of misunderstanding of what the method Alloc() of wxArray does - it only preallocates enough memory (to prevent reallocations of the memory space) but it _doesn't_ change the size of the array. So if you call Alloc(1000) and then GetCount(), the result will be 0. So either you have to Alloc the space and then Add your elements, or call SetCount() which allocates the memory _and_ adds the elements with some default value (both methods used in the patch).
(this is the last patch of the series)
Forgot to mention one more problem - elements of the popup window didn't have the parent window set.
I leave this open and un-assigned for the (active) maintainer of this plugin to take action. If nothing happens for a while, drop me a note (just a comment here).
Of interest to Pecan.
Applied. Svn 6179
Thanks