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

Jan Kundrát jkt at flaska.net
Thu Oct 4 16:38:42 CEST 2012


Hi,
my application makes heavy use of QAIM::reset() in its proxy models, 
most notably in situations where the parent model either "goes away" or 
otherwise fails in a manner which cannot be accommodated by the 
beginResetModel/endResetModel pair of functions. I could convert some of 
these into proper pairs, but others (like the parent model being 
destroyed) have no choice but to signal the "sorry, everything is gone" 
situation and carry on.

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(). 
My models are probably buggy in this regard (they use lazy loading which 
means that they should probably explicitly check for a reset being in 
progress and disable any dynamic updates from this context -- some of 
them do, others don't). I've always used reset() in my code to indicate 
that this is a place where the code is doing either something 
suspicious, or where it does not have any other way but emit this signal.

I have also believed that calling reset() is "safe" in that it is 
somehow different than emitting modelAboutToBeReset/modelReset. In Qt4, 
the implementation of QAIM::reset() is in the .cpp file which I haven't 
seen until now. It just emits these signals and invalidates the 
persistent indexes. In Qt5, it's different -- the code actually does 
nothing but calling the beginResetModel()/endResetModel() pair, so it is 
as "safe" as doing that by hand.

What shall my Qt5 code do when a proxy model discovers that the source 
model is no longer there? Some of my proxies build internal data 
structures which contain pointers to data in the source model; at the 
time the source model gets missing, I really shouldn't be accessing 
these anymore.

With kind regards,
Jan

-- 
Trojita, a fast e-mail client -- http://trojita.flaska.net/



More information about the Interest mailing list