[Interest] qt5: deprecated QAbstractItemModel::reset()
stephen.kelly at kdab.com
Fri Oct 5 11:32:10 CEST 2012
On Thursday, October 04, 2012 18:24:08 Christian Kandeler wrote:
> On 10/04/12 18:09, Stephen Kelly wrote:
> > On Thursday, October 04, 2012 16:38:42 Jan Kundrát wrote:
> >> I have always assumed that the users of the model are more or less free
> >> to call a "reasonable" subset of model's functions form inside slots
> >> attached to modelAboutToBeReset() -- like index(), parent() and data().
> > Yes, you should be able to call any const method on a model which just
> > emitted modelAboutToBeReset.
> Hm, I have always assumed that signal to mean "stay the hell away from
> me until I emit modelReset()",
Nope. It's just part of the boundary which is common to all parts of the QAIM
structural change reporting API, which are all:
without returning to the event loop.
> meaning that this ...
> > You must not return to the event loop between
> > beginResetModel and endResetModel.
> ... would actually be safe
It seems to be in the case of reset, because beginResetModel is mostly unused
inside Qt itself. It's only used in QTreeView and QComboBox, but I haven't
investigated what happens with those when the begin signal is not emitted.
Quite some useful KDE code expects it to be emitted though, so if you ever
start doing anything complex (such as state saving across application restarts
etc), you'll need it.
I guess consumers of model resets should keep track of whether they recieved a
modelAboutToBeReset, and if they didn't, they should assume that means
destruction of something essential (such as the source model in the case of a
Stephen Kelly <stephen.kelly at kdab.com> | Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
www.kdab.com || Germany +49-30-521325470 || Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-Independent Software Solutions
** Qt Developer Conference: http://qtconference.kdab.com/ **
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 198 bytes
Desc: This is a digitally signed message part.
More information about the Interest