Skip to content

Commit be905c0

Browse files
committed
Only apply contrasting foreground colour if there is a background colour
1 parent 62e7ccd commit be905c0

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

qrenderdoc/Widgets/Extended/RDTreeView.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -774,9 +774,15 @@ void RDTreeView::drawBranches(QPainter *painter, const QRect &rect, const QModel
774774
opt.rect = allLinesRect;
775775
opt.showDecorationSelected = true;
776776
opt.backgroundBrush = index.data(Qt::BackgroundRole).value<QBrush>();
777-
QColor foreCol = index.data(Qt::ForegroundRole).value<QBrush>().color();
778-
opt.palette.setColor(QPalette::Foreground, foreCol);
779-
opt.palette.setColor(QPalette::Text, foreCol);
777+
QVariant foreColVar = index.data(Qt::ForegroundRole);
778+
QColor foreCol;
779+
780+
if(foreColVar.isValid())
781+
{
782+
foreCol = foreColVar.value<QBrush>().color();
783+
opt.palette.setColor(QPalette::Foreground, foreCol);
784+
opt.palette.setColor(QPalette::Text, foreCol);
785+
}
780786

781787
style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, this);
782788

@@ -786,7 +792,8 @@ void RDTreeView::drawBranches(QPainter *painter, const QRect &rect, const QModel
786792
{
787793
// set the desired colour for RDTweakedNativeStyle via a huge hack - see
788794
// RDTweakedNativeStyle::drawPrimitive for QStyle::PE_IndicatorBranch
789-
painter->setPen(QPen(foreCol, 1234.5));
795+
if(foreColVar.isValid())
796+
painter->setPen(QPen(foreCol, 1234.5));
790797
QTreeView::drawBranches(painter, rect, index);
791798
}
792799
else

0 commit comments

Comments
 (0)