From 99d3a4f4d25384a661d0cd371e96ca8bea2ca5bb Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 17 Feb 2014 23:53:20 +0000 Subject: [PATCH] Speed up wxHtmlHelpWindow startup time by freezing font choices. Appending the names of all fonts could take a significant amount of time if there were a lot of them, freeze the controls while doing it to speed it up. Closes #15978. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75907 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/html/helpwnd.cpp | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/html/helpwnd.cpp b/src/html/helpwnd.cpp index ef91722efd..131375b07c 100644 --- a/src/html/helpwnd.cpp +++ b/src/html/helpwnd.cpp @@ -55,6 +55,7 @@ #include "wx/fontenum.h" #include "wx/artprov.h" #include "wx/spinctrl.h" +#include "wx/wupdlock.h" // what is considered "small index"? #define INDEX_IS_SMALL 1000 @@ -1340,18 +1341,26 @@ void wxHtmlHelpWindow::OptionsDialog() m_FixedFace = fnt.GetFaceName(); } - for (i = 0; i < m_NormalFonts->GetCount(); i++) - dlg.NormalFont->Append((*m_NormalFonts)[i]); - for (i = 0; i < m_FixedFonts->GetCount(); i++) - dlg.FixedFont->Append((*m_FixedFonts)[i]); - if (!m_NormalFace.empty()) - dlg.NormalFont->SetStringSelection(m_NormalFace); - else - dlg.NormalFont->SetSelection(0); - if (!m_FixedFace.empty()) - dlg.FixedFont->SetStringSelection(m_FixedFace); - else - dlg.FixedFont->SetSelection(0); + // Lock updates to the choice controls before inserting potentially many + // items into them until the end of this block. + { + wxWindowUpdateLocker lockNormalFont(dlg.NormalFont); + wxWindowUpdateLocker lockFixedFont(dlg.FixedFont); + + for (i = 0; i < m_NormalFonts->GetCount(); i++) + dlg.NormalFont->Append((*m_NormalFonts)[i]); + for (i = 0; i < m_FixedFonts->GetCount(); i++) + dlg.FixedFont->Append((*m_FixedFonts)[i]); + if (!m_NormalFace.empty()) + dlg.NormalFont->SetStringSelection(m_NormalFace); + else + dlg.NormalFont->SetSelection(0); + if (!m_FixedFace.empty()) + dlg.FixedFont->SetStringSelection(m_FixedFace); + else + dlg.FixedFont->SetSelection(0); + } + dlg.FontSize->SetValue(m_FontSize); dlg.UpdateTestWin();