From b21639304b108de0697553f062eb36ccde6a5bd5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 7 Sep 2010 15:56:34 +0200 Subject: Tools (uic/rcc): Improve warning messages. Output as 'filename: Warning: message' and make some uic warnings more verbose to make Qt Creator parsing easier. Fix resource warning in Qt Designer. Reviewed-by: dt Rubber-stamped-by: Tobias Hunger --- src/tools/rcc/rcc.cpp | 7 ++++-- src/tools/uic/cpp/cppextractimages.cpp | 8 +++--- src/tools/uic/cpp/cppwriteincludes.cpp | 10 +++++--- src/tools/uic/cpp/cppwriteinitialization.cpp | 29 +++++++++++++++------- src/tools/uic/driver.cpp | 5 +++- src/tools/uic/option.h | 8 ++++++ .../src/components/formeditor/formeditor.qrc | 1 - 7 files changed, 48 insertions(+), 20 deletions(-) diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index 1f6e58f..0e3167d 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -544,8 +544,11 @@ bool RCCResourceLibrary::addFile(const QString &alias, const RCCFileInfo &file) const QString filename = nodes.at(nodes.size()-1); RCCFileInfo *s = new RCCFileInfo(file); s->m_parent = parent; - if (parent->m_children.contains(filename)) - qWarning("potential duplicate alias detected: '%s'", qPrintable(filename)); + if (parent->m_children.contains(filename)) { + foreach (const QString &fileName, m_fileNames) + qWarning("%s: Warning: potential duplicate alias detected: '%s'", + qPrintable(fileName), qPrintable(filename)); + } parent->m_children.insertMulti(filename, s); return true; } diff --git a/src/tools/uic/cpp/cppextractimages.cpp b/src/tools/uic/cpp/cppextractimages.cpp index 52c1b9d..5809724 100644 --- a/src/tools/uic/cpp/cppextractimages.cpp +++ b/src/tools/uic/cpp/cppextractimages.cpp @@ -76,14 +76,14 @@ void ExtractImages::acceptUI(DomUI *node) if (m_option.qrcOutputFile.size()) { f.setFileName(m_option.qrcOutputFile); if (!f.open(QIODevice::WriteOnly | QFile::Text)) { - fprintf(stderr, "Could not create resource file\n"); + fprintf(stderr, "%s: Error: Could not create resource file\n", qPrintable(m_option.messagePrefix())); return; } QFileInfo fi(m_option.qrcOutputFile); QDir dir = fi.absoluteDir(); if (!dir.exists(QLatin1String("images")) && !dir.mkdir(QLatin1String("images"))) { - fprintf(stderr, "Could not create image dir\n"); + fprintf(stderr, "%s: Error: Could not create image dir\n", qPrintable(m_option.messagePrefix())); return; } dir.cd(QLatin1String("images")); @@ -126,7 +126,9 @@ void ExtractImages::acceptImage(DomImage *image) if (isXPM_GZ) openMode |= QIODevice::Text; if (!f.open(openMode)) { - fprintf(stderr, "Could not create image file %s: %s", qPrintable(fname), qPrintable(f.errorString())); + fprintf(stderr, "%s: Error: Could not create image file %s: %s", + qPrintable(m_option.messagePrefix()), + qPrintable(fname), qPrintable(f.errorString())); return; } diff --git a/src/tools/uic/cpp/cppwriteincludes.cpp b/src/tools/uic/cpp/cppwriteincludes.cpp index 4e0ee4a..2dded84 100644 --- a/src/tools/uic/cpp/cppwriteincludes.cpp +++ b/src/tools/uic/cpp/cppwriteincludes.cpp @@ -126,8 +126,9 @@ void WriteIncludes::acceptUI(DomUI *node) if (m_uic->hasExternalPixmap() && m_uic->pixmapFunction() == QLatin1String("qPixmapFromMimeSource")) { #ifdef QT_NO_QT3_SUPPORT - qWarning("Warning: The form file has external pixmaps or qPixmapFromMimeSource() set as a pixmap function. " - "This requires Qt 3 support, which is disabled. The resulting code will not compile."); + qWarning("%s: Warning: The form file has external pixmaps or qPixmapFromMimeSource() set as a pixmap function. " + "This requires Qt 3 support, which is disabled. The resulting code will not compile.", + qPrintable(m_uic->option().warningsPrefix())); #endif add(QLatin1String("Q3MimeSourceFactory")); } @@ -212,8 +213,9 @@ void WriteIncludes::insertIncludeForClass(const QString &className, QString head header = lowerClassName; header += QLatin1String(".h"); if (warnHeaderGeneration) { - qWarning("Warning: generated header '%s' for class '%s'.", qPrintable(header), - qPrintable(className)); + qWarning("%s: Warning: generated header '%s' for class '%s'.", + qPrintable(m_uic->option().messagePrefix()), + qPrintable(header), qPrintable(className)); } diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index dc1d181..c62f3d9 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -539,10 +539,14 @@ void WriteInitialization::acceptUI(DomUI *node) const Buddy &b = m_buddies.at(i); if (!m_registeredWidgets.contains(b.objName)) { - fprintf(stderr, "'%s' isn't a valid widget\n", b.objName.toLatin1().data()); + fprintf(stderr, "%s: Warning: Buddy assignment: '%s' is not a valid widget\n", + qPrintable(m_option.messagePrefix()), + b.objName.toLatin1().data()); continue; } else if (!m_registeredWidgets.contains(b.buddy)) { - fprintf(stderr, "'%s' isn't a valid widget\n", b.buddy.toLatin1().data()); + fprintf(stderr, "%s: Warning: Buddy assignment: '%s' is not a valid widget\n", + qPrintable(m_option.messagePrefix()), + b.buddy.toLatin1().data()); continue; } @@ -867,7 +871,7 @@ void WriteInitialization::acceptWidget(DomWidget *node) const QString name = zOrder.at(i); if (!m_registeredWidgets.contains(name)) { - fprintf(stderr, "'%s' isn't a valid widget\n", name.toLatin1().data()); + fprintf(stderr, "'%s' Z-order assignment: is not a valid widget\n", name.toLatin1().data()); continue; } @@ -895,7 +899,9 @@ void WriteInitialization::addButtonGroup(const DomWidget *buttonNode, const QStr DomButtonGroup *newGroup = new DomButtonGroup; newGroup->setAttributeName(attributeName); group = newGroup; - fprintf(stderr, "Warning: Creating button group `%s'\n", attributeName.toLatin1().data()); + fprintf(stderr, "%s: Warning: Creating button group `%s'\n", + qPrintable(m_option.messagePrefix()), + attributeName.toLatin1().data()); } const QString groupName = m_driver->findOrInsertButtonGroup(group); // Create on demand @@ -1163,7 +1169,9 @@ void WriteInitialization::acceptActionRef(DomActionRef *node) return; } } else if (!(m_driver->actionByName(actionName) || isSeparator)) { - fprintf(stderr, "Warning: action `%s' not declared\n", actionName.toLatin1().data()); + fprintf(stderr, "%s: Warning: action `%s' not declared\n", + qPrintable(m_option.messagePrefix()), + actionName.toLatin1().data()); return; } @@ -1853,7 +1861,9 @@ void WriteInitialization::acceptTabStops(DomTabStops *tabStops) const QString name = l.at(i); if (!m_registeredWidgets.contains(name)) { - fprintf(stderr, "'%s' isn't a valid widget\n", name.toLatin1().data()); + fprintf(stderr, "%s: Warning: Tab-stop assignment: '%s' is not a valid widget\n", + qPrintable(m_option.messagePrefix()), + name.toLatin1().data()); continue; } @@ -2083,7 +2093,8 @@ QString WriteInitialization::pixCall(const DomProperty *p) const s = p->elementPixmap()->text(); break; default: - qWarning() << "Warning: Unknown icon format encountered. The ui-file was generated with a too-recent version of Designer."; + qWarning("%s: Warning: Unknown icon format encountered. The ui-file was generated with a too-recent version of Designer.", + qPrintable(m_option.messagePrefix())); return QLatin1String("QIcon()"); break; } @@ -2573,7 +2584,7 @@ void WriteInitialization::initializeQ3SqlDataTable(DomWidget *w) } if (table.isEmpty() || connection.isEmpty()) { - fprintf(stderr, "invalid database connection\n"); + fprintf(stderr, "%s: Warning: Invalid database connection\n", qPrintable(m_option.messagePrefix())); return; } @@ -2613,7 +2624,7 @@ void WriteInitialization::initializeQ3SqlDataBrowser(DomWidget *w) } if (table.isEmpty() || connection.isEmpty()) { - fprintf(stderr, "invalid database connection\n"); + fprintf(stderr, "%s: Warning: Invalid database connection\n", qPrintable(m_option.messagePrefix())); return; } diff --git a/src/tools/uic/driver.cpp b/src/tools/uic/driver.cpp index 676388f..65d63e0 100644 --- a/src/tools/uic/driver.cpp +++ b/src/tools/uic/driver.cpp @@ -178,7 +178,10 @@ QString Driver::unique(const QString &instanceName, const QString &className) } if (alreadyUsed && className.size()) { - fprintf(stderr, "Warning: name %s is already used\n", qPrintable(instanceName)); + fprintf(stderr, "%s: Warning: The name '%s' (%s) is already in use, defaulting to '%s'.\n", + qPrintable(m_option.messagePrefix()), + qPrintable(instanceName), qPrintable(className), + qPrintable(name)); } m_nameRepository.insert(name, true); diff --git a/src/tools/uic/option.h b/src/tools/uic/option.h index 8556728..011a8f8 100644 --- a/src/tools/uic/option.h +++ b/src/tools/uic/option.h @@ -43,6 +43,7 @@ #define OPTION_H #include +#include QT_BEGIN_NAMESPACE @@ -91,6 +92,13 @@ struct Option generator(CppGenerator), prefix(QLatin1String("Ui_")) { indent.fill(QLatin1Char(' '), 4); } + + QString messagePrefix() const + { + return inputFile.isEmpty() ? + QString(QLatin1String("stdin")) : + QDir::toNativeSeparators(inputFile); + } }; QT_END_NAMESPACE diff --git a/tools/designer/src/components/formeditor/formeditor.qrc b/tools/designer/src/components/formeditor/formeditor.qrc index 6510814..42724dd 100644 --- a/tools/designer/src/components/formeditor/formeditor.qrc +++ b/tools/designer/src/components/formeditor/formeditor.qrc @@ -113,7 +113,6 @@ images/widgets/vslider.png images/widgets/vspacer.png images/widgets/widget.png - images/widgets/widget.png images/widgets/widgetstack.png images/widgets/wizard.png images/win/adjustsize.png -- cgit v0.12