forked from qt-creator/qt-creator
Fix crash in ManhattanStyle
The widget can be a nullptr. const bool isComboBox = widget->inherits("QComboBox"); Was crashing in the iso icon browser. Task-number: QDS-3079 Change-Id: Ie7efa08ff5be094b94a835db895929158918bfcf Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -431,7 +431,7 @@ static void drawPrimitiveTweakedForDarkTheme(QStyle::PrimitiveElement element,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QStyle::PE_FrameLineEdit: {
|
case QStyle::PE_FrameLineEdit: {
|
||||||
const bool isComboBox = widget->inherits("QComboBox");
|
const bool isComboBox = widget && widget->inherits("QComboBox");
|
||||||
const QRectF frameRectF =
|
const QRectF frameRectF =
|
||||||
QRectF(option->rect).adjusted(0.5, 0.5, isComboBox ? -8.5 : -0.5, -0.5);
|
QRectF(option->rect).adjusted(0.5, 0.5, isComboBox ? -8.5 : -0.5, -0.5);
|
||||||
painter->setPen(framePen);
|
painter->setPen(framePen);
|
||||||
@@ -447,7 +447,8 @@ static void drawPrimitiveTweakedForDarkTheme(QStyle::PrimitiveElement element,
|
|||||||
// Shrinking the topMargin if Not checkable AND title is empty
|
// Shrinking the topMargin if Not checkable AND title is empty
|
||||||
topMargin = groupBoxTopMargin;
|
topMargin = groupBoxTopMargin;
|
||||||
} else {
|
} else {
|
||||||
topMargin = qMax(widget->style()->pixelMetric(QStyle::PM_ExclusiveIndicatorHeight),
|
const int exclusiveIndicatorHeight = widget ? widget->style()->pixelMetric(QStyle::PM_ExclusiveIndicatorHeight) : 0;
|
||||||
|
topMargin = qMax(exclusiveIndicatorHeight,
|
||||||
option->fontMetrics.height()) + groupBoxTopMargin;
|
option->fontMetrics.height()) + groupBoxTopMargin;
|
||||||
}
|
}
|
||||||
// Snippet from QFusionStyle::drawPrimitive - END
|
// Snippet from QFusionStyle::drawPrimitive - END
|
||||||
@@ -505,15 +506,16 @@ static void drawPrimitiveTweakedForDarkTheme(QStyle::PrimitiveElement element,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case QStyle::PE_IndicatorTabClose: {
|
case QStyle::PE_IndicatorTabClose: {
|
||||||
QWindow *window = widget->window()->windowHandle();
|
QWindow *window = widget ? widget->window()->windowHandle() : nullptr;
|
||||||
QRect iconRect = QRect(0, 0, 16, 16);
|
QRect iconRect = QRect(0, 0, 16, 16);
|
||||||
iconRect.moveCenter(option->rect.center());
|
iconRect.moveCenter(option->rect.center());
|
||||||
const QIcon::Mode mode = !isEnabled ? QIcon::Disabled : QIcon::Normal;
|
const QIcon::Mode mode = !isEnabled ? QIcon::Disabled : QIcon::Normal;
|
||||||
const static QIcon closeIcon = Utils::Icons::CLOSE_FOREGROUND.icon();
|
const static QIcon closeIcon = Utils::Icons::CLOSE_FOREGROUND.icon();
|
||||||
if (option->state & QStyle::State_MouseOver)
|
if (option->state & QStyle::State_MouseOver && widget)
|
||||||
widget->style()->drawPrimitive(QStyle::PE_PanelButtonCommand, option, painter, widget);
|
widget->style()->drawPrimitive(QStyle::PE_PanelButtonCommand, option, painter, widget);
|
||||||
|
const int devicePixelRatio = widget ? widget->devicePixelRatio() : 1;
|
||||||
const QPixmap iconPx =
|
const QPixmap iconPx =
|
||||||
closeIcon.pixmap(window, iconRect.size() * widget->devicePixelRatio(), mode);
|
closeIcon.pixmap(window, iconRect.size() * devicePixelRatio, mode);
|
||||||
painter->drawPixmap(iconRect, iconPx);
|
painter->drawPixmap(iconRect, iconPx);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user