• R/O
  • SSH
  • HTTPS

tortoisesvn: Commit


Commit MetaInfo

Revision28319 (tree)
Time2018-07-27 03:25:21
Authorcsware

Log Message

Use local copy for adjusting PROPSHEETPAGE

Based on TortoiseGit commit 0ffb9e042545441de1ce28707ceeda5e63e2e1d3.

Change Summary

Incremental Difference

--- trunk/ext/TreePropSheet/TreePropSheet.h (revision 28318)
+++ trunk/ext/TreePropSheet/TreePropSheet.h (revision 28319)
@@ -414,16 +414,31 @@
414414 {
415415 CPropertySheet::BuildPropPageArray();
416416
417- LPCPROPSHEETPAGE ppsp = m_psh.ppsp;
418- auto nSize = m_pages.GetSize();
419- for (decltype(nSize) nPage = 0; nPage < nSize; nPage++)
417+ // create a copy of existing PROPSHEETPAGE array which can be modified
418+ int nPages = static_cast<int>(m_pages.GetSize());
419+ int nBytes = 0;
420+ for (decltype(nPages) i = 0; i < nPages; ++i)
420421 {
422+ auto pPage = GetPage(i);
423+ nBytes += pPage->m_psp.dwSize;
424+ }
425+ auto ppsp0 = static_cast<LPPROPSHEETPAGE>(malloc(nBytes));
426+ Checked::memcpy_s(ppsp0, nBytes, m_psh.ppsp, nBytes);
427+ auto ppsp = ppsp0;
428+ for (decltype(nPages) i = 0; i < nPages; ++i)
429+ {
421430 const DLGTEMPLATE* pResource = ppsp->pResource;
422431 CDialogTemplate dlgTemplate(pResource);
423432 dlgTemplate.SetFont(L"MS Shell Dlg 2", 9);
424- memmove((void*)pResource, dlgTemplate.m_hTemplate, dlgTemplate.m_dwTemplateSize);
433+ HGLOBAL hNew = GlobalAlloc(GPTR, dlgTemplate.m_dwTemplateSize);
434+ ppsp->pResource = (DLGTEMPLATE*)GlobalLock(hNew);
435+ Checked::memcpy_s((void*)ppsp->pResource, dlgTemplate.m_dwTemplateSize, dlgTemplate.m_hTemplate, dlgTemplate.m_dwTemplateSize);
436+ GlobalUnlock(hNew);
425437 (BYTE*&)ppsp += ppsp->dwSize;
426438 }
439+ // free existing PROPSHEETPAGE array and assign the new one
440+ free((void*)m_psh.ppsp);
441+ m_psh.ppsp = ppsp0;
427442 }
428443 //}}AFX_VIRTUAL
429444
--- trunk/ext/ResizableLib/ResizableSheetEx.h (revision 28318)
+++ trunk/ext/ResizableLib/ResizableSheetEx.h (revision 28319)
@@ -112,16 +112,31 @@
112112 {
113113 CPropertySheet::BuildPropPageArray();
114114
115- LPCPROPSHEETPAGE ppsp = m_psh.ppsp;
116- auto nSize = m_pages.GetSize();
117- for (decltype(nSize) nPage = 0; nPage < nSize; nPage++)
115+ // create a copy of existing PROPSHEETPAGE array which can be modified
116+ int nPages = static_cast<int>(m_pages.GetSize());
117+ int nBytes = 0;
118+ for (decltype(nPages) i = 0; i < nPages; ++i)
118119 {
120+ auto pPage = GetPage(i);
121+ nBytes += pPage->m_psp.dwSize;
122+ }
123+ auto ppsp0 = static_cast<LPPROPSHEETPAGE>(malloc(nBytes));
124+ Checked::memcpy_s(ppsp0, nBytes, m_psh.ppsp, nBytes);
125+ auto ppsp = ppsp0;
126+ for (decltype(nPages) i = 0; i < nPages; ++i)
127+ {
119128 const DLGTEMPLATE* pResource = ppsp->pResource;
120129 CDialogTemplate dlgTemplate(pResource);
121130 dlgTemplate.SetFont(L"MS Shell Dlg 2", 9);
122- memmove((void*)pResource, dlgTemplate.m_hTemplate, dlgTemplate.m_dwTemplateSize);
131+ HGLOBAL hNew = GlobalAlloc(GPTR, dlgTemplate.m_dwTemplateSize);
132+ ppsp->pResource = (DLGTEMPLATE*)GlobalLock(hNew);
133+ Checked::memcpy_s((void*)ppsp->pResource, dlgTemplate.m_dwTemplateSize, dlgTemplate.m_hTemplate, dlgTemplate.m_dwTemplateSize);
134+ GlobalUnlock(hNew);
123135 (BYTE*&)ppsp += ppsp->dwSize;
124136 }
137+ // free existing PROPSHEETPAGE array and assign the new one
138+ free((void*)m_psh.ppsp);
139+ m_psh.ppsp = ppsp0;
125140 }
126141
127142 virtual CWnd* GetResizableWnd() const
--- trunk/src/TortoiseMerge/Settings.h (revision 28318)
+++ trunk/src/TortoiseMerge/Settings.h (revision 28319)
@@ -50,16 +50,31 @@
5050 {
5151 CPropertySheet::BuildPropPageArray();
5252
53- LPCPROPSHEETPAGE ppsp = m_psh.ppsp;
54- auto nSize = m_pages.GetSize();
55- for (decltype(nSize) nPage = 0; nPage < nSize; nPage++)
53+ // create a copy of existing PROPSHEETPAGE array which can be modified
54+ int nPages = static_cast<int>(m_pages.GetSize());
55+ int nBytes = 0;
56+ for (decltype(nPages) i = 0; i < nPages; ++i)
5657 {
58+ auto pPage = GetPage(i);
59+ nBytes += pPage->m_psp.dwSize;
60+ }
61+ auto ppsp0 = static_cast<LPPROPSHEETPAGE>(malloc(nBytes));
62+ Checked::memcpy_s(ppsp0, nBytes, m_psh.ppsp, nBytes);
63+ auto ppsp = ppsp0;
64+ for (decltype(nPages) i = 0; i < nPages; ++i)
65+ {
5766 const DLGTEMPLATE* pResource = ppsp->pResource;
5867 CDialogTemplate dlgTemplate(pResource);
5968 dlgTemplate.SetFont(L"MS Shell Dlg 2", 9);
60- memmove((void*)pResource, dlgTemplate.m_hTemplate, dlgTemplate.m_dwTemplateSize);
69+ HGLOBAL hNew = GlobalAlloc(GPTR, dlgTemplate.m_dwTemplateSize);
70+ ppsp->pResource = (DLGTEMPLATE*)GlobalLock(hNew);
71+ Checked::memcpy_s((void*)ppsp->pResource, dlgTemplate.m_dwTemplateSize, dlgTemplate.m_hTemplate, dlgTemplate.m_dwTemplateSize);
72+ GlobalUnlock(hNew);
6173 (BYTE*&)ppsp += ppsp->dwSize;
6274 }
75+ // free existing PROPSHEETPAGE array and assign the new one
76+ free((void*)m_psh.ppsp);
77+ m_psh.ppsp = ppsp0;
6378 }
6479 private:
6580 CSetMainPage * m_pMainPage;
Show on old repository browser