[Interest] qt5: deprecated QAbstractItemModel::reset()

Stephen Kelly 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:

beginDoSomething();
user_doSomething();
endDoSomething();

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 
proxy).

Thanks,

-- 
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...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20121005/8d7af5c7/attachment.sig>


More information about the Interest mailing list