Hi,

I'd like to make kde4automoc look for Q_OBJECT macros in private headers 
automatically. This is very convenient as it just makes everything work 
automatically (I was putting Q_OBJECT macros in _p.h files in 
playground/multimedia/phonon/mixer and expected the automoc to work, but it 
didn't).

I have been using this patch for a week or so now and seen no regressions. Ok 
to commit?

-- 
________________________________________________________
Matthias Kretz (Germany)                            <><
http://Vir.homelinux.org/
[EMAIL PROTECTED], [EMAIL PROTECTED],
[EMAIL PROTECTED]
Index: automoc/kde4automoc.cpp
===================================================================
--- automoc/kde4automoc.cpp	(revision 716231)
+++ automoc/kde4automoc.cpp	(working copy)
@@ -168,6 +168,18 @@
                         notIncludedMocs.insert(headername, currentMoc);
                     }
                 }
+                const QString privateHeaderName = absPath + basename + "_p.h";
+                if (QFile::exists(privateHeaderName) && !includedMocs.contains(privateHeaderName) &&
+                        !notIncludedMocs.contains(privateHeaderName)) {
+                    const QString currentMoc = "moc_" + basename + "_p.cpp";
+                    QFile header(privateHeaderName);
+                    header.open(QIODevice::ReadOnly);
+                    const QByteArray contents = header.readAll();
+                    if (qObjectRegExp.indexIn(QString::fromUtf8(contents)) >= 0) {
+                        //qDebug() << "header contains Q_OBJECT macro";
+                        notIncludedMocs.insert(privateHeaderName, currentMoc);
+                    }
+                }
             } else {
                 do { // call this for every moc include in the file
                     const QString currentMoc = mocIncludeRegExp.cap(1);
Index: modules/KDE4Macros.cmake
===================================================================
--- modules/KDE4Macros.cmake	(revision 716231)
+++ modules/KDE4Macros.cmake	(working copy)
@@ -207,6 +207,10 @@
             if(EXISTS "${_header}")
                list(APPEND _moc_headers ${_header})
             endif(EXISTS "${_header}")
+            set(_pheader "${_abs_path}/${_basename}_p.h")
+            if(EXISTS "${_pheader}")
+               list(APPEND _moc_headers ${_pheader})
+            endif(EXISTS "${_pheader}")
             list(APPEND _moc_files ${_abs_current_FILE})
          endif(_suffix STREQUAL ".cpp" OR _suffix STREQUAL ".cc" OR _suffix STREQUAL ".cxx" OR _suffix STREQUAL ".C")
       endif(NOT _generated AND NOT _skip)

Attachment: pgpOtROovSHxS.pgp
Description: PGP signature

_______________________________________________
Kde-buildsystem mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kde-buildsystem

Reply via email to