On 18/02/2020 16.31, Konstantin Shegunov wrote:
> On Tue, Feb 18, 2020 at 11:20 PM Matthew Woehlke wrote:
>> I wonder if anyone else can spot it? ;-)
> 
> Without knowing anything about the code at all, my best guess based on a
> very quick glance would be the range for the dataChanged is wrong.

Okay, I'll give you half a cookie, since I can't really say much more
without giving it away. (Incidentally, if I hadn't already figured it
out, you comment probably would have helped!)

Here's the broken code:

  if (auto const rows = this->rowCount())
  {
    auto const& first = this->index(0, 0);
    auto const& last = this->index(rows, 0);

    emit this->dataChanged(first, last, {MyFilterRole});
  }

It fell victim to one of the two hard problems of programming (as
enumerated by Leon Bambrick¹). To wit, `last` is an invalid index, which
trips one of the sanity checks in QSortFilterProxyModel's internal logic.

If you can't tell *why* `last` is invalid, well, keep looking until you
can ;-). All the information you need to spot the problem is in the
above snippet, and it's *obvious* once you see it. (Note: assume that
the class otherwise behaves in a correct fashion.)

(¹ https://www.goodreads.com/quotes/7443069)

-- 
Matthew
_______________________________________________
Interest mailing list
[email protected]
https://lists.qt-project.org/listinfo/interest

Reply via email to