Please also try those other smoke unit tests.
I do not remember things detailed right now, but possibly
resetInternalData();resulted in lots of signal emitted due to rowinserted or something, which broke at least assumptions of the smoke test, but possibly also for good reasons. But just a vague memory here.
Will have a look in one of the next days, thanks for pushing this further.
He, this is the very same patch that I found in the fork/copy of KDescendantsProxyModel in the sources of Marble when I updated it to latest KF5 version. Actually that patch there was done in 2012 but seems it never got upstreamed, can someone please fix the (L)GPL to require patches to be at least reported to upstream!1! Meh.
I cannot remember what bugged me about this very code when I tried to reason why it fixes things that I went instead for the version in https://git.reviewboard.kde.org/r/128398/ But as said in the comment there, I have not had grasped the complete logic and hoped for guidance by Stephen :)
So given this patch here completes the autotests, also matches that previous patch found in Marble and still works fine in Marble, it has my "Ship it" :)
Thanks for picking this up and getting to a proper test and seemingly better fix, Sune & David.