[Development] Qt 5 types under consideration for deprecation / removal in Qt 6

Matthew Woehlke mwoehlke.floss at gmail.com
Wed Jun 19 18:42:32 CEST 2019


On 18/06/2019 19.59, Giuseppe D'Angelo via Development wrote:
> On 18/06/2019 23:27, Matthew Woehlke wrote:
>> So... to be clear, your plan is to deprive Qt users of a (mostly)
>> perfectly good wheel, that *is* being used by said users, and instead
>> tell all of those users that they need to go (individually) reinvent the
>> wheel?
> 
> Why depriving? They can stay around, as-is. Current (and future) users
> can still use them...

Mark wants to deprecate Q[E]SDP. That implies eventual removal, which
absolutely *is* depriving users of something they were previously using.
(Even just deprecating is requiring users to either a) stop using it,
which again, is depriving them of it, or b) ignore deprecation warnings,
which will not end well.)

>> Here's a thought... how about, instead, just [...] mark the 
>> conversions-to-pointer deprecated.
> 
> I don't see why people writing "if (d)" should now get deprecation
> warnings and require const_casts to avoid them,

...because, as previously noted, that code *detaches*, which is almost
certainly not what you want!

And no cast is required to fix it; just write `if(d.constData())`
instead. (Also as previously noted.)

Besides, I question the usefulness of implicit casts to pointer. The STL
smart pointer classes don't have those, probably for a reason...
(Admittedly that is sometimes annoying for *generic* pointers, which
often are used with functions that expect raw pointers... but when do
you need that for a *Q[E]SDP*?

Personally, I only ever use Q[E]SDP via a d-func and associated helper
macros that make it clear if I'm detaching or not, and so (AFAIK) I've
never had such "surprises".

Compare:

  // n.b. decltype(d) == QSharedDataPointer<MyClassData>
  if (d->m_visible) // did this detach?
  {
    d->m_visible = false; // what about this?
  }

- vs. -

  QTE_D_SHARED();
  // n.b. decltype(d) == MyClassData const*
  if (d->m_visible) // definitely did not detach
  {
    QTE_D_DETACH(); // definitely *did* detach
    // n.b. decltype(d) == MyClassData*
    d->m_visible = false;
  }

-- 
Matthew


More information about the Development mailing list