From b1332ad67c4e88e247ecbef94a24d5b1233b8630 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Fri, 1 May 2015 03:20:05 -0700 Subject: [PATCH] MGR: Fix some crash bugs in the code to hide or rearrange columns which can occur when changing locale to a different language. --- clientgui/BOINCListCtrl.cpp | 12 +++++++----- clientgui/ViewProjects.cpp | 2 +- clientgui/ViewTransfers.cpp | 2 +- clientgui/ViewWork.cpp | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/clientgui/BOINCListCtrl.cpp b/clientgui/BOINCListCtrl.cpp index c0a34cbbe1..f739ad3e70 100644 --- a/clientgui/BOINCListCtrl.cpp +++ b/clientgui/BOINCListCtrl.cpp @@ -230,6 +230,10 @@ bool CBOINCListCtrl::OnRestoreState(wxConfigBase* pConfig) { // If the user installed a new vesion of BOINC, new columns may have // been added that didn't exist in the older version. Check for this. + // + // This will also be triggered if the locale is changed, which will cause + // SetListColumnOrder() to be called again so the wxListCtrl will be set + // up with the correctly labeled columns. bool foundNewColumns = false; if (pConfig->Read(wxT("HiddenColumns"), &strHiddenColumns)) { @@ -273,9 +277,6 @@ bool CBOINCListCtrl::OnRestoreState(wxConfigBase* pConfig) { SetDefaultColumnDisplay(); } - - - if (m_pParentView->m_iSortColumnID != -1) { m_pParentView->InitSort(); @@ -351,9 +352,10 @@ void CBOINCListCtrl::SetListColumnOrder(wxArrayString& orderArray) { // // CBOINCListCtrl::OnRestoreState() may have incorrectly added the column names in // the new locale as "new" columns, so check against both shownColCount and stdCount. - if (columnIndex < wxMin(shownColCount, stdCount)) { + int limit = wxMin(shownColCount, stdCount); + if (columnIndex < limit) { SetStandardColumnOrder(); - for (columnID=0; columnIDAppendColumn(columnID); pView->m_iColumnIndexToColumnID.Add(columnID); diff --git a/clientgui/ViewProjects.cpp b/clientgui/ViewProjects.cpp index 20c64e5869..2d3569ac01 100644 --- a/clientgui/ViewProjects.cpp +++ b/clientgui/ViewProjects.cpp @@ -254,7 +254,7 @@ CViewProjects::CViewProjects(wxNotebook* pNotebook) : // Entries must be in order of ascending Column ID. We initalize // it here to the default column widths. It is updated by // CBOINCListCtrl::OnRestoreState() and also when a user resizes - // a column bby dragging the divider between two columns. + // a column by dragging the divider between two columns. // m_iStdColWidthOrder.Clear(); m_iStdColWidthOrder.Insert(150, COLUMN_PROJECT); diff --git a/clientgui/ViewTransfers.cpp b/clientgui/ViewTransfers.cpp index 8a0a9e6ddb..7373c9e0b8 100644 --- a/clientgui/ViewTransfers.cpp +++ b/clientgui/ViewTransfers.cpp @@ -218,7 +218,7 @@ CViewTransfers::CViewTransfers(wxNotebook* pNotebook) : // Entries must be in order of ascending Column ID. We initalize // it here to the default column widths. It is updated by // CBOINCListCtrl::OnRestoreState() and also when a user resizes - // a column bby dragging the divider between two columns. + // a column by dragging the divider between two columns. // m_iStdColWidthOrder.Clear(); m_iStdColWidthOrder.Insert(125, COLUMN_PROJECT); diff --git a/clientgui/ViewWork.cpp b/clientgui/ViewWork.cpp index 0d0324b195..f354029318 100644 --- a/clientgui/ViewWork.cpp +++ b/clientgui/ViewWork.cpp @@ -270,7 +270,7 @@ CViewWork::CViewWork(wxNotebook* pNotebook) : // Entries must be in order of ascending Column ID. We initalize // it here to the default column widths. It is updated by // CBOINCListCtrl::OnRestoreState() and also when a user resizes - // a column bby dragging the divider between two columns. + // a column by dragging the divider between two columns. // m_iStdColWidthOrder.Clear(); m_iStdColWidthOrder.Insert(125, COLUMN_PROJECT);