[Development] RFC: RAII for property changes
Marc Mutz
marc.mutz at kdab.com
Wed Apr 15 21:03:04 CEST 2015
On Wednesday 15 April 2015 17:08:11 Matthew Woehlke wrote:
> FWIW I had the same thought; also, I'm not a fan of needing the
> Q_UNUSED, or using a macro to 'hide' it.
I haven't had to use Q_UNUSED on a RAII object since iirc GCC 3 times. What
broken compilers are you guys using?
> What about something like this?
>
> QPropertyGuard g{this};
> g.addProperty("a"); // use QObject::property
> g.addProperty("b", m_b); // take value member by reference
> g.addProperty(m_c, &cChanged); // ...and also slot address
There's type erasure going on, so it will allocate memory. Allocating memory
in a setter that might just change an int is what I call inefficient.
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 Experts
More information about the Development
mailing list