From: Markus R. <rol...@us...> - 2007-06-23 14:30:01
|
Update of /cvsroot/simspark/simspark/contrib/rsgedit In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv18278 Modified Files: sparkedit.cpp sparkedit.h Log Message: - it's a bug to statically store the index of a tab within the notebook. This index can change after dragging or closing tabs at runtime Index: sparkedit.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/sparkedit.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sparkedit.cpp 23 Jun 2007 13:36:28 -0000 1.2 --- sparkedit.cpp 23 Jun 2007 14:29:58 -0000 1.3 *************** *** 87,95 **** { wxScintilla* edit = (*iter).first; - if (select) { ! notebook->SetSelection(entry.page); ! edit->SetFocus(); } --- 87,93 ---- { wxScintilla* edit = (*iter).first; if (select) { ! SelectEdit(notebook, edit); } *************** *** 117,121 **** } - entry.page = static_cast<int>(notebook->GetPageCount() - 1); mEditMap[edit] = entry; --- 115,118 ---- *************** *** 278,282 **** } ! void SparkEdit::UpdateIcon(wxFlatNotebook* notebook, const wxScintilla* edit, const EditEntry& entry) { if ( --- 275,279 ---- } ! void SparkEdit::UpdateIcon(wxFlatNotebook* notebook, wxScintilla* edit, const EditEntry& entry) { if ( *************** *** 289,294 **** } ! notebook->SetPageImageIndex(entry.page, -1); ! notebook->SetPageImageIndex(entry.page, GetImageIndex(edit, entry)); } --- 286,297 ---- } ! int page = notebook->GetPageIndex(edit); ! if (page < 0) ! { ! assert(false); ! return; ! } ! ! notebook->SetPageImageIndex(page, GetImageIndex(edit, entry)); } *************** *** 302,312 **** for ( ! TEditMap::const_iterator iter = mEditMap.begin(); iter != mEditMap.end(); ++iter ) { ! const EditEntry& entry = (*iter).second; ! const wxScintilla* edit = (*iter).first; UpdateIcon(notebook, edit, entry); } --- 305,315 ---- for ( ! TEditMap::iterator iter = mEditMap.begin(); iter != mEditMap.end(); ++iter ) { ! EditEntry& entry = (*iter).second; ! wxScintilla* edit = (*iter).first; UpdateIcon(notebook, edit, entry); } *************** *** 340,345 **** } const EditEntry& entry = (*iter).second; ! notebook->SetPageText(entry.page, GetTitle(edit, entry)); } --- 343,355 ---- } + int page = notebook->GetPageIndex(edit); + if (page < 0) + { + assert(false); + return; + } + const EditEntry& entry = (*iter).second; ! notebook->SetPageText(page, GetTitle(edit, entry)); } *************** *** 440,452 **** } ! TEditMap::iterator iter = mEditMap.find(edit); ! if (iter == mEditMap.end()) ! { ! assert(false); ! return; ! } ! const EditEntry& entry = (*iter).second; ! notebook->SetSelection(entry.page); edit->SetFocus(); } --- 450,461 ---- } ! int page = notebook->GetPageIndex(edit); ! if (page < 0) ! { ! assert(false); ! return; ! } ! notebook->SetSelection(page); edit->SetFocus(); } Index: sparkedit.h =================================================================== RCS file: /cvsroot/simspark/simspark/contrib/rsgedit/sparkedit.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sparkedit.h 23 Jun 2007 13:36:28 -0000 1.2 --- sparkedit.h 23 Jun 2007 14:29:58 -0000 1.3 *************** *** 53,61 **** EEditType type; wxString fname; - int page; public: EditEntry() ! : type(ET_RSG), page(-1) { } --- 53,60 ---- EEditType type; wxString fname; public: EditEntry() ! : type(ET_RSG) { } *************** *** 86,90 **** static wxString GetTitle(wxScintilla* edit, const EditEntry& entry); ! static void UpdateIcon(wxFlatNotebook* notebook, const wxScintilla* edit, const EditEntry& entry); static int GetImageIndex(const wxScintilla* edit, const EditEntry& entry); --- 85,89 ---- static wxString GetTitle(wxScintilla* edit, const EditEntry& entry); ! static void UpdateIcon(wxFlatNotebook* notebook, wxScintilla* edit, const EditEntry& entry); static int GetImageIndex(const wxScintilla* edit, const EditEntry& entry); |