浏览代码

LibGUI: Complain in SortingProxyModel::data() if map_to_target() fails

There is some sort of issue with using a SortingProxyModel together
with ColumnsView. This is a workaround to allow FilePicker to use a
MultiView for now, but this needs to be fixed separately somehow.
Andreas Kling 5 年之前
父节点
当前提交
2ad405c789
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      Libraries/LibGUI/SortingProxyModel.cpp

+ 5 - 0
Libraries/LibGUI/SortingProxyModel.cpp

@@ -81,6 +81,11 @@ Model::ColumnMetadata SortingProxyModel::column_metadata(int index) const
 
 
 Variant SortingProxyModel::data(const ModelIndex& index, Role role) const
 Variant SortingProxyModel::data(const ModelIndex& index, Role role) const
 {
 {
+    auto target_index = map_to_target(index);
+    if (!target_index.is_valid()) {
+        dbg() << "BUG! SortingProxyModel: Unable to convert " << index << " to target";
+        return {};
+    }
     return target().data(map_to_target(index), role);
     return target().data(map_to_target(index), role);
 }
 }