From 5c9e012d5bc40544ad42e28154ca9b9d620f9959 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Tue, 10 Dec 2013 02:48:49 -0800 Subject: [PATCH] MGR: Prevent zero-size window in a rare situation where registry values have accidentally been set to zero --- clientgui/BOINCGUIApp.cpp | 3 +++ clientgui/DlgEventLog.cpp | 3 +++ clientgui/DlgItemProperties.cpp | 4 ++++ clientgui/sg_DlgMessages.cpp | 4 ++++ 4 files changed, 14 insertions(+) diff --git a/clientgui/BOINCGUIApp.cpp b/clientgui/BOINCGUIApp.cpp index 5593728fcb..097bf04bfe 100644 --- a/clientgui/BOINCGUIApp.cpp +++ b/clientgui/BOINCGUIApp.cpp @@ -984,6 +984,9 @@ bool CBOINCGUIApp::SetActiveGUI(int iGUISelection, bool bShowWindow) { m_pConfig->Read(wxT("XPos"), &iLeft, 30); m_pConfig->Read(wxT("Width"), &iWidth, 800); m_pConfig->Read(wxT("Height"), &iHeight, 600); + // Guard against a rare situation where registry values are zero + if (iWidth < 50) iWidth = 800; + if (iHeight < 50) iHeight = 600; } else { m_pConfig->SetPath(wxT("/Simple")); m_pConfig->Read(wxT("YPos"), &iTop, 30); diff --git a/clientgui/DlgEventLog.cpp b/clientgui/DlgEventLog.cpp index d1756eb81c..440907a58c 100644 --- a/clientgui/DlgEventLog.cpp +++ b/clientgui/DlgEventLog.cpp @@ -763,6 +763,9 @@ void CDlgEventLog::GetWindowDimensions( wxPoint& position, wxSize& size ) { pConfig->Read(wxT("Width"), &iWidth, 640); pConfig->Read(wxT("Height"), &iHeight, 480); + // Guard against a rare situation where registry values are zero + if (iWidth < 50) iWidth = 640; + if (iHeight < 50) iHeight = 480; position.y = iTop; position.x = iLeft; size.x = iWidth; diff --git a/clientgui/DlgItemProperties.cpp b/clientgui/DlgItemProperties.cpp index b33e3d784a..bf572a018e 100644 --- a/clientgui/DlgItemProperties.cpp +++ b/clientgui/DlgItemProperties.cpp @@ -129,6 +129,10 @@ bool CDlgItemProperties::RestoreState() { pConfig->Read(wxT("Width"), &iWidth, wxDefaultCoord); pConfig->Read(wxT("Height"), &iHeight, wxDefaultCoord); + // Guard against a rare situation where registry values are zero + if ((iWidth < 50) && (iWidth != wxDefaultCoord)) iWidth = wxDefaultCoord; + if ((iHeight < 50) && (iHeight != wxDefaultCoord)) iHeight = wxDefaultCoord; + #ifndef __WXMAC__ // Set size to saved values or defaults if no saved values SetSize(iWidth, iHeight); diff --git a/clientgui/sg_DlgMessages.cpp b/clientgui/sg_DlgMessages.cpp index 5c3f15cc65..f9b584f614 100644 --- a/clientgui/sg_DlgMessages.cpp +++ b/clientgui/sg_DlgMessages.cpp @@ -597,6 +597,10 @@ void CDlgMessages::RestoreWindowDimensions() { pConfig->Read(wxT("WindowIconized"), &bWindowIconized, false); pConfig->Read(wxT("WindowMaximized"), &bWindowMaximized, false); + // Guard against a rare situation where registry values are zero + if (iWidth < 50) iWidth = 640; + if (iHeight < 50) iHeight = 480; + #ifndef __WXMAC__ // If either co-ordinate is less then 0 then set it equal to 0 to ensure