QGIM: check that row is valid also in flags()
While we never access the data, accessing a MultiColumn item holding a nullptr would still dereference that nullptr, and then pass that reference to our lambda. And the results are misleading: if there is no gadget or object stored for that row yet, then the item is not editable - nothing can be stored. Change-Id: Ic24242296f8cdedae6e36a12da470831eb93ee2a Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
This commit is contained in:
parent
e9dbc016e1
commit
2332f827c5
@ -240,13 +240,19 @@ public:
|
|||||||
// we didn't remove the const of the range first.
|
// we didn't remove the const of the range first.
|
||||||
const_row_reference row = rowData(index);
|
const_row_reference row = rowData(index);
|
||||||
row_reference mutableRow = const_cast<row_reference>(row);
|
row_reference mutableRow = const_cast<row_reference>(row);
|
||||||
for_element_at(mutableRow, index.column(), [&f](auto &&ref){
|
if (QGenericItemModelDetails::isValid(mutableRow)) {
|
||||||
using target_type = decltype(ref);
|
for_element_at(mutableRow, index.column(), [&f](auto &&ref){
|
||||||
if constexpr (std::is_const_v<std::remove_reference_t<target_type>>)
|
using target_type = decltype(ref);
|
||||||
f &= ~Qt::ItemIsEditable;
|
if constexpr (std::is_const_v<std::remove_reference_t<target_type>>)
|
||||||
else if constexpr (std::is_lvalue_reference_v<target_type>)
|
f &= ~Qt::ItemIsEditable;
|
||||||
f |= Qt::ItemIsEditable;
|
else if constexpr (std::is_lvalue_reference_v<target_type>)
|
||||||
});
|
f |= Qt::ItemIsEditable;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// If there's no usable value stored in the row, then we can't
|
||||||
|
// do anything with this item.
|
||||||
|
f &= ~Qt::ItemIsEditable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user