From 059831534c7e884f0a607ed86b582fd00d821731 Mon Sep 17 00:00:00 2001 From: Christoph Berg Date: Sat, 26 Sep 2026 23:24:03 +0200 Subject: New upstream version 3.2.0~rc1+dfsg --- widgets/DecodeHighlightingListView.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'widgets/DecodeHighlightingListView.cpp') diff --git a/widgets/DecodeHighlightingListView.cpp b/widgets/DecodeHighlightingListView.cpp index cfb14fc5..2997017a 100644 --- a/widgets/DecodeHighlightingListView.cpp +++ b/widgets/DecodeHighlightingListView.cpp @@ -15,6 +15,10 @@ DecodeHighlightingListView::DecodeHighlightingListView (QWidget * parent) addAction (fg_colour_action); connect (fg_colour_action, &QAction::triggered, [this] (bool /*checked*/) { auto const& index = currentIndex (); + if (!model () || !index.isValid ()) + { + return; + } auto colour = QColorDialog::getColor (model ()->data (index, Qt::ForegroundRole).value ().color () , this , tr ("Choose %1 Foreground Color") @@ -28,13 +32,21 @@ DecodeHighlightingListView::DecodeHighlightingListView (QWidget * parent) auto * unset_fg_colour_action = new QAction {tr ("&Unset foreground color"), this}; addAction (unset_fg_colour_action); connect (unset_fg_colour_action, &QAction::triggered, [this] (bool /*checked*/) { - model ()->setData (currentIndex (), QBrush {}, Qt::ForegroundRole); + auto const& index = currentIndex (); + if (model () && index.isValid ()) + { + model ()->setData (index, QBrush {}, Qt::ForegroundRole); + } }); auto * bg_colour_action = new QAction {tr ("&Background color ..."), this}; addAction (bg_colour_action); connect (bg_colour_action, &QAction::triggered, [this] (bool /*checked*/) { auto const& index = currentIndex (); + if (!model () || !index.isValid ()) + { + return; + } auto colour = QColorDialog::getColor (model ()->data (index, Qt::BackgroundRole).value ().color () , this , tr ("Choose %1 Background Color") @@ -48,13 +60,21 @@ DecodeHighlightingListView::DecodeHighlightingListView (QWidget * parent) auto * unset_bg_colour_action = new QAction {tr ("U&nset background color"), this}; addAction (unset_bg_colour_action); connect (unset_bg_colour_action, &QAction::triggered, [this] (bool /*checked*/) { - model ()->setData (currentIndex (), QBrush {}, Qt::BackgroundRole); + auto const& index = currentIndex (); + if (model () && index.isValid ()) + { + model ()->setData (index, QBrush {}, Qt::BackgroundRole); + } }); auto * defaults_action = new QAction {tr ("&Reset this item to defaults"), this}; addAction (defaults_action); connect (defaults_action, &QAction::triggered, [this] (bool /*checked*/) { auto const& index = currentIndex (); + if (!model () || !index.isValid ()) + { + return; + } model ()->setData (index, model ()->data (index, DecodeHighlightingModel::EnabledDefaultRole).toBool () ? Qt::Checked : Qt::Unchecked, Qt::CheckStateRole); model ()->setData (index, model ()->data (index, DecodeHighlightingModel::ForegroundDefaultRole), Qt::ForegroundRole); model ()->setData (index, model ()->data (index, DecodeHighlightingModel::BackgroundDefaultRole), Qt::BackgroundRole); -- cgit v1.2.3