Browse Source

LibGUI: Fix GModel::is_valid() behavior for tree-like models

Sergey Bugaev 5 năm trước cách đây
mục cha
commit
caa08938e5
1 tập tin đã thay đổi với 2 bổ sung1 xóa
  1. 2 1
      Libraries/LibGUI/GModel.h

+ 2 - 1
Libraries/LibGUI/GModel.h

@@ -60,7 +60,8 @@ public:
 
 
     bool is_valid(const GModelIndex& index) const
     bool is_valid(const GModelIndex& index) const
     {
     {
-        return index.row() >= 0 && index.row() < row_count() && index.column() >= 0 && index.column() < column_count();
+        auto parent_index = this->parent_index(index);
+        return index.row() >= 0 && index.row() < row_count(parent_index) && index.column() >= 0 && index.column() < column_count(parent_index);
     }
     }
 
 
     virtual int key_column() const { return -1; }
     virtual int key_column() const { return -1; }