automoc4 corner issues - what lerned from qt-creator port

Matthias Kretz kretz at kde.org
Wed Mar 25 19:23:29 CET 2009


On Wednesday 25 March 2009 17:38:46 Helio Chissini de Castro wrote:
> On Wednesday 25 of March 2009 13:07:07 Matthias Kretz wrote:
> > On Tuesday 24 March 2009 19:36:19 Helio Chissini de Castro wrote:
> > > 4 - w.cpp have an internal Q_OBJECT class and includes w.h with other
> > > class with Q_OBJECT but have no moc includes.
> >
> > Not sure I understand. If the class declaration is in w.cpp but no moc
> > included how do you compile a moc file generated from that w.cpp file?
> > Because in order to compile the generated moc file you need the class
> > declaration, but that's only in w.cpp which you can't include from the
> > moc... So what am I missing?
>
> Something like this:
>  -------------------- w.cpp ---------------------------------
>
> #include <QObject>
> #include "w.h"
>
> class Z : public QObject
> {
>     Q_OBJECT
> public:
>     Z() {};
> };
>
> W::W()
> {
> }
>
> int main()
> {
>     W w;
>     return 0;
> }
>
> -------------------------------------------------------------------
>
> ------------------------ w.h --------------------------------
> #include <QObject>
>
> class W : public QObject
> {
>     Q_OBJECT;
> public:
>     W();
> };
>
> -----------------------------------------------------------------
>
> So, as you see, both header and cpp have no moc includes
> automoc4 test, see that aren't any includes, enter in the first situation
> ( matchOfset < 0 ) and only test if there is Q_OBJECT on w.h or w_p.h,
> suddenly generating a moc_w.cpp

I see I understood you correctly. I still don't see how this is compilable at 
all...

> But since we have a Z class in the cpp with a Q_OBJECT, they should be
> moc'd as well, generating w.moc too. The revised last patch solve this case
> too already.

Does moc add a copy of the class declaration in the moc file then? Is this new 
with Qt 4.5?

-- 
________________________________________________________
Matthias Kretz (Germany)                            <><
http://Vir.homelinux.org/



More information about the Kde-buildsystem mailing list