Sped up HistoryWindow updating by eliminating duplicate clearing and refilling the wxListCtrl. In the worst case, where the window had not yet been created, it would clear and refill the same content in the list 3 times. Otherwise it would always do it 2 times.

The only call to Show for HistoryWindow is in AudacityProject::OnHistory, and it always calls HistoryWindow::UpdateDisplay. All HistoryWindow::UpdateDisplay does is check IsShown() and if so, call HistoryWindow::DoUpdate. 

Removed the call to HistoryWindow::DoUpdate in the constructor because AudacityProject::OnHistory will get that done. 

Removed HistoryWindow::OnShow. No reason to implement it outside the normal wxDialog::Show() mechanism, and all it did was call HistoryWindow::UpdateDisplay (and then AudacityProject::OnHistory would do that again).

Didn't see any other reasons it has been slow, as it's just getting the state names and sizes from the stack, not actually examining anything about the states. It probably doesn't really need to clear the list and repopulate it every time, but let's see if this gives sufficient improvement before adding a lot of mechanisms for tracking exactly what needs to change.
This commit is contained in:
v.audacity 2010-07-30 21:47:25 +00:00
parent 3729f067be
commit 62689e9e70
3 changed files with 5 additions and 24 deletions

View File

@ -42,7 +42,6 @@ enum {
};
BEGIN_EVENT_TABLE(HistoryWindow, wxDialog)
EVT_SHOW(HistoryWindow::OnShow)
EVT_SIZE(HistoryWindow::OnSize)
EVT_CLOSE(HistoryWindow::OnCloseWindow)
EVT_LIST_ITEM_SELECTED(wxID_ANY, HistoryWindow::OnItemSelected)
@ -116,7 +115,9 @@ HistoryWindow::HistoryWindow(AudacityProject *parent, UndoManager *manager):
S.EndVerticalLay();
// ----------------------- End of main section --------------
DoUpdate();
// Vaughan, 2010-07-30: AudacityProject::OnHistory always calls Show() then
// HistoryWindow::UpdateDisplay, so no need to do it here.
// DoUpdate();
mList->SetMinSize(mList->GetSize());
Fit();
SetMinSize(GetSize());
@ -237,26 +238,8 @@ void HistoryWindow::OnSize(wxSizeEvent & event)
mList->EnsureVisible(mSelected);
}
void HistoryWindow::OnShow(wxShowEvent & event)
{
if (event.GetShow())
UpdateDisplay();
}
void HistoryWindow::OnChar(wxKeyEvent &event)
{
event.Skip(false);
return;
}
// Indentation settings for Vim and Emacs and unique identifier for Arch, a
// version control system. Please do not modify past this point.
//
// Local Variables:
// c-basic-offset: 3
// indent-tabs-mode: nil
// End:
//
// vim: et sts=3 sw=3
// arch-tag: a32dc48c-50da-4cda-90a6-b5aa4fd7673e

View File

@ -35,7 +35,6 @@ class HistoryWindow :public wxDialog {
void DoUpdate();
void UpdateLevels();
void OnShow(wxShowEvent & event);
void OnSize(wxSizeEvent & event);
void OnCloseWindow(wxCloseEvent & WXUNUSED(event));
void OnChar(wxKeyEvent & event);

View File

@ -4360,8 +4360,8 @@ void AudacityProject::OnHistory()
{
if (!mHistoryWindow)
mHistoryWindow = new HistoryWindow(this, &mUndoManager);
mHistoryWindow->Show(true);
mHistoryWindow->Show();
mHistoryWindow->Raise();
mHistoryWindow->UpdateDisplay();
}
@ -4369,7 +4369,6 @@ void AudacityProject::OnKaraoke()
{
if (!mLyricsWindow)
mLyricsWindow = new LyricsWindow(this);
wxASSERT(mLyricsWindow);
mLyricsWindow->Show();
mLyricsWindow->Raise();
}