[Development] What's the status of a moved-from object?

Simon Hausmann Simon.Hausmann at qt.io
Fri May 24 15:24:56 CEST 2019


I don't think our users should have to use a build of Qt that has its internal Q_ASSERTs enabled. IMHO Q_ASSERT should be used by developers in Qt to express invariants that, if violated, represent a bug in Qt that needs fixing. I don't think we should use Q_ASSERT to communicate anything to our users - it's a poor interface because it either isn't reliable (-release build not enabling it) or hard to understand (debugger usage).


From: Giuseppe D'Angelo <giuseppe.dangelo at kdab.com>
Sent: Friday, May 24, 2019 14:28
To: Simon Hausmann; development at qt-project.org
Subject: Re: [Development] What's the status of a moved-from object?

Il 23/05/19 09:36, Simon Hausmann ha scritto:
> I think a well-formed state is more likely to enable our users to have a
> productive time. Operating - by accident - on a partially-formed object
> and either
>      (1) seeing a back-trace that points into Qt, not my application code
>      (2) spending time in the debugger stepping through Qt code
> is IMHO a direction that we should avoid.

To nitpick, in the proposed scenario, (2) shouldn't ever happen. In such
a scenario, the d-pointer checks would be replaced by something like
Q_ASSERT_X(d_ptr, "This object has been moved from"), which would fire
in a debug build of Qt. (1) is a bit more tricky as it wouldn't be
obvious at all what the problem is, although again, a debug build would
identify it immediately.

Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
The Qt Experts - KDAB<http://www.kdab.com/>
KDAB - Software Experts in Qt, C++ and 3D / OpenGL. We have profund expertise in desktop and embedded software services for all kind of industries.

KDAB - The Qt, C++ and OpenGL Experts

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20190524/ac9425bf/attachment.html>

More information about the Development mailing list