On Wednesday, 21 de September de 2011 15.12.21, Thiago Macieira wrote:
> There's no way around it. Since we're using the function pointer (actually, 
> the PMF) to identify the signal, you must have C++ access to the signal
> function. That means you must be able to call it.
> 
> Other template-based signal libraries have the same problem. It cannot be 
> avoided unless you have a way to identify the signal which doesn't include 
> access to the actual signal implementation.
> 
> One solution to that would be to have an enum of signals, instead of 
> identifying by an object or by a PMF.

Another solution (also by way of adding an indirection) is to add a function 
that emits, which is protected.

template <typename Klass, typename... Args> 
void QObject::emitSignal(void (Klass:: *signal)(Args...), Args... args);

Then you'd write:
        emitSignal(&Me::textChanged, newText);
instead of:
        emit textChanged(newText);

The template magic to make that happen is already present.

However, it would be completely source-incompatible with the existing code, 
which is a big no-no. It would require making the signal functions themselves 
not do anything -- only serve as identifiers.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Qt5-feedback mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback

Reply via email to