]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/wincmn.cpp
Don't crash when input is empty in wxFileConfig(wxInputStream) ctor.
[wxWidgets.git] / src / common / wincmn.cpp
index 27a560c9b9e6953200998a08b20353b4f082c2ec..a9c2b445052faca8af1bf66ab75890a21edf02f3 100644 (file)
@@ -245,7 +245,7 @@ bool wxWindowBase::CreateBase(wxWindowBase *parent,
     // does not as the user should be able to resize the window)
     //
     // note that we can't use IsTopLevel() from ctor
-    if ( !wxTopLevelWindows.Find((wxWindow *)this) )
+    if ( size != wxDefaultSize && !wxTopLevelWindows.Find((wxWindow *)this) )
         SetMinSize(size);
 
     SetName(name);
@@ -322,6 +322,12 @@ wxWindowBase::~wxWindowBase()
     // we weren't a dialog class
     wxTopLevelWindows.DeleteObject((wxWindow*)this);
 
+    // Any additional event handlers should be popped before the window is
+    // deleted as otherwise the last handler will be left with a dangling
+    // pointer to this window result in a difficult to diagnose crash later on.
+    wxASSERT_MSG( GetEventHandler() == this,
+                    wxT("any pushed event handlers must have been removed") );
+
 #if wxUSE_MENUS
     // The associated popup menu can still be alive, disassociate from it in
     // this case
@@ -1359,7 +1365,7 @@ wxColour wxWindowBase::GetBackgroundColour() const
         wxColour colBg = GetDefaultAttributes().colBg;
 
         // we must return some valid colour to avoid redoing this every time
-        // and also to avoid surprizing the applications written for older
+        // and also to avoid surprising the applications written for older
         // wxWidgets versions where GetBackgroundColour() always returned
         // something -- so give them something even if it doesn't make sense
         // for this window (e.g. it has a themed background)
@@ -2455,28 +2461,24 @@ void wxWindowBase::DoUpdateWindowUI(wxUpdateUIEvent& event)
 // dialog units translations
 // ----------------------------------------------------------------------------
 
-wxPoint wxWindowBase::ConvertPixelsToDialog(const wxPoint& pt)
+wxPoint wxWindowBase::ConvertPixelsToDialog(const wxPoint& pt) const
 {
-    int charWidth = GetCharWidth();
-    int charHeight = GetCharHeight();
     wxPoint pt2 = wxDefaultPosition;
     if (pt.x != wxDefaultCoord)
-        pt2.x = (int) ((pt.x * 4) / charWidth);
+        pt2.x = (int) ((pt.x * 4) / GetCharWidth());
     if (pt.y != wxDefaultCoord)
-        pt2.y = (int) ((pt.y * 8) / charHeight);
+        pt2.y = (int) ((pt.y * 8) / GetCharHeight());
 
     return pt2;
 }
 
-wxPoint wxWindowBase::ConvertDialogToPixels(const wxPoint& pt)
+wxPoint wxWindowBase::ConvertDialogToPixels(const wxPoint& pt) const
 {
-    int charWidth = GetCharWidth();
-    int charHeight = GetCharHeight();
     wxPoint pt2 = wxDefaultPosition;
     if (pt.x != wxDefaultCoord)
-        pt2.x = (int) ((pt.x * charWidth) / 4);
+        pt2.x = (int) ((pt.x * GetCharWidth()) / 4);
     if (pt.y != wxDefaultCoord)
-        pt2.y = (int) ((pt.y * charHeight) / 8);
+        pt2.y = (int) ((pt.y * GetCharHeight()) / 8);
 
     return pt2;
 }