添加widget判空处理

This commit is contained in:
tanjing 2024-04-16 16:49:56 +08:00
parent 3d541d67bc
commit 853dd45e9e
1 changed files with 9 additions and 6 deletions

View File

@ -1221,6 +1221,8 @@ void UKUIConfigStyle::unpolish(QWidget *widget)
}
}
if(!widget)
return;
m_shadow_helper->unregisterWidget(widget);
widget->removeEventFilter(this);
@ -1479,7 +1481,8 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty
painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
painter->setBrush(sp->m_MenuParameters.menuBackgroundBrush);
painter->setPen(sp->m_MenuParameters.menuBackgroundPen);
painter->drawRoundedRect(widget->rect(), sp->m_MenuParameters.frameRadius, sp->m_MenuParameters.frameRadius);
if(widget)
painter->drawRoundedRect(widget->rect(), sp->m_MenuParameters.frameRadius, sp->m_MenuParameters.frameRadius);
painter->restore();
if(sp->Menu_Right_Bottom_Corner){
@ -4563,7 +4566,7 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp
animator->startAnimator("groove_width");
}
}
if(widget->isEnabled())
if(widget && widget->isEnabled())
len = animator->value("groove_width").toReal() * 4 * sp->m_scaleRatio2_1 + 4;
else
len = 4;
@ -4856,7 +4859,7 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp
if (iconRect.isValid()) {
if(sp->getAdjustColorRules() == UKUIConfigStyleParameters::AdjustColorRules::HSL &&
inactive && useTransparentButtonList().contains(qAppName()) &&
inactive && useTransparentButtonList().contains(qAppName()) && widget &&
widget->property("isWindowButton").isValid() &&
(widget->property("isWindowButton").toInt() == 0x01 ||
widget->property("isWindowButton").toInt() == 0x02)) {
@ -5770,7 +5773,7 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp
if (const QStyleOptionToolBox *tb = qstyleoption_cast<const QStyleOptionToolBox *>(option)) {
painter->save();
painter->setPen(Qt::NoPen);
if(widget->isEnabled()){
if(widget && widget->isEnabled()){
painter->setBrush(tb->palette.button().color());
if(option->state & State_MouseOver)
{
@ -7263,7 +7266,7 @@ QRect UKUIConfigStyle::subElementRect(SubElement element, const QStyleOption *op
if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
bool clear = false;
if (widget) {
if (qobject_cast<QComboBox *>(widget->parent()))
if (widget->parent() && qobject_cast<QComboBox *>(widget->parent()))
{
return option->rect;
}
@ -7548,7 +7551,7 @@ QSize UKUIConfigStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt
newSize.setWidth(qMin(newSize.width(), sp->TabBar_DefaultMaxWidth));
}
if (qobject_cast<const QTabBar*>(widget)) {
if (widget && qobject_cast<const QTabBar*>(widget)) {
//set height between min and max
newSize.setHeight(qMax(newSize.height(), widget->minimumHeight()));
newSize.setHeight(qMin(newSize.height(), widget->maximumHeight()));