From 74255e8b30e486ce1f09a2f071815db6ef42c8ba Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Sat, 14 Jun 2014 16:04:24 +0200 Subject: [PATCH] Fixed issue #1951: Slow switch/checkout dialog Inspired by code provided by Yue Lin Ho. Signed-off-by: Sven Strickroth --- src/Changelog.txt | 2 +- src/TortoiseProc/BranchCombox.h | 7 +++---- src/TortoiseProc/ChooseVersion.h | 8 ++------ src/TortoiseProc/FormatPatchDlg.cpp | 4 ++-- src/TortoiseProc/RebaseDlg.cpp | 4 ++-- src/TortoiseProc/RefLogDlg.cpp | 4 ++-- src/Utils/MiscUI/HistoryCombo.cpp | 39 ++++++++++++++++++++++++++----------- src/Utils/MiscUI/HistoryCombo.h | 13 ++++++++++++- 8 files changed, 52 insertions(+), 29 deletions(-) diff --git a/src/Changelog.txt b/src/Changelog.txt index c0fcfe403..319449c0e 100644 --- a/src/Changelog.txt +++ b/src/Changelog.txt @@ -7,6 +7,7 @@ Released: unreleased == Bug Fixes == * Fixed issue #2216: Add fails with message: libgit2: "failed to parse 'warn' as boolean" * Fixed issue #2218: Tortoise Git Extra Backslash with SUBST Drive Paths + * Fixed issue #1951: Slow switch/checkout dialog = Release 1.8.9.0 = Released: 2014-06-09 @@ -125,7 +126,6 @@ Released: 2014-01-12 == Bug Fixes == * Fixed issue #1947: When editing git notes, spurious reformatting is done - * Fixed issue #1951: Slow switch/checkout dialog * Fixed issue #1958: Revision graph crashes when trying to switch/checkout via context menu * Fixed issue #1963: TortoiseGitMerge: Missing color config when an added line is changed * Fixed issue #1976: Commit log crashes if it receives a WM_PRINTCLIENT while opening diff --git a/src/TortoiseProc/BranchCombox.h b/src/TortoiseProc/BranchCombox.h index 2f5ad00ec..202cacb47 100644 --- a/src/TortoiseProc/BranchCombox.h +++ b/src/TortoiseProc/BranchCombox.h @@ -180,23 +180,22 @@ protected: STRING_VECTOR list; list.clear(); int current=0; - m_ctrlLocalBranch.Reset(); - m_ctrlRemoteBranch.Reset(); g_Git.GetBranchList(list,¤t,CGit::BRANCH_LOCAL_F); - m_ctrlLocalBranch.AddString(list); + m_ctrlLocalBranch.SetList(list); if(this->m_RegKeyRemoteBranch.IsEmpty()) { list.clear(); g_Git.GetBranchList(list, NULL, CGit::BRANCH_REMOTE); - m_ctrlRemoteBranch.AddString(list); + m_ctrlRemoteBranch.SetList(list); } else { + m_ctrlRemoteBranch.Reset(); m_ctrlRemoteBranch.LoadHistory(m_RegKeyRemoteBranch,_T("sync")); } diff --git a/src/TortoiseProc/ChooseVersion.h b/src/TortoiseProc/ChooseVersion.h index 707a139f2..6b6cb130f 100644 --- a/src/TortoiseProc/ChooseVersion.h +++ b/src/TortoiseProc/ChooseVersion.h @@ -192,16 +192,12 @@ protected: int current = -1; g_Git.GetBranchList(list,¤t,CGit::BRANCH_ALL_F); - for (int i = m_ChooseVersioinBranch.GetCount(); i >= 0; --i) - m_ChooseVersioinBranch.DeleteString(i); - m_ChooseVersioinBranch.AddString(list, false); + m_ChooseVersioinBranch.SetList(list); m_ChooseVersioinBranch.SetCurSel(current); list.clear(); g_Git.GetTagList(list); - for (int i = m_ChooseVersioinTags.GetCount(); i >= 0; --i) - m_ChooseVersioinTags.DeleteString(i); - m_ChooseVersioinTags.AddString(list, false); + m_ChooseVersioinTags.SetList(list); m_ChooseVersioinTags.SetCurSel(0); m_pWin->SendMessage(WM_GUIUPDATES); diff --git a/src/TortoiseProc/FormatPatchDlg.cpp b/src/TortoiseProc/FormatPatchDlg.cpp index da51c513b..8cd229e5f 100644 --- a/src/TortoiseProc/FormatPatchDlg.cpp +++ b/src/TortoiseProc/FormatPatchDlg.cpp @@ -1,6 +1,6 @@ // TortoiseGit - a Windows shell extension for easy version control -// Copyright (C) 2008-2013 - TortoiseGit +// Copyright (C) 2008-2014 - TortoiseGit // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -121,7 +121,7 @@ BOOL CFormatPatchDlg::OnInitDialog() STRING_VECTOR list; g_Git.GetBranchList(list,NULL,CGit::BRANCH_ALL_F); m_cSince.SetMaxHistoryItems((int)list.size()); - m_cSince.AddString(list); + m_cSince.SetList(list); if(!m_Since.IsEmpty()) m_cSince.SetWindowText(m_Since); diff --git a/src/TortoiseProc/RebaseDlg.cpp b/src/TortoiseProc/RebaseDlg.cpp index 5fd74008f..e7c1e692d 100644 --- a/src/TortoiseProc/RebaseDlg.cpp +++ b/src/TortoiseProc/RebaseDlg.cpp @@ -419,14 +419,14 @@ void CRebaseDlg::LoadBranchInfo() list.clear(); int current = -1; g_Git.GetBranchList(list,¤t,CGit::BRANCH_ALL); - m_BranchCtrl.AddString(list); + m_BranchCtrl.SetList(list); if (current >= 0) m_BranchCtrl.SetCurSel(current); else m_BranchCtrl.AddString(g_Git.GetCurrentBranch(true)); list.clear(); g_Git.GetBranchList(list, NULL, CGit::BRANCH_ALL_F); - m_UpstreamCtrl.AddString(list); + m_UpstreamCtrl.SetList(list); AddBranchToolTips(&m_BranchCtrl); AddBranchToolTips(&m_UpstreamCtrl); diff --git a/src/TortoiseProc/RefLogDlg.cpp b/src/TortoiseProc/RefLogDlg.cpp index 35c57ff47..0b745fb49 100644 --- a/src/TortoiseProc/RefLogDlg.cpp +++ b/src/TortoiseProc/RefLogDlg.cpp @@ -1,6 +1,6 @@ // TortoiseGit - a Windows shell extension for easy version control -// Copyright (C) 2009-2013 - TortoiseGit +// Copyright (C) 2009-2014 - TortoiseGit // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -308,7 +308,7 @@ void CRefLogDlg::Refresh() if (g_Git.GetRefList(list)) MessageBox(g_Git.GetGitLastErr(_T("Could not get all refs.")), _T("TortoiseGit"), MB_ICONERROR); - m_ChooseRef.AddString(list, 0); + m_ChooseRef.SetList(list); if (m_CurrentBranch.IsEmpty()) { diff --git a/src/Utils/MiscUI/HistoryCombo.cpp b/src/Utils/MiscUI/HistoryCombo.cpp index d465dc37c..02d85c7e1 100644 --- a/src/Utils/MiscUI/HistoryCombo.cpp +++ b/src/Utils/MiscUI/HistoryCombo.cpp @@ -147,8 +147,16 @@ int CHistoryCombo::AddString(const CString& str, INT_PTR pos /* = -1*/, BOOL isS m_arEntries.RemoveAt(m_nMaxHistoryItems); } - COMBOBOXEXITEM cbei; - SecureZeroMemory(&cbei, sizeof cbei); + int nRet = InsertEntry(combostring, pos); + + if (isSel) + SetCurSel(nRet); + return nRet; +} + +int CHistoryCombo::InsertEntry(const CString& combostring, INT_PTR pos) +{ + COMBOBOXEXITEM cbei = { 0 }; cbei.mask = CBEIF_TEXT; cbei.iItem = pos; @@ -192,11 +200,26 @@ int CHistoryCombo::AddString(const CString& str, INT_PTR pos /* = -1*/, BOOL isS if (nRet >= 0) m_arEntries.InsertAt(nRet, combostring); - if(isSel) - SetCurSel(nRet); return nRet; } +void CHistoryCombo::SetList(const STRING_VECTOR& list) +{ + Reset(); + for (int i = 0; i < list.size(); ++i) + { + CString combostring = list[i]; + combostring.Replace('\r', ' '); + combostring.Replace('\n', ' '); + if (m_bTrim) + combostring.Trim(); + if (combostring.IsEmpty()) + continue; + + InsertEntry(combostring, i); + } +} + CString CHistoryCombo::LoadHistory(LPCTSTR lpszSection, LPCTSTR lpszKeyPrefix) { if (lpszSection == NULL || lpszKeyPrefix == NULL || *lpszSection == '\0') @@ -392,13 +415,7 @@ void CHistoryCombo::SetMaxHistoryItems(int nMaxItems) for (int n = m_nMaxHistoryItems; n < nNumItems; n++) DeleteString(m_nMaxHistoryItems); } -void CHistoryCombo::AddString(STRING_VECTOR &list,BOOL isSel) -{ - for(unsigned int i=0;i