From 74a88ac9d72ba83965d439eddc99e478762fd524 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 4 Sep 2009 10:49:32 +0200 Subject: Generate Q_UNUSED(varName) only when varName was not used in retranslateUi(Class varName) method. Autotests for uic updated accordingly Task: 260784 RevBy: Kai Koehne --- src/tools/uic/cpp/cppwriteinitialization.cpp | 11 +++++++++-- src/tools/uic/cpp/cppwriteinitialization.h | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src/tools') diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 8dcc4aae38..197414b31b 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -474,6 +474,7 @@ WriteInitialization::WriteInitialization(Uic *uic, bool activateScripts) : m_dindent(m_indent + m_option.indent), m_stdsetdef(true), m_layoutMarginType(TopLevelMargin), + m_mainFormUsedInRetranslateUi(false), m_delayedOut(&m_delayedInitialization, QIODevice::WriteOnly), m_refreshOut(&m_refreshInitialization, QIODevice::WriteOnly), m_actionOut(&m_delayedActionInitialization, QIODevice::WriteOnly), @@ -569,11 +570,11 @@ void WriteInitialization::acceptUI(DomUI *node) m_output << m_option.indent << "} // setupUi\n\n"; - if (m_delayedActionInitialization.isEmpty()) { + if (!m_mainFormUsedInRetranslateUi) { m_refreshInitialization += m_indent; m_refreshInitialization += QLatin1String("Q_UNUSED("); m_refreshInitialization += varName ; - m_refreshInitialization +=QLatin1String(");\n"); + m_refreshInitialization += QLatin1String(");\n"); } m_output << m_option.indent << "void " << "retranslateUi(" << widgetClassName << " *" << varName << ")\n" @@ -1531,6 +1532,12 @@ void WriteInitialization::writeProperties(const QString &varName, o << ");\n"; if (defineC) closeIfndef(o, QLatin1String(defineC)); + + if (varName == m_mainFormVarName && &o == &m_refreshOut) { + // this is the only place (currently) where we output mainForm name to the retranslateUi(). + // Other places output merely instances of a certain class (which cannot be main form, e.g. QListWidget). + m_mainFormUsedInRetranslateUi = true; + } } } if (leftMargin != -1 || topMargin != -1 || rightMargin != -1 || bottomMargin != -1) { diff --git a/src/tools/uic/cpp/cppwriteinitialization.h b/src/tools/uic/cpp/cppwriteinitialization.h index 19e4fc7ca7..b0564d00aa 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.h +++ b/src/tools/uic/cpp/cppwriteinitialization.h @@ -350,6 +350,7 @@ private: QString m_generatedClass; QString m_mainFormVarName; + bool m_mainFormUsedInRetranslateUi; QString m_delayedInitialization; QTextStream m_delayedOut; -- cgit v1.2.1