diff options
author | hjk <hjk@qt.io> | 2019-07-23 12:03:27 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2019-07-30 09:34:36 +0200 |
commit | 4fa0b415237040d806758ab5374055ab2c32d84c (patch) | |
tree | 7e1ce49a0f5e2d0e264cb21064c34ef7dc75ab85 | |
parent | 31753adebe0f19b90f332e81e1a9b063b40f982d (diff) |
uic: Avoid use of Q_UNUSED in the generated code
Instead, use (void)x; directly.
The current use of Q_UNUSED(x); generates warnings for an
empty statement the expansion of Q_UNUSED contains a semicolon
already.
Emitting Q_UNUSED(x) without the extra semicolon would be
an option, too, but as the future of Q_UNUSED's embedded
semicolon seems unclear right now, avoid its use altogether.
The change affects only generated code that's barely ever
read by a human, so the overall utility of "improved readability"
of Q_UNUSED in that place is questionable anyway.
Change-Id: I332527ed7c202f779bd82290517837e3ecf09a08
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
-rw-r--r-- | src/tools/uic/cpp/cppwriteinitialization.cpp | 5 | ||||
-rw-r--r-- | tests/auto/tools/uic/baseline/qfiledialog.ui.h | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index d16c859eed..fd5f8c9017 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -547,10 +547,11 @@ void WriteInitialization::acceptUI(DomUI *node) m_output << m_option.indent << language::endFunctionDefinition("setupUi"); if (!m_mainFormUsedInRetranslateUi && language::language() == Language::Cpp) { + // Mark varName as unused to avoid compiler warnings. m_refreshInitialization += m_indent; - m_refreshInitialization += QLatin1String("Q_UNUSED("); + m_refreshInitialization += QLatin1String("(void)"); m_refreshInitialization += varName ; - m_refreshInitialization += QLatin1String(");\n"); + m_refreshInitialization += QLatin1String(";\n"); } m_output << m_option.indent diff --git a/tests/auto/tools/uic/baseline/qfiledialog.ui.h b/tests/auto/tools/uic/baseline/qfiledialog.ui.h index 9e51ee6a7c..52f8d25c75 100644 --- a/tests/auto/tools/uic/baseline/qfiledialog.ui.h +++ b/tests/auto/tools/uic/baseline/qfiledialog.ui.h @@ -291,7 +291,7 @@ public: detailModeButton->setToolTip(QCoreApplication::translate("QFileDialog", "Detail View", nullptr)); #endif // QT_CONFIG(tooltip) fileTypeLabel->setText(QCoreApplication::translate("QFileDialog", "Files of type:", nullptr)); - Q_UNUSED(QFileDialog); + (void)QFileDialog; } // retranslateUi }; |