Kaydet (Commit) c2cb5f47 authored tarafından Herbert Dürr's avatar Herbert Dürr Kaydeden (comit) Caolán McNamara

Related: #i112873# check native widget's control value type...

before converting to SpinbuttonValue or ScrollbarValue

Else problems like #i112873# or even crashes can and do happen.

(cherry picked from commit d2fde1d3)

Conflicts:
	vcl/unx/kde/salnativewidgets-kde.cxx

Change-Id: I6429205ab41b3194577bc50aa02384c920e11ed2
üst 064457db
......@@ -805,7 +805,7 @@ sal_Bool AquaSalGraphics::drawNativeControl(ControlType nType,
case CTRL_SCROLLBAR:
{
ScrollbarValue* pScrollbarVal = (ScrollbarValue *)&aValue;
const ScrollbarValue* pScrollbarVal = (aValue.getType() == CTRL_SCROLLBAR) ? static_cast<const ScrollbarValue*>(&aValue) : NULL;
if( nPart == PART_DRAW_BACKGROUND_VERT ||
nPart == PART_DRAW_BACKGROUND_HORZ )
......@@ -1025,16 +1025,13 @@ sal_Bool AquaSalGraphics::drawNativeControl(ControlType nType,
if(nState & CTRL_STATE_FOCUSED) HIThemeDrawFocusRect(&rc, true, mrContext, kHIThemeOrientationNormal);
//buttons:
SpinbuttonValue* pSpinButtonVal = (SpinbuttonValue *)&aValue;
const SpinbuttonValue* pSpinButtonVal = (aValue.getType() == CTRL_SPINBUTTONS) ? static_cast<const SpinbuttonValue*>(&aValue) : NULL;
ControlState nUpperState = CTRL_STATE_ENABLED;//state of the upper button
ControlState nLowerState = CTRL_STATE_ENABLED;//and of the lower button
if(pSpinButtonVal) {//pSpinButtonVal is sometimes null
nUpperState = (ControlState) pSpinButtonVal->mnUpperState;
nLowerState = (ControlState) pSpinButtonVal->mnLowerState;
}
if( pSpinButtonVal )
{
HIThemeButtonDrawInfo aSpinInfo;
aSpinInfo.kind = kThemeIncDecButton;
aSpinInfo.state = kThemeStateActive;
......
......@@ -1749,7 +1749,7 @@ sal_Bool GtkSalGraphics::NWPaintGTKScrollbar( ControlType, ControlPart nPart,
const OUString& )
{
OSL_ASSERT( aValue.getType() == CTRL_SCROLLBAR );
const ScrollbarValue* pScrollbarVal = static_cast<const ScrollbarValue *>(&aValue);
const ScrollbarValue* pScrollbarVal = (aValue.getType() == CTRL_SCROLLBAR) ? static_cast<const ScrollbarValue*>(&aValue) : NULL;
GdkPixmap* pixmap = NULL;
Rectangle pixmapRect, scrollbarRect;
GtkStateType stateType;
......
......@@ -559,7 +559,7 @@ sal_Bool WidgetPainter::drawStyledWidget( QWidget *pWidget,
}
else if ( strcmp( QSpinWidget_String, pClassName ) == 0 )
{
const SpinbuttonValue *pValue = static_cast<const SpinbuttonValue *> ( &aValue );
const SpinbuttonValue* pValue = (aValue.getType() == CTRL_SPINBUTTONS) ? static_cast<const SpinbuttonValue*>(&aValue) : NULL;
// Is any of the buttons pressed?
QStyle::SCFlags eActive = QStyle::SC_None;
......@@ -648,7 +648,7 @@ sal_Bool WidgetPainter::drawStyledWidget( QWidget *pWidget,
}
else if ( strcmp( QScrollBar_String, pClassName ) == 0 )
{
const ScrollbarValue *pValue = static_cast<const ScrollbarValue *> ( &aValue );
const ScrollbarValue* pScrollbarVal = (aValue.getType() == CTRL_SCROLLBAR) ? static_cast<const ScrollbarValue*>(&aValue) : NULL;
QStyle::SCFlags eActive = QStyle::SC_None;
if ( pValue )
......@@ -1052,7 +1052,7 @@ QScrollBar *WidgetPainter::scrollBar( const Rectangle& rControlRegion,
m_pScrollBar->resize( qRect.size() );
m_pScrollBar->setOrientation( bHorizontal? Qt::Horizontal: Qt::Vertical );
const ScrollbarValue *pValue = static_cast<const ScrollbarValue *> ( &aValue );
const ScrollbarValue* pScrollbarVal = (aValue.getType() == CTRL_SCROLLBAR) ? static_cast<const ScrollbarValue*>(&aValue) : NULL;
if ( pValue )
{
m_pScrollBar->setMinValue( pValue->mnMin );
......
......@@ -650,7 +650,7 @@ sal_Bool ImplDrawNativeControl( HDC hDC, HTHEME hTheme, RECT rc,
{
if( aValue.getType() == CTRL_SPINBUTTONS )
{
const SpinbuttonValue *pValue = static_cast<const SpinbuttonValue*>(&aValue);
const SpinbuttonValue* pValue = (aValue.getType() == CTRL_SPINBUTTONS) ? static_cast<const SpinbuttonValue*>(&aValue) : NULL;
sal_Bool bOk = sal_False;
RECT rect;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment