From 34f8ae85e0b0fe56910663d44355a33d02e89786 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 13 Dec 2016 15:43:17 +0100 Subject: [PATCH] Simplify wxPersistentTLW code and avoid warnings in it Use wxPoint and wxSize instead of individual "int" variables to make the code slightly shorter and avoid clang warnings about "y" and "h" being possibly uninitialized (which couldn't happen, but the compiler didn't understand it, at least in non-optimized builds). --- include/wx/persist/toplevel.h | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/include/wx/persist/toplevel.h b/include/wx/persist/toplevel.h index 9f33192dbf..31912b3801 100644 --- a/include/wx/persist/toplevel.h +++ b/include/wx/persist/toplevel.h @@ -79,14 +79,13 @@ public: { wxTopLevelWindow * const tlw = Get(); - int x wxDUMMY_INITIALIZE(-1), - y wxDUMMY_INITIALIZE(-1), - w wxDUMMY_INITIALIZE(-1), - h wxDUMMY_INITIALIZE(-1); - const bool hasPos = RestoreValue(wxPERSIST_TLW_X, &x) && - RestoreValue(wxPERSIST_TLW_Y, &y); - const bool hasSize = RestoreValue(wxPERSIST_TLW_W, &w) && - RestoreValue(wxPERSIST_TLW_H, &h); + wxPoint pos; + wxSize size; + + const bool hasPos = RestoreValue(wxPERSIST_TLW_X, &pos.x) && + RestoreValue(wxPERSIST_TLW_Y, &pos.y); + const bool hasSize = RestoreValue(wxPERSIST_TLW_W, &size.x) && + RestoreValue(wxPERSIST_TLW_H, &size.y); #ifdef __WXGTK20__ wxTopLevelWindowGTK::DecorSize decorSize; if (tlw->m_decorSize.top == 0 && @@ -108,17 +107,16 @@ public: // NB: we should allow window position to be (slightly) off screen, // it's not uncommon to position the window so that its upper // left corner has slightly negative coordinate - if ( wxDisplay::GetFromPoint(wxPoint(x, y)) != wxNOT_FOUND || - (hasSize && wxDisplay::GetFromPoint( - wxPoint(x + w, y + h)) != wxNOT_FOUND) ) + if ( wxDisplay::GetFromPoint(pos) != wxNOT_FOUND || + (hasSize && wxDisplay::GetFromPoint(pos + size) != wxNOT_FOUND) ) { - tlw->Move(x, y, wxSIZE_ALLOW_MINUS_ONE); + tlw->Move(pos, wxSIZE_ALLOW_MINUS_ONE); } //else: should we try to adjust position/size somehow? } if ( hasSize ) - tlw->SetSize(w, h); + tlw->SetSize(size); // note that the window can be both maximized and iconized bool maximized;