From caa08938e5c9bd399ce5bd69e09aed506d963eb4 Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Fri, 10 Jan 2020 18:48:27 +0300 Subject: [PATCH] LibGUI: Fix GModel::is_valid() behavior for tree-like models --- Libraries/LibGUI/GModel.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Libraries/LibGUI/GModel.h b/Libraries/LibGUI/GModel.h index b0adb39289..c241cd23fc 100644 --- a/Libraries/LibGUI/GModel.h +++ b/Libraries/LibGUI/GModel.h @@ -60,7 +60,8 @@ public: 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; }