Bug 242032 - automoc does not write mocDefinitions into the _automoc.cpp file
Summary: automoc does not write mocDefinitions into the _automoc.cpp file
Status: RESOLVED WORKSFORME
Alias: None
Product: buildsystem
Classification: Developer tools
Component: KDE4 (cmake) (show other bugs)
Version: unspecified
Platform: Debian unstable Linux
: NOR minor
Target Milestone: ---
Assignee: Alexander Neundorf
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-17 22:59 UTC by Vincent Ordy
Modified: 2023-01-12 05:18 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Suggested patch (914 bytes, patch)
2010-06-17 23:12 UTC, Vincent Ordy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vincent Ordy 2010-06-17 22:59:42 UTC
Version:           unspecified (using Devel) 
OS:                Linux

It happens when none of the moc files are included (automoc generates them because of Q_OBJECT) *AND* the output _automoc.cpp file does not exists yet (first run or after "make clean").

mocDefinitions is read from the _automoc.cpp.files file by lazyInitMocDefinitions(), which is called if the output file exists to check if the definitions have changed or the first time generateMoc() is called.

When there are only not-included mocs in a project, the first call to generatedMoc() occurs after the mocDefinitions have been written in the output file.

----------------------------------------------
    // run moc on all the moc's that are #included in source files
    QHash<QString, QString>::ConstIterator end = includedMocs.constEnd();
    QHash<QString, QString>::ConstIterator it = includedMocs.constBegin();
    for (; it != end; ++it) {
        generateMoc(it.key(), it.value());
    }

    QByteArray automocSource;
    QTextStream outStream(&automocSource, QIODevice::WriteOnly);
    outStream << "/* This file is autogenerated, do not edit\n"
        << mocDefinitions.join(QString(QLatin1Char(' '))) << "\n*/\n";

    if (notIncludedMocs.isEmpty()) {
        outStream << "enum some_compilers { need_more_than_nothing };\n";
    } else {
        // run moc on the remaining headers and include them in the _automoc.cpp file
        end = notIncludedMocs.constEnd();
        it = notIncludedMocs.constBegin();
        for (; it != end; ++it) {
            if (generateMoc(it.key(), it.value())) {
                automocCppChanged = true;
            }
            outStream << "#include \"" << it.value() << "\"\n";
        }
    }
----------------------------------------------

=> the moc files are regenerated the second time automoc4 is called.

I suggest to call lazyInitMocDefinitions() once and for all when the application start, even if the outputfile does not exists.

Reproducible: Always
Comment 1 Vincent Ordy 2010-06-17 23:12:18 UTC
Created attachment 48090 [details]
Suggested patch
Comment 2 Andrew Crouthamel 2018-11-05 03:21:03 UTC
Dear Bug Submitter,

This bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? I am setting the status to NEEDSINFO pending your response, please change the Status back to REPORTED when you respond.

Thank you for helping us make KDE software even better for everyone!
Comment 3 Andrew Crouthamel 2018-11-17 04:51:06 UTC
Dear Bug Submitter,

This is a reminder that this bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? This bug will be moved back to REPORTED Status for manual review later, which may take a while. If you are able to, please lend us a hand.

Thank you for helping us make KDE software even better for everyone!
Comment 4 Justin Zobel 2022-12-13 02:53:48 UTC
Thank you for reporting this issue in KDE software. As it was reported on an older version, can we please ask you to see if you cazn reproduce the issue with a more recent software version?  
  
If you can confirm this issue still exists in a recent version, please change the version field and the status to "REPORTED" when replying. Thank you!
Comment 5 Bug Janitor Service 2022-12-28 05:25:30 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 6 Bug Janitor Service 2023-01-12 05:18:26 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!