summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJarek Kobus <jkobus@trolltech.com>2009-09-04 08:49:32 (GMT)
committerJarek Kobus <jkobus@trolltech.com>2009-09-04 08:53:13 (GMT)
commit74a88ac9d72ba83965d439eddc99e478762fd524 (patch)
tree69aac02b16979a670d224d89cb847cde823e5d2c /src
parent92a3662564f421a46761989d153f6c8eb990131f (diff)
downloadQt-74a88ac9d72ba83965d439eddc99e478762fd524.zip
Qt-74a88ac9d72ba83965d439eddc99e478762fd524.tar.gz
Qt-74a88ac9d72ba83965d439eddc99e478762fd524.tar.bz2
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 <kai.koehne@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.cpp11
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.h1
2 files changed, 10 insertions, 2 deletions
diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp
index 8dcc4aa..197414b 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 19e4fc7..b0564d0 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;