[Development] Adding std::weak_ptr<void> to QModelIndex

Marc Mutz marc.mutz at kdab.com
Fri Apr 21 12:01:27 CEST 2017


On Friday 21 April 2017 09:32:44 Filippo Cucchetto wrote:
> 2017-04-21 9:13 GMT+02:00 Marc Mutz <marc.mutz at kdab.com>:
> > On Friday 21 April 2017 08:42:37 Filippo Cucchetto wrote:
> > > Is there any plan to enhance the QModelIndex interface by adding
> > > support
> > 
> > to
> > 
> > > std::weak_ptr<void?
> > > I know that is not necessary since we can directly store T* from
> > > shared_ptr<T> but being able to store a weak_ptr seems a little bit
> > 
> > safer.
> > 
> > There is no such plan. QModelIndexes should not be stored anywhere, they
> > are
> > simply an interface type: as long as you're using ti correctly, you could
> > not
> > observe the weak_ptr being reset
> > 
> Yes and i agree, but there's a difference between a crash of an
> application and a warning.

Yes, the former is preferable :)

Seriously, if you still release code that hasn't been though asan, valgrind, 
Purify or any other such tool, a weak_ptr will not help you, either. If you 
don't test, why do you expect your users to report some nondescript warning 
back to you? I'd say they're more likely to report a crash.

> Futhermore since QModelIndexes have been somewhat interfaced with QML this
> bring
> a lot of indeterminism.
>
> > If and when we change QModelIndex to become more convenient, but also
> > more expensive to use, it should probably get a QVariant (or std::any),
> > not any particular type.
> > 
> > Thanks,
> > Marc
> > 
> > --
> > Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
> > KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
> > Tel: +49-30-521325470
> > KDAB - The Qt, C++ and OpenGL Experts

-- 
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt, C++ and OpenGL Experts



More information about the Development mailing list