Correct wxWindowQt::DoSetSize() for possible NULL member de-reference.

Thanks David Register

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78376 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Mariano Reingart
2015-01-19 02:18:02 +00:00
parent 6f2bd40a81
commit 98c49c9cc5

View File

@@ -422,7 +422,7 @@ void wxWindowQt::Refresh( bool WXUNUSED( eraseBackground ), const wxRect *rect )
}
}
bool wxWindowQt::SetFont( const wxFont &font )
{
// SetFont may be called before Create, so the font is stored
@@ -544,7 +544,7 @@ void wxWindowQt::SetScrollbar( int orientation, int pos, int thumbvisible, int r
scrollBar->GetHandle()->setEnabled( false );
}
else
scrollBar->GetHandle()->setEnabled( true );
scrollBar->GetHandle()->setEnabled( true );
}
}
@@ -560,7 +560,7 @@ int wxWindowQt::GetScrollPos( int orientation ) const
{
wxScrollBar *scrollBar = QtGetScrollBar( orientation );
wxCHECK_MSG( scrollBar, 0, "Invalid scrollbar" );
return scrollBar->GetThumbPosition();
}
@@ -568,7 +568,7 @@ int wxWindowQt::GetScrollThumb( int orientation ) const
{
wxScrollBar *scrollBar = QtGetScrollBar( orientation );
wxCHECK_MSG( scrollBar, 0, "Invalid scrollbar" );
return scrollBar->GetThumbSize();
}
@@ -576,7 +576,7 @@ int wxWindowQt::GetScrollRange( int orientation ) const
{
wxScrollBar *scrollBar = QtGetScrollBar( orientation );
wxCHECK_MSG( scrollBar, 0, "Invalid scrollbar" );
return scrollBar->GetRange();
}
@@ -627,7 +627,7 @@ void wxWindowQt::ScrollWindow( int dx, int dy, const wxRect *rect )
else
widget->scroll( dx, dy );
}
void wxWindowQt::SetDropTarget( wxDropTarget * WXUNUSED( dropTarget ) )
{
@@ -637,7 +637,7 @@ void wxWindowQt::SetDropTarget( wxDropTarget * WXUNUSED( dropTarget ) )
void wxWindowQt::SetWindowStyleFlag( long style )
{
wxWindowBase::SetWindowStyleFlag( style );
// wxMISSING_IMPLEMENTATION( "wxWANTS_CHARS, wxTAB_TRAVERSAL" );
// // wxFULL_REPAINT_ON_RESIZE: Qt::WResizeNoErase (marked obsolete)
// // wxTRANSPARENT_WINDOW, wxCLIP_CHILDREN: Used in window for
@@ -771,14 +771,14 @@ void wxWindowQt::DoClientToScreen( int *x, int *y ) const
*y = screenPosition.y();
}
void wxWindowQt::DoScreenToClient( int *x, int *y ) const
{
QPoint clientPosition = GetHandle()->mapFromGlobal( QPoint( *x, *y ));
*x = clientPosition.x();
*y = clientPosition.y();
}
void wxWindowQt::DoCaptureMouse()
{
@@ -820,7 +820,7 @@ void wxWindowQt::DoGetSize(int *width, int *height) const
if (height) *height = rect.height();
}
void wxWindowQt::DoSetSize(int x, int y, int width, int height, int sizeFlags )
{
@@ -856,7 +856,7 @@ void wxWindowQt::DoSetSize(int x, int y, int width, int height, int sizeFlags )
// if a control is created with size of zero, it is set as hidden by qt
// if it is then resized, in some cases it remains hidden, so it
// needs to be shown here
if (!m_qtWindow->isVisible() && IsShown())
if (m_qtWindow && !m_qtWindow->isVisible() && IsShown())
m_qtWindow->show();
}
@@ -868,7 +868,7 @@ void wxWindowQt::DoGetClientSize(int *width, int *height) const
if (height) *height = geometry.height();
}
void wxWindowQt::DoSetClientSize(int width, int height)
{
QWidget *qtWidget = GetHandle();
@@ -891,7 +891,7 @@ void wxWindowQt::DoMoveWindow(int x, int y, int width, int height)
void wxWindowQt::DoSetToolTip( wxToolTip *tip )
{
wxWindowBase::DoSetToolTip( tip );
if ( tip != NULL )
GetHandle()->setToolTip( wxQtConvertString( tip->GetTip() ));
else
@@ -913,15 +913,15 @@ bool wxWindowQt::DoPopupMenu(wxMenu *menu, int x, int y)
void wxWindowQt::SetAcceleratorTable( const wxAcceleratorTable& accel )
{
wxWindowBase::SetAcceleratorTable( accel );
// Disable previously set accelerators
while ( !m_qtShortcuts.isEmpty() )
delete m_qtShortcuts.takeFirst();
// Create new shortcuts (use GetHandle() so all events inside
// the window are handled, not only in the container subwindow)
m_qtShortcuts = accel.ConvertShortcutTable( GetHandle() );
// Connect shortcuts to window
Q_FOREACH( QShortcut *s, m_qtShortcuts )
{
@@ -1132,7 +1132,7 @@ bool wxWindowQt::QtHandleWheelEvent ( QWidget *WXUNUSED( handler ), QWheelEvent
e.m_wheelRotation = event->delta();
e.m_linesPerAction = 3;
e.m_wheelDelta = 120;
return ProcessWindowEvent( e );
}
@@ -1152,7 +1152,7 @@ bool wxWindowQt::QtHandleKeyEvent ( QWidget *WXUNUSED( handler ), QKeyEvent *eve
* Return true to avoid Qt-processing of the event
* Instead, use the flag to indicate that it wasn't processed */
m_processingShortcut = false;
return true;
}
#endif // wxUSE_ACCEL
@@ -1168,7 +1168,7 @@ bool wxWindowQt::QtHandleKeyEvent ( QWidget *WXUNUSED( handler ), QKeyEvent *eve
e.m_uniChar = 0;
else
e.m_uniChar = event->text().at( 0 ).unicode();
e.m_rawCode = event->nativeVirtualKey();
e.m_rawFlags = event->nativeModifiers();
@@ -1189,12 +1189,12 @@ bool wxWindowQt::QtHandleKeyEvent ( QWidget *WXUNUSED( handler ), QKeyEvent *eve
* to this function. We use the m_processingShortcut flag to avoid
* processing that recursive call and return back to this one. */
m_processingShortcut = true;
QApplication::instance()->notify( GetHandle(), event );
handled = m_processingShortcut;
m_processingShortcut = false;
if ( handled )
return true;
}
@@ -1208,10 +1208,10 @@ bool wxWindowQt::QtHandleKeyEvent ( QWidget *WXUNUSED( handler ), QKeyEvent *eve
translated = event->text().at( 0 ).toLatin1();
if ( translated )
e.m_keyCode = translated;
handled = ProcessWindowEvent( e );
}
return handled;
}
@@ -1318,7 +1318,7 @@ bool wxWindowQt::QtHandleMouseEvent ( QWidget *handler, QMouseEvent *event )
if ( mousePos.x() < 0 || mousePos.x() > handler->width() ||
mousePos.y() < 0 || mousePos.y() > handler->height() )
mouseInside = false;
if ( e.GetEventType() == wxEVT_MOTION )
{
/* Qt doesn't emit leave/enter events while the mouse is grabbed
@@ -1339,7 +1339,7 @@ bool wxWindowQt::QtHandleMouseEvent ( QWidget *handler, QMouseEvent *event )
}
m_mouseInside = mouseInside;
return handled;
}
@@ -1348,13 +1348,13 @@ bool wxWindowQt::QtHandleEnterEvent ( QWidget *handler, QEvent *event )
wxMouseEvent e( event->type() == QEvent::Enter ? wxEVT_ENTER_WINDOW : wxEVT_LEAVE_WINDOW );
e.m_clickCount = 0;
e.SetPosition( wxQtConvertPoint( handler->mapFromGlobal( QCursor::pos() ) ) );
// Mouse buttons
wxQtFillMouseButtons( QApplication::mouseButtons(), &e );
// Keyboard modifiers
wxQtFillKeyboardModifiers( QApplication::keyboardModifiers(), &e );
return ProcessWindowEvent( e );
}
@@ -1362,7 +1362,7 @@ bool wxWindowQt::QtHandleMoveEvent ( QWidget *handler, QMoveEvent *event )
{
if ( GetHandle() != handler )
return false;
wxMoveEvent e( wxQtConvertPoint( event->pos() ) );
return ProcessWindowEvent( e );
@@ -1372,7 +1372,7 @@ bool wxWindowQt::QtHandleShowEvent ( QWidget *handler, QEvent *event )
{
if ( GetHandle() != handler )
return false;
wxShowEvent e;
e.SetShow( event->type() == QEvent::Show );
@@ -1398,7 +1398,7 @@ bool wxWindowQt::QtHandleCloseEvent ( QWidget *handler, QCloseEvent *WXUNUSED( e
{
if ( GetHandle() != handler )
return false;
int close = Close();
if ( close )
{
@@ -1411,7 +1411,7 @@ bool wxWindowQt::QtHandleContextMenuEvent ( QWidget *WXUNUSED( handler ), QConte
{
wxContextMenuEvent e( wxEVT_CONTEXT_MENU );
e.SetPosition( wxQtConvertPoint( event->globalPos() ) );
return ProcessWindowEvent( e );
}
@@ -1427,7 +1427,7 @@ bool wxWindowQt::QtHandleFocusEvent ( QWidget *WXUNUSED( handler ), QFocusEvent
wxChildFocusEvent childEvent( this );
parent->ProcessWindowEvent( childEvent );
}
return handled;
}
@@ -1438,7 +1438,7 @@ void wxWindowQt::QtHandleShortcut ( int command )
{
wxCommandEvent menu_event( wxEVT_COMMAND_MENU_SELECTED, command );
bool ret = ProcessWindowEvent( menu_event );
if ( !ret )
{
// if the accelerator wasn't handled as menu event, try