avoid null pointer dereference in DoGetClientSize

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41139 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett
2006-09-10 20:50:58 +00:00
parent fe92a9d685
commit c1fa6f5245

View File

@@ -10,40 +10,23 @@
// For compilers that support precompilation, includes "wx.h". // For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h" #include "wx/wxprec.h"
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/frame.h" #include "wx/frame.h"
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/dcclient.h"
#include "wx/menu.h" #include "wx/menu.h"
#include "wx/dialog.h"
#include "wx/control.h"
#include "wx/toolbar.h" #include "wx/toolbar.h"
#include "wx/statusbr.h" #include "wx/statusbr.h"
#endif // WX_PRECOMP #endif // WX_PRECOMP
#include <glib.h>
#include "wx/gtk/private.h" #include "wx/gtk/private.h"
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkx.h>
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// constants // constants
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
const int wxSTATUS_HEIGHT = 25; static const int wxSTATUS_HEIGHT = 25;
const int wxPLACE_HOLDER = 0; static const int wxPLACE_HOLDER = 0;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// event tables // event tables
@@ -252,33 +235,39 @@ void wxFrame::DoGetClientSize( int *width, int *height ) const
if (m_frameStatusBar && m_frameStatusBar->IsShown()) if (m_frameStatusBar && m_frameStatusBar->IsShown())
(*height) -= wxSTATUS_HEIGHT; (*height) -= wxSTATUS_HEIGHT;
#endif // wxUSE_STATUSBAR #endif // wxUSE_STATUSBAR
}
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
// tool bar // tool bar
if (m_frameToolBar && m_frameToolBar->IsShown()) if (m_frameToolBar && m_frameToolBar->IsShown())
{
if (m_toolBarDetached)
{ {
if (m_toolBarDetached) if (height != NULL)
{
*height -= wxPLACE_HOLDER; *height -= wxPLACE_HOLDER;
}
else
{
int x, y;
m_frameToolBar->GetSize( &x, &y );
if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL )
{
if (width != NULL)
*width -= x;
} }
else else
{ {
int x, y; if (height != NULL)
m_frameToolBar->GetSize( &x, &y );
if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL )
{
*width -= x;
}
else
{
*height -= y; *height -= y;
}
} }
} }
#endif // wxUSE_TOOLBAR
if (*height < 0)
*height = 0;
} }
#endif // wxUSE_TOOLBAR
if (width != NULL && *width < 0)
*width = 0;
if (height != NULL && *height < 0)
*height = 0;
} }
void wxFrame::DoSetClientSize( int width, int height ) void wxFrame::DoSetClientSize( int width, int height )