From c951908bc201afa59402967d50fa926212845fae Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 23 Feb 2012 07:43:30 +0100 Subject: [PATCH 01/37] QString: add from{Ascii,Latin1,Utf8,Local8Bit() overloads for QByteArray One of the more frequent uses for QByteArray::operator const char*() is in passing a QByteArray to QString::fromLatin1(). But this is highly inefficient, since the bytearray already knows its size, but since its demoted to a const char* in passing to fromLatin1(), it forces the latter to call strlen() _again_. The solution, then, is to add overloads for QByteArray that pass the array's .size() as a second argument to the two-arg fromLatin1() version. Change-Id: I5ea1ad3c96d9e64167be53c0c418c7b7dba51f68 Reviewed-by: David Faure Reviewed-by: Lars Knoll --- src/corelib/tools/qstring.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index f1bad5c028..12a5acb689 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -417,6 +417,10 @@ public: { return fromLocal8Bit_helper(str, (str && size == -1) ? int(strlen(str)) : size); } + static inline QString fromAscii(const QByteArray &str) { return fromAscii(str.data(), str.size()); } + static inline QString fromLatin1(const QByteArray &str) { return fromLatin1(str.data(), str.size()); } + static inline QString fromUtf8(const QByteArray &str) { return fromUtf8(str.data(), str.size()); } + static inline QString fromLocal8Bit(const QByteArray &str) { return fromLocal8Bit(str.data(), str.size()); } static QString fromUtf16(const ushort *, int size = -1); static QString fromUcs4(const uint *, int size = -1); static QString fromRawData(const QChar *, int size); From ddf4b378f1e7eac62bd504a1e453cb7b894e21f2 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 25 Feb 2012 12:40:20 +0100 Subject: [PATCH 02/37] Inline and mark as deprecated images's serialNumber() These function are marked as obsolete since Qt 4.3 The motivation here was too fix QPixmap::serialNumber which is marked as QT_DEPRECATED_SINCE but was not inlined. But then I took the oportunity to do the same with all the other functions. Change-Id: Ic50a7857461fc402b2f2b4528c83e53e8e28ea30 Reviewed-by: Lars Knoll --- src/gui/image/qimage.cpp | 11 ++--------- src/gui/image/qimage.h | 4 +++- src/gui/image/qpixmap.cpp | 9 ++------- src/gui/image/qpixmap.h | 2 +- src/gui/image/qpixmap_raster.cpp | 4 ++-- src/gui/kernel/qpalette.cpp | 7 ++----- src/gui/kernel/qpalette.h | 4 +++- src/gui/text/qtextcursor.cpp | 2 +- src/widgets/kernel/qicon.cpp | 8 ++------ src/widgets/kernel/qicon.h | 4 +++- .../tst_qtextdocumentfragment.cpp | 2 +- .../auto/widgets/widgets/qcombobox/tst_qcombobox.cpp | 2 +- 12 files changed, 23 insertions(+), 36 deletions(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 5b23dbf4dc..23d212cc92 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -5132,7 +5132,8 @@ bool qt_xForm_helper(const QTransform &trueMat, int xoffset, int type, int depth #undef IWX_LSB #undef IWX_PIX -/*! \obsolete +/*! \fn int QImage::serialNumber() const + \obsolete Returns a number that identifies the contents of this QImage object. Distinct QImage objects can only have the same serial number if they refer to the same contents (but they don't @@ -5147,14 +5148,6 @@ bool qt_xForm_helper(const QTransform &trueMat, int xoffset, int type, int depth \sa operator==() */ -int QImage::serialNumber() const -{ - if (!d) - return 0; - else - return d->ser_no; -} - /*! Returns a number that identifies the contents of this QImage object. Distinct QImage objects can only have the same key if they diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 5a3ae8f886..e9192f1031 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -253,7 +253,9 @@ public: inline static QImage fromData(const QByteArray &data, const char *format = 0) { return fromData(reinterpret_cast(data.constData()), data.size(), format); } - int serialNumber() const; +#if QT_DEPRECATED_SINCE(5, 0) + QT_DEPRECATED inline int serialNumber() const { return cacheKey() >> 32; } +#endif qint64 cacheKey() const; QPaintEngine *paintEngine() const; diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index e8c1304b74..1f325f5b6b 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -885,7 +885,8 @@ void QPixmap::fill(const QColor &color) data->fill(color); } -/*! \obsolete +/*! \fn int QPixmap::serialNumber() const + \obsolete Returns a number that identifies the contents of this QPixmap object. Distinct QPixmap objects can only have the same serial number if they refer to the same contents (but they don't have @@ -898,12 +899,6 @@ void QPixmap::fill(const QColor &color) it as a cache key. For caching pixmaps, we recommend using the QPixmapCache class whenever possible. */ -int QPixmap::serialNumber() const -{ - if (isNull()) - return 0; - return data->serialNumber(); -} /*! Returns a number that identifies this QPixmap. Distinct QPixmap diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index 27bfe15688..3d78a43917 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -146,7 +146,7 @@ public: void scroll(int dx, int dy, const QRect &rect, QRegion *exposed = 0); #if QT_DEPRECATED_SINCE(5, 0) - QT_DEPRECATED int serialNumber() const; + QT_DEPRECATED inline int serialNumber() const { return cacheKey() >> 32; } #endif qint64 cacheKey() const; diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp index 8125b1360d..7c7c4652e3 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -115,7 +115,7 @@ void QRasterPlatformPixmap::resize(int width, int height) image.setColor(1, QColor(Qt::color1).rgba()); } - setSerialNumber(image.serialNumber()); + setSerialNumber(image.cacheKey() >> 32); } bool QRasterPlatformPixmap::fromData(const uchar *buffer, uint len, const char *format, @@ -349,7 +349,7 @@ void QRasterPlatformPixmap::createPixmapForImage(QImage &sourceImage, Qt::ImageC } is_null = (w <= 0 || h <= 0); - setSerialNumber(image.serialNumber()); + setSerialNumber(image.cacheKey() >> 32); } QImage* QRasterPlatformPixmap::buffer() diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp index 6d3d1c9580..90d96674bc 100644 --- a/src/gui/kernel/qpalette.cpp +++ b/src/gui/kernel/qpalette.cpp @@ -844,7 +844,8 @@ bool QPalette::isEqual(QPalette::ColorGroup group1, QPalette::ColorGroup group2) return true; } -/*! \obsolete +/*! \fn int QPalette::serialNumber() const + \obsolete Returns a number that identifies the contents of this QPalette object. Distinct QPalette objects can only have the same serial @@ -860,10 +861,6 @@ bool QPalette::isEqual(QPalette::ColorGroup group1, QPalette::ColorGroup group2) \sa operator==() */ -int QPalette::serialNumber() const -{ - return d->ser_no; -} /*! Returns a number that identifies the contents of this QPalette diff --git a/src/gui/kernel/qpalette.h b/src/gui/kernel/qpalette.h index cc710fa67a..ca619a89b4 100644 --- a/src/gui/kernel/qpalette.h +++ b/src/gui/kernel/qpalette.h @@ -139,7 +139,9 @@ public: inline bool operator!=(const QPalette &p) const { return !(operator==(p)); } bool isCopyOf(const QPalette &p) const; - int serialNumber() const; +#if QT_DEPRECATED_SINCE(5, 0) + QT_DEPRECATED inline int serialNumber() const { return cacheKey() >> 32; } +#endif qint64 cacheKey() const; QPalette resolve(const QPalette &) const; diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index ddf2fb080e..cbffc4315f 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -2325,7 +2325,7 @@ void QTextCursor::insertImage(const QImage &image, const QString &name) } QString imageName = name; if (name.isEmpty()) - imageName = QString::number(image.serialNumber()); + imageName = QString::number(image.cacheKey()); d->priv->document()->addResource(QTextDocument::ImageResource, QUrl(imageName), image); QTextImageFormat format; format.setName(imageName); diff --git a/src/widgets/kernel/qicon.cpp b/src/widgets/kernel/qicon.cpp index e579fac4f4..c848dd74f4 100644 --- a/src/widgets/kernel/qicon.cpp +++ b/src/widgets/kernel/qicon.cpp @@ -621,7 +621,8 @@ QIcon::operator QVariant() const return QVariant(QVariant::Icon, this); } -/*! \obsolete +/*! \fn int QIcon::serialNumber() const + \obsolete Returns a number that identifies the contents of this QIcon object. Distinct QIcon objects can have @@ -638,11 +639,6 @@ QIcon::operator QVariant() const \sa QPixmap::serialNumber() */ -int QIcon::serialNumber() const -{ - return d ? d->serialNum : 0; -} - /*! Returns a number that identifies the contents of this QIcon object. Distinct QIcon objects can have the same key if diff --git a/src/widgets/kernel/qicon.h b/src/widgets/kernel/qicon.h index 7bef500946..c6e07ba3e2 100644 --- a/src/widgets/kernel/qicon.h +++ b/src/widgets/kernel/qicon.h @@ -94,7 +94,9 @@ public: bool isDetached() const; void detach(); - int serialNumber() const; +#if QT_DEPRECATED_SINCE(5, 0) + QT_DEPRECATED inline int serialNumber() const { return cacheKey() >> 32; } +#endif qint64 cacheKey() const; void addPixmap(const QPixmap &pixmap, Mode mode = Normal, State state = Off); diff --git a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp index 50ae22c530..7ca4fc981b 100644 --- a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp +++ b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp @@ -2938,7 +2938,7 @@ void tst_QTextDocumentFragment::backgroundImage() doc.setHtml("

Hello

"); QBrush bg = doc.begin().blockFormat().background(); QVERIFY(bg.style() == Qt::TexturePattern); - QVERIFY(bg.texture().serialNumber() == doc.testPixmap.serialNumber()); + QCOMPARE(bg.texture().cacheKey(), doc.testPixmap.cacheKey()); } void tst_QTextDocumentFragment::dontMergePreAndNonPre() diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 907a239912..7cc043e247 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -1333,7 +1333,7 @@ void tst_QComboBox::textpixmapdata() for (int i = 0; iitemIcon(i); - QVERIFY(icon.serialNumber() == icons.at(i).serialNumber()); + QCOMPARE(icon.cacheKey(), icons.at(i).cacheKey()); QPixmap original = icons.at(i).pixmap(1024); QPixmap pixmap = icon.pixmap(1024); QVERIFY(pixmap.toImage() == original.toImage()); From 8397a44bedf542b53284674c87268819f4911d31 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 22 Feb 2012 16:17:30 +0100 Subject: [PATCH 03/37] QByteArray: deprecate QT_NO_CAST_FROM_BYTEARRAY-protected operators The QByteArray::operator const {char,void}*() implicit conversions are a source of subtle bugs, so they right- fully can be disabled with QT_NO_CAST_FROM_BYTEARRAY. const char *d = qstring.toLatin1(); // implicit conversion while ( d ) // oops: d points to freed memory // ... But almost no-one ever enabled this macros in the wild and many were bitten by these implicit conversions, so this patch deprecates them. I would have liked to remove them completely, but there are just too many occurrences even in Qt itself to hope to find all conditionally-compiled code that uses these. Also fixes all code that needs to compile under QT_NO_DEPRECATED (in qmake/, src/tools/). I984706452db7d0841620a0f64e179906123f3849 separately deals with the bulk of changes in src/ and examples/. Depends on I5ea1ad3c96d9e64167be53c0c418c7b7dba51f68. Change-Id: I8d47e6c293c80f61c6288c9f8d42fda41afe2267 Reviewed-by: David Faure Reviewed-by: Lars Knoll --- qmake/generators/integrity/gbuild.cpp | 4 ++-- qmake/generators/mac/pbuilder_pbx.cpp | 2 +- qmake/generators/makefiledeps.cpp | 4 ++-- qmake/generators/win32/msvc_objectmodel.cpp | 2 +- qmake/generators/win32/msvc_objectmodel.h | 2 +- qmake/project.cpp | 10 +++++----- src/corelib/codecs/qtextcodec.cpp | 6 +++--- src/corelib/io/qfilesystemengine_unix.cpp | 18 +++++++++--------- src/corelib/io/qsettings.cpp | 6 +++--- src/corelib/kernel/qvariant.cpp | 2 +- src/corelib/tools/qbytearray.cpp | 6 ++++-- src/corelib/tools/qbytearray.h | 12 ++++-------- src/corelib/tools/qlocale_unix.cpp | 2 +- src/corelib/tools/qstring.cpp | 2 +- src/tools/rcc/rcc.cpp | 2 +- src/tools/uic/cpp/cppwriteicondata.cpp | 4 ++-- src/xml/dom/qdom.cpp | 8 ++++---- src/xml/sax/qxml.cpp | 6 +++--- 18 files changed, 48 insertions(+), 50 deletions(-) diff --git a/qmake/generators/integrity/gbuild.cpp b/qmake/generators/integrity/gbuild.cpp index c72c120f39..895df24193 100644 --- a/qmake/generators/integrity/gbuild.cpp +++ b/qmake/generators/integrity/gbuild.cpp @@ -213,7 +213,7 @@ GBuildMakefileGenerator::write() dllbase += DLLOFFSET; } - warn_msg(WarnParser, Option::output.fileName().toAscii()); + warn_msg(WarnParser, Option::output.fileName().toAscii().constData()); QTextStream t(&Option::output); QString primaryTarget(project->values("QMAKE_CXX").at(0)); @@ -425,7 +425,7 @@ GBuildMakefileGenerator::openOutput(QFile &file, const QString &build) const outputName += QDir::separator(); outputName += fileInfo(project->projectFile()).baseName(); outputName += projectSuffix(); - warn_msg(WarnParser, outputName.toAscii()); + warn_msg(WarnParser, outputName.toAscii().constData()); file.setFileName(outputName); } debug_msg(1, "file is %s", file.fileName().toLatin1().constData()); diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp index b78ebd136d..2f6b30fe12 100644 --- a/qmake/generators/mac/pbuilder_pbx.cpp +++ b/qmake/generators/mac/pbuilder_pbx.cpp @@ -1374,7 +1374,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) } tmp = project->values("QMAKE_PBX_VARS"); for(int i = 0; i < tmp.count(); i++) { - QString var = tmp[i], val = qgetenv(var.toLatin1()); + QString var = tmp[i], val = QString::fromAscii(qgetenv(var.toLatin1().constData())); if(val.isEmpty() && var == "TB") val = "/usr/bin/"; t << "\t\t\t\t" << writeSettings(var, escapeFilePath(val)) << ";" << "\n"; diff --git a/qmake/generators/makefiledeps.cpp b/qmake/generators/makefiledeps.cpp index d28d48b4d0..642dd97e68 100644 --- a/qmake/generators/makefiledeps.cpp +++ b/qmake/generators/makefiledeps.cpp @@ -185,9 +185,9 @@ SourceFile *SourceFiles::lookupFile(const char *file) void SourceFiles::addFile(SourceFile *p, const char *k, bool own_file) { - QByteArray ba = p->file.local().toLatin1(); + const QByteArray ba = p->file.local().toLatin1(); if(!k) - k = ba; + k = ba.constData(); int h = hash(k) % num_nodes; SourceFileNode *pn = new SourceFileNode; pn->own_file = own_file; diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index 81f541f94e..e0f55a64c9 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -1615,7 +1615,7 @@ bool VCLinkerTool::parseOption(const char* option) { // Split up in subsystem, and version number QStringList both = QString(option+11).split(","); - switch (elfHash(both[0].toLatin1())) { + switch (elfHash(both[0].toLatin1().constData())) { case 0x8438445: // CONSOLE SubSystem = subSystemConsole; break; diff --git a/qmake/generators/win32/msvc_objectmodel.h b/qmake/generators/win32/msvc_objectmodel.h index 8b1cf519ff..37d923f9c1 100644 --- a/qmake/generators/win32/msvc_objectmodel.h +++ b/qmake/generators/win32/msvc_objectmodel.h @@ -477,7 +477,7 @@ protected: public: void parseOptions(QStringList& options) { for (QStringList::ConstIterator it=options.begin(); (it!=options.end()); it++) - parseOption((*it).toLatin1()); + parseOption((*it).toLatin1().constData()); } static QStringList fixCommandLine(const QString &input); }; diff --git a/qmake/project.cpp b/qmake/project.cpp index 2029e068ec..379854ed6a 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -1520,7 +1520,7 @@ QMakeProject::resolveSpec(QString *spec, const QString &qmakespec) if (*spec == "default") { #ifdef Q_OS_UNIX char buffer[1024]; - int l = readlink(qmakespec.toLatin1(), buffer, 1023); + int l = readlink(qmakespec.toLatin1().constData(), buffer, 1023); if (l != -1) { buffer[l] = '\0'; *spec = QString::fromLatin1(buffer); @@ -2070,7 +2070,7 @@ QMakeProject::doProjectExpand(QString func, QList args_list, if(args.count() > 1) singleLine = (args[1].toLower() == "true"); QString output; - FILE *proc = QT_POPEN(args[0].toLatin1(), "r"); + FILE *proc = QT_POPEN(args[0].toLatin1().constData(), "r"); while(proc && !feof(proc)) { int read_in = int(fread(buff, 1, 255, proc)); if(!read_in) @@ -3150,12 +3150,12 @@ QStringList &QMakeProject::values(const QString &_var, QHash 0; oldslash = slash) { - QByteArray chunk = QFile::encodeName(dirName.left(slash)); + const QByteArray chunk = QFile::encodeName(dirName.left(slash)); QT_STATBUF st; - if (QT_STAT(chunk, &st) != -1) { + if (QT_STAT(chunk.constData(), &st) != -1) { if ((st.st_mode & S_IFMT) != S_IFDIR) return false; - if (::rmdir(chunk) != 0) + if (::rmdir(chunk.constData()) != 0) return oldslash != 0; } else { return false; @@ -515,7 +515,7 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo } return true; } - return rmdir(QFile::encodeName(entry.filePath())) == 0; + return rmdir(QFile::encodeName(entry.filePath()).constData()) == 0; } //static @@ -623,7 +623,7 @@ QString QFileSystemEngine::tempPath() bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &path) { int r; - r = QT_CHDIR(path.nativeFilePath()); + r = QT_CHDIR(path.nativeFilePath().constData()); return r >= 0; } diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 2021c42c4d..f743c592bd 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -1752,10 +1752,10 @@ bool QConfFileSettingsPrivate::readIniFile(const QByteArray &data, iniSection = iniSection.trimmed(); - if (qstricmp(iniSection, "general") == 0) { + if (qstricmp(iniSection.constData(), "general") == 0) { currentSection.clear(); } else { - if (qstricmp(iniSection, "%general") == 0) { + if (qstricmp(iniSection.constData(), "%general") == 0) { currentSection = QLatin1String(iniSection.constData() + 1); } else { currentSection.clear(); @@ -1912,7 +1912,7 @@ bool QConfFileSettingsPrivate::writeIniFile(QIODevice &device, const ParsedSetti if (realSection.isEmpty()) { realSection = "[General]"; - } else if (qstricmp(realSection, "general") == 0) { + } else if (qstricmp(realSection.constData(), "general") == 0) { realSection = "[%General]"; } else { realSection.prepend('['); diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 4e7fd94141..2f67ae9287 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -1698,7 +1698,7 @@ void QVariant::load(QDataStream &s) if (typeId == QVariant::UserType) { QByteArray name; s >> name; - typeId = QMetaType::type(name); + typeId = QMetaType::type(name.constData()); if (!typeId) { s.setStatus(QDataStream::ReadCorruptData); return; diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index c74c61999d..1d37f578b8 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -343,7 +343,7 @@ int qstrcmp(const QByteArray &str1, const QByteArray &str2) { int l1 = str1.length(); int l2 = str2.length(); - int ret = memcmp(str1, str2, qMin(l1, l2)); + int ret = memcmp(str1.constData(), str2.constData(), qMin(l1, l2)); if (ret != 0) return ret; @@ -995,6 +995,8 @@ QByteArray &QByteArray::operator=(const char *str) /*! \fn QByteArray::operator const char *() const \fn QByteArray::operator const void *() const + \obsolete Use constData() instead. + Returns a pointer to the data stored in the byte array. The pointer can be used to access the bytes that compose the array. The data is '\\0'-terminated. The pointer remains valid as long @@ -2751,7 +2753,7 @@ QDataStream &operator<<(QDataStream &out, const QByteArray &ba) out << (quint32)0xffffffff; return out; } - return out.writeBytes(ba, ba.size()); + return out.writeBytes(ba.constData(), ba.size()); } /*! \relates QByteArray diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index 8202097da5..09c43988fd 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -207,8 +207,10 @@ public: void squeeze(); #ifndef QT_NO_CAST_FROM_BYTEARRAY - operator const char *() const; - operator const void *() const; +#if QT_DEPRECATED_SINCE(5, 0) + QT_DEPRECATED operator const char *() const { return constData(); } + QT_DEPRECATED operator const void *() const { return constData(); } +#endif #endif char *data(); const char *data() const; @@ -415,12 +417,6 @@ inline char QByteArray::operator[](uint i) const inline bool QByteArray::isEmpty() const { return d->size == 0; } -#ifndef QT_NO_CAST_FROM_BYTEARRAY -inline QByteArray::operator const char *() const -{ return d->data(); } -inline QByteArray::operator const void *() const -{ return d->data(); } -#endif inline char *QByteArray::data() { detach(); return d->data(); } inline const char *QByteArray::data() const diff --git a/src/corelib/tools/qlocale_unix.cpp b/src/corelib/tools/qlocale_unix.cpp index 6ace96f771..f2876912b4 100644 --- a/src/corelib/tools/qlocale_unix.cpp +++ b/src/corelib/tools/qlocale_unix.cpp @@ -98,7 +98,7 @@ QLocale QSystemLocale::fallbackLocale() const lang = qgetenv("LC_NUMERIC"); if (lang.isEmpty()) lang = qgetenv("LANG"); - return QLocale(QLatin1String(lang)); + return QLocale(QString::fromLatin1(lang)); } QVariant QSystemLocale::query(QueryType type, QVariant in) const diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 704545667c..14b8782dae 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -4761,7 +4761,7 @@ int QString::localeAwareCompare_helper(const QChar *data1, int length1, } // else fall through # endif // declared in - int delta = strcoll(toLocal8Bit_helper(data1, length1), toLocal8Bit_helper(data2, length2)); + int delta = strcoll(toLocal8Bit_helper(data1, length1).constData(), toLocal8Bit_helper(data2, length2).constData()); if (delta == 0) delta = ucstrcmp(data1, length1, data2, length2); return delta; diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index 5fbda35fc6..bfb3206778 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -681,7 +681,7 @@ bool RCCResourceLibrary::output(QIODevice &outDevice, QIODevice &errorDevice) m_errorDevice->write("Could not write footer\n"); return false; } - outDevice.write(m_out, m_out.size()); + outDevice.write(m_out.constData(), m_out.size()); return true; } diff --git a/src/tools/uic/cpp/cppwriteicondata.cpp b/src/tools/uic/cpp/cppwriteicondata.cpp index 39ce52f4b3..082961cfe6 100644 --- a/src/tools/uic/cpp/cppwriteicondata.cpp +++ b/src/tools/uic/cpp/cppwriteicondata.cpp @@ -176,8 +176,8 @@ void WriteIconData::writeImage(QTextStream &output, const QString &indent, void WriteIconData::writeImage(QIODevice &output, DomImage *image) { - QByteArray array = transformImageData(image->elementData()->text()); - output.write(array, array.size()); + const QByteArray array = transformImageData(image->elementData()->text()); + output.write(array.constData(), array.size()); } } // namespace CPP diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index c16fd03613..38a44024aa 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -5682,24 +5682,24 @@ static QByteArray encodeEntity(const QByteArray& str) QByteArray tmp(str); int len = tmp.size(); int i = 0; - const char* d = tmp.data(); + const char* d = tmp.constData(); while (i < len) { if (d[i] == '%'){ tmp.replace(i, 1, "<"); - d = tmp; + d = tmp.constData(); len += 4; i += 5; } else if (d[i] == '"') { tmp.replace(i, 1, """); - d = tmp; + d = tmp.constData(); len += 4; i += 5; } else if (d[i] == '&' && i + 1 < len && d[i+1] == '#') { // Dont encode < or " or &custom;. // Only encode character references tmp.replace(i, 1, "&"); - d = tmp; + d = tmp.constData(); len += 4; i += 5; } else { diff --git a/src/xml/sax/qxml.cpp b/src/xml/sax/qxml.cpp index 2a41ce3426..75e2fdb2e7 100644 --- a/src/xml/sax/qxml.cpp +++ b/src/xml/sax/qxml.cpp @@ -1612,7 +1612,7 @@ QString QXmlInputSource::fromRawData(const QByteArray &data, bool beginning) d->encMapper = codec->makeDecoder(); } - QString input = d->encMapper->toUnicode(data, data.size()); + QString input = d->encMapper->toUnicode(data.constData(), data.size()); if (d->lookingForEncodingDecl) { d->encodingDeclChars += input; @@ -1633,9 +1633,9 @@ QString QXmlInputSource::fromRawData(const QByteArray &data, bool beginning) input.clear(); // prime the decoder with the data so far - d->encMapper->toUnicode(d->encodingDeclBytes, d->encodingDeclBytes.size()); + d->encMapper->toUnicode(d->encodingDeclBytes.constData(), d->encodingDeclBytes.size()); // now feed it the new data - input = d->encMapper->toUnicode(data, data.size()); + input = d->encMapper->toUnicode(data.constData(), data.size()); } } } From 3ec9aac6c9aa627eb41f8603c517c8cf71be0af0 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 23 Feb 2012 22:15:57 +0100 Subject: [PATCH 04/37] QXmlStream{Reader,Writer}: add explicit to constructors Change-Id: Ib70b7a8f15aaf2e59deddcb0b89eb7e976893280 Reviewed-by: Lars Knoll Reviewed-by: Olivier Goffart --- src/corelib/xml/qxmlstream.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/corelib/xml/qxmlstream.h b/src/corelib/xml/qxmlstream.h index 3a9ddfd990..90382c7fe5 100644 --- a/src/corelib/xml/qxmlstream.h +++ b/src/corelib/xml/qxmlstream.h @@ -248,10 +248,10 @@ public: QXmlStreamReader(); - QXmlStreamReader(QIODevice *device); - QXmlStreamReader(const QByteArray &data); - QXmlStreamReader(const QString &data); - QXmlStreamReader(const char * data); + explicit QXmlStreamReader(QIODevice *device); + explicit QXmlStreamReader(const QByteArray &data); + explicit QXmlStreamReader(const QString &data); + explicit QXmlStreamReader(const char * data); ~QXmlStreamReader(); void setDevice(QIODevice *device); @@ -361,9 +361,9 @@ class Q_CORE_EXPORT QXmlStreamWriter QDOC_PROPERTY(int autoFormattingIndent READ autoFormattingIndent WRITE setAutoFormattingIndent) public: QXmlStreamWriter(); - QXmlStreamWriter(QIODevice *device); - QXmlStreamWriter(QByteArray *array); - QXmlStreamWriter(QString *string); + explicit QXmlStreamWriter(QIODevice *device); + explicit QXmlStreamWriter(QByteArray *array); + explicit QXmlStreamWriter(QString *string); ~QXmlStreamWriter(); void setDevice(QIODevice *device); From 4550f0db210258338c8d6261640d9f192c0d3db6 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 23 Feb 2012 22:39:20 +0100 Subject: [PATCH 05/37] QStringMatcher: make constructor explicit Change-Id: I3a8f37d2132eb84bef336afed60aff6e2350366d Reviewed-by: Lars Knoll Reviewed-by: Olivier Goffart --- src/corelib/tools/qstringmatcher.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qstringmatcher.h b/src/corelib/tools/qstringmatcher.h index a9b2a7c371..3f614f732c 100644 --- a/src/corelib/tools/qstringmatcher.h +++ b/src/corelib/tools/qstringmatcher.h @@ -55,7 +55,7 @@ class Q_CORE_EXPORT QStringMatcher { public: QStringMatcher(); - QStringMatcher(const QString &pattern, + explicit QStringMatcher(const QString &pattern, Qt::CaseSensitivity cs = Qt::CaseSensitive); QStringMatcher(const QChar *uc, int len, Qt::CaseSensitivity cs = Qt::CaseSensitive); From 5bb1408927b4eb5a03e8ab9f7cbc68f80d8a3962 Mon Sep 17 00:00:00 2001 From: Matthew Vogt Date: Thu, 23 Feb 2012 11:12:58 +1000 Subject: [PATCH 06/37] Allow moc to handle symbols that have been redefined. Allow moc to produce the desired identifiers when used with C++ symbol names that have been redefined, for example by -Dfoo=bar. Two changes are required: firstly, when encoding a type name, the components of the name must be checked for substitutions that have been defined for that token (note that this is not done here by correct pre-processing, but only by processing the resultant table of definitions). Secondly, the arguments to the SIGNAL, SLOT and METHOD macros must be allowed to be substituted during macro expansion rather than stringized directly. This is a temporary change to prevent breaking existing projects that depend on the declarative module. After clients have had an opportunity to update their code to the use the new interfaces, it can be removed. Task-number: QTBUG-23737 Change-Id: I39e6844cebf6ca7984af6028160b8a3797ac44a5 Reviewed-by: Martin Jones --- src/corelib/kernel/qobjectdefs.h | 12 +-- src/tools/moc/main.cpp | 2 +- src/tools/moc/moc.cpp | 110 +++++++++++++++++++++- src/tools/moc/moc.h | 13 ++- tests/auto/tools/moc/tst_moc.cpp | 152 +++++++++++++++++++++++++++++++ 5 files changed, 278 insertions(+), 11 deletions(-) diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 0b1fa8839f..45ef8ab3ca 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -208,16 +208,16 @@ Q_CORE_EXPORT const char *qFlagLocation(const char *method); #ifndef QT_NO_DEBUG # define QLOCATION "\0" __FILE__ ":" QTOSTRING(__LINE__) # ifndef QT_NO_KEYWORDS -# define METHOD(a) qFlagLocation("0"#a QLOCATION) +# define METHOD(a) qFlagLocation("0" QTOSTRING(a) QLOCATION) # endif -# define SLOT(a) qFlagLocation("1"#a QLOCATION) -# define SIGNAL(a) qFlagLocation("2"#a QLOCATION) +# define SLOT(a) qFlagLocation("1" QTOSTRING(a) QLOCATION) +# define SIGNAL(a) qFlagLocation("2" QTOSTRING(a) QLOCATION) #else # ifndef QT_NO_KEYWORDS -# define METHOD(a) "0"#a +# define METHOD(a) "0" QTOSTRING(a) # endif -# define SLOT(a) "1"#a -# define SIGNAL(a) "2"#a +# define SLOT(a) "1" QTOSTRING(a) +# define SIGNAL(a) "2" QTOSTRING(a) #endif #define QMETHOD_CODE 0 // member type codes diff --git a/src/tools/moc/main.cpp b/src/tools/moc/main.cpp index 772df1feec..6f67a7dddf 100644 --- a/src/tools/moc/main.cpp +++ b/src/tools/moc/main.cpp @@ -159,7 +159,7 @@ int runMoc(int _argc, char **_argv) bool autoInclude = true; bool defaultInclude = true; Preprocessor pp; - Moc moc; + Moc moc(pp); pp.macros["Q_MOC_RUN"]; pp.macros["__cplusplus"]; QByteArray filename; diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 7b358c1ae8..4189c29de1 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -304,7 +304,9 @@ void Moc::parseFunctionArguments(FunctionDef *def) arg.rightType += lexem(); } arg.normalizedType = normalizeType(QByteArray(arg.type.name + ' ' + arg.rightType)); + arg.normalizedType = getTypeSubstitution(arg.normalizedType); arg.typeNameForCast = normalizeType(QByteArray(noRef(arg.type.name) + "(*)" + arg.rightType)); + arg.typeNameForCast = getTypeSubstitution(arg.typeNameForCast); if (test(EQ)) arg.isDefault = true; def->arguments += arg; @@ -414,6 +416,7 @@ bool Moc::parseFunction(FunctionDef *def, bool inMacro) } def->normalizedType = normalizeType(def->type.name); + def->normalizedType = getTypeSubstitution(def->normalizedType); if (!test(RPAREN)) { parseFunctionArguments(def); @@ -512,6 +515,7 @@ bool Moc::parseMaybeFunction(const ClassDef *cdef, FunctionDef *def) } def->normalizedType = normalizeType(def->type.name); + def->normalizedType = getTypeSubstitution(def->normalizedType); if (!test(RPAREN)) { parseFunctionArguments(def); @@ -968,6 +972,7 @@ void Moc::createPropertyDef(PropertyDef &propDef) QVariant. */ type = normalizeType(type); + type = getTypeSubstitution(type); if (type == "QMap") type = "QMap"; else if (type == "QValueList") @@ -1081,7 +1086,6 @@ void Moc::parseProperty(ClassDef *def) createPropertyDef(propDef); next(RPAREN); - if(!propDef.notify.isEmpty()) def->notifyableProperties++; if (propDef.revision > 0) @@ -1244,7 +1248,8 @@ void Moc::parseInterfaces(ClassDef *def) } // resolve from classnames to interface ids for (int i = 0; i < iface.count(); ++i) { - const QByteArray iid = interface2IdMap.value(iface.at(i).className); + QByteArray className = getTypeSubstitution(iface.at(i).className); + QByteArray iid = interface2IdMap.value(className); if (iid.isEmpty()) error("Undefined interface"); @@ -1502,6 +1507,107 @@ void Moc::checkProperties(ClassDef *cdef) } } +QByteArray Moc::getSubstitution(const QByteArray &token) const +{ + Macros::ConstIterator it = preprocessor.macros.find(token); + if (it != preprocessor.macros.end() && it->symbols.count() == 1) { + // We can only handle substitutions that result in a single symbol + return it->symbols.at(0).lexem(); + } + + return QByteArray(); +} + +QByteArray Moc::getTokenSubstitution(const QByteArray &token) const +{ + QByteArray result = token; + + QSet used; + + // Process substitution chain until no replacement exists + QByteArray substitution = getSubstitution(result); + while (!substitution.isEmpty()) { + used.insert(result); + result = substitution; + + if (used.contains(result)) { + break; + } + + substitution = getSubstitution(result); + } + + return result; +} + +QByteArray Moc::getWordSubstitution(const QByteArray &word) const +{ + QByteArray result; + + // A word can contain multiple components separated by '*' + int startIndex = 0; + do { + int index = word.indexOf('*', startIndex); + if (index == -1) { + result.append(getTokenSubstitution(word.mid(startIndex))); + } else { + result.append(getTokenSubstitution(word.mid(startIndex, (index - startIndex)))); + result.append('*'); + } + + startIndex = index + 1; + } while (startIndex != 0); + + return result; +} + +QByteArray Moc::getNameSubstitution(const QByteArray &name) const +{ + QByteArray result; + + // Parse multiple tokens in this name independently + int startIndex = 0; + do { + int index = name.indexOf(' ', startIndex); + if (index == -1) { + result.append(getWordSubstitution(name.mid(startIndex))); + } else { + result.append(getWordSubstitution(name.mid(startIndex, (index - startIndex)))); + result.append(' '); + } + + startIndex = index + 1; + } while (startIndex != 0); + + return result; +} + +QByteArray Moc::getTypeSubstitution(const QByteArray &typeName) const +{ + int index = typeName.indexOf('<'); + if (index != -1) { + QByteArray templateName = typeName.left(index); + + int lastIndex = typeName.lastIndexOf('>'); + if (lastIndex > index) { + QByteArray result = getNameSubstitution(templateName); + + // Parse the interior type independently + QByteArray parameter = typeName.mid(index + 1, (lastIndex - index - 1)); + QByteArray interior = getTypeSubstitution(parameter); + if (interior.endsWith('>')) { + interior.append(' '); + } + result.append('<').append(interior).append(typeName.mid(lastIndex)); + return result; + } else { + // Something is broken; return the input unmodified + return typeName; + } + } + + return getNameSubstitution(typeName); +} QT_END_NAMESPACE diff --git a/src/tools/moc/moc.h b/src/tools/moc/moc.h index aedb97b234..9e9225da0a 100644 --- a/src/tools/moc/moc.h +++ b/src/tools/moc/moc.h @@ -43,6 +43,7 @@ #define MOC_H #include "parser.h" +#include "preprocessor.h" #include #include #include @@ -197,12 +198,14 @@ struct NamespaceDef { class Moc : public Parser { public: - Moc() - : noInclude(false), generatedCode(false), mustIncludeQMetaTypeH(false), mustIncludeQPluginH(false) + Moc(Preprocessor &p) + : preprocessor(p), noInclude(false), generatedCode(false), + mustIncludeQMetaTypeH(false), mustIncludeQPluginH(false) {} QByteArray filename; + Preprocessor &preprocessor; bool noInclude; bool generatedCode; bool mustIncludeQMetaTypeH; @@ -260,6 +263,12 @@ public: void checkSuperClasses(ClassDef *def); void checkProperties(ClassDef* cdef); + + QByteArray getSubstitution(const QByteArray &token) const; + QByteArray getTokenSubstitution(const QByteArray &token) const; + QByteArray getWordSubstitution(const QByteArray &word) const; + QByteArray getNameSubstitution(const QByteArray &name) const; + QByteArray getTypeSubstitution(const QByteArray &typeName) const; }; inline QByteArray noRef(const QByteArray &type) diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 27db6cc59c..49095048bf 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -535,6 +535,7 @@ private slots: void cxx11Enums_data(); void cxx11Enums(); void returnRefs(); + void redefinedNames(); signals: void sigWithUnsignedArg(unsigned foo); @@ -1762,6 +1763,157 @@ void tst_Moc::returnRefs() // they used to cause miscompilation of the moc generated file. } +struct ActualInterfaceName +{ + virtual ~ActualInterfaceName() {} + virtual void foo() = 0; +}; + +QT_BEGIN_NAMESPACE +Q_DECLARE_INTERFACE(ActualInterfaceName, "foo.bar.ActualInterfaceName") +QT_END_NAMESPACE + +#define DefinedInterfaceName ActualInterfaceName +#define RedefinedInterfaceName DefinedInterfaceName + +struct ActualName {}; +#define DefinedName ActualName +#define RedefinedName DefinedName + +template +struct ActualTemplateName {}; + +#define DefinedTemplateName ActualTemplateName +#define RedefinedTemplateName DefinedTemplateName + +#define ActualName ActualName + +class RedefinitionTest : public QObject, public RedefinedInterfaceName +{ + Q_OBJECT + Q_INTERFACES(RedefinedInterfaceName) + + Q_PROPERTY(ActualName p1 READ getP1) + + Q_PROPERTY(DefinedName p2 READ getP2) + Q_PROPERTY(RedefinedName p3 READ getP3) + + Q_PROPERTY(DefinedName * p4 READ getP4) + Q_PROPERTY(RedefinedName * p5 READ getP5) + + Q_PROPERTY(DefinedName ** p6 READ getP6) + Q_PROPERTY(RedefinedName ** p7 READ getP7) + + Q_PROPERTY(DefinedName const ** p8 READ getP8) + Q_PROPERTY(RedefinedName const ** p9 READ getP9) + + Q_PROPERTY(DefinedName const * const * p10 READ getP10) + Q_PROPERTY(RedefinedName const * const * p11 READ getP11) + + Q_PROPERTY(DefinedTemplateName p16 READ getP16) + Q_PROPERTY(RedefinedTemplateName p17 READ getP17) + + Q_PROPERTY(DefinedTemplateName p18 READ getP18) + Q_PROPERTY(RedefinedTemplateName p19 READ getP19) + + Q_PROPERTY(DefinedTemplateName p20 READ getP20) + Q_PROPERTY(RedefinedTemplateName p21 READ getP21) + +signals: + void signal1(ActualName); + void signal2(DefinedName); + void signal3(RedefinedName); + +public slots: + void slot1(ActualName x) { v = x; } + void slot2(DefinedName x) { v = x; } + void slot3(RedefinedName x) { v = x; } + +public: + void foo() {} + + ActualName v; + + ActualName *vp; + ActualName const *vcp; + + ActualTemplateName tv; + ActualTemplateName tvpp; + ActualTemplateName tvcpc; + + ActualName getP0() { return v; } + ActualName getP1() { return v; } + + DefinedName getP2() { return v; } + RedefinedName getP3() { return v; } + + DefinedName * getP4() { return &v; } + RedefinedName * getP5() { return &v; } + + DefinedName ** getP6() { return &vp; } + RedefinedName ** getP7() { return &vp; } + + DefinedName const ** getP8() { return &vcp; } + RedefinedName const ** getP9() { return &vcp; } + + DefinedName const * const * getP10() const { return &vcp; } + RedefinedName const * const * getP11() const { return &vcp; } + + DefinedTemplateName getP16() { return tv; } + RedefinedTemplateName getP17() { return tv; } + + DefinedTemplateName getP18() { return tvpp; } + RedefinedTemplateName getP19() { return tvpp; } + + DefinedTemplateName getP20() { return tvcpc; } + RedefinedTemplateName getP21() { return tvcpc; } +}; + +void tst_Moc::redefinedNames() +{ + RedefinitionTest tst; + const QMetaObject *mobj = tst.metaObject(); + QVERIFY(mobj->indexOfProperty("p1") != -1); + + // Use the true slot name rather than the declared name + QVERIFY(QObject::connect(&tst, SIGNAL(signal1(ActualName)), + &tst, SLOT(slot1(ActualName)))); + + QVERIFY(QObject::connect(&tst, SIGNAL(signal2(ActualName)), + &tst, SLOT(slot2(ActualName)))); + + QVERIFY(QObject::connect(&tst, SIGNAL(signal3(ActualName)), + &tst, SLOT(slot3(ActualName)))); + + // Use the declared slot name rather than the true name + QVERIFY(QObject::connect(&tst, SIGNAL(signal1(ActualName)), + &tst, SLOT(slot2(DefinedName)))); + + QVERIFY(QObject::connect(&tst, SIGNAL(signal1(ActualName)), + &tst, SLOT(slot3(RedefinedName)))); + + // Use the declared signal name rather than the true name + QVERIFY(QObject::connect(&tst, SIGNAL(signal2(DefinedName)), + &tst, SLOT(slot1(ActualName)))); + + QVERIFY(QObject::connect(&tst, SIGNAL(signal3(RedefinedName)), + &tst, SLOT(slot1(ActualName)))); + + // Use both declared names + QVERIFY(QObject::connect(&tst, SIGNAL(signal2(DefinedName)), + &tst, SLOT(slot2(DefinedName)))); + + QVERIFY(QObject::connect(&tst, SIGNAL(signal2(DefinedName)), + &tst, SLOT(slot3(RedefinedName)))); + + QVERIFY(QObject::connect(&tst, SIGNAL(signal3(RedefinedName)), + &tst, SLOT(slot2(DefinedName)))); + + QVERIFY(QObject::connect(&tst, SIGNAL(signal3(RedefinedName)), + &tst, SLOT(slot3(RedefinedName)))); +} + + QTEST_APPLESS_MAIN(tst_Moc) #include "tst_moc.moc" From 6225e3ba01ef918724a15dd1311ab5d8205be534 Mon Sep 17 00:00:00 2001 From: Matthew Vogt Date: Thu, 23 Feb 2012 11:31:05 +1000 Subject: [PATCH 07/37] Add workaround for projects using 'QT += declarative' The code previously exported by the declarative library has been migrated to the qml and quick libraries, and the symbol names have been changed accordingly. To allow existing projects to continue to build, the declarative module now contains a set of definitions redefining the deprecated class names to their replacement names. To make this work, a dependency on the declarative module now automatically adds a dependency on the qml module in order to make the new library available for linking. This is a temporary change to prevent breaking existing projects that depend on the declarative module. After clients have had an opportunity to update their code to the use the new interfaces, it can be removed. Task-number: QTBUG-23737 Change-Id: Idee6ac627858856802bb1be29e9a4a079da73688 Reviewed-by: Kent Hansen Reviewed-by: Lars Knoll Reviewed-by: Martin Jones --- mkspecs/features/qt.prf | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index b7da02e5bb..1c2aec49c6 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -1,5 +1,32 @@ CONFIG *= moc thread +# Temporary fixes to avoid QDeclarative -> QQml breakage: + +# Projects depending on declarative will now get the full set of +# -DOldSymbol=NewSymbol definitions added to their configuration +# so that the old symbol names still compile. All code previously +# in the declarative library is now in the qml library. +contains(QT, qmldevtools):!contains(QT, declarative) { + QT += declarative +} +contains(QT, qmldevtools-private):!contains(QT, declarative-private) { + QT += declarative-private +} + +contains(QT, quick):!contains(QT, declarative) { + QT += declarative +} +contains(QT, quick-private):!contains(QT, declarative-private) { + QT += declarative-private +} + +contains(QT, declarative):!contains(QT, qml) { + QT += qml +} +contains(QT, declarative-private):!contains(QT, qml-private) { + QT += qml-private +} + #handle defines win32 { qt_static:DEFINES += QT_NODLL From 643fd1afdd4b83641e08cc8db04b17416d835121 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 26 Feb 2012 11:53:56 +0100 Subject: [PATCH 08/37] QFontEngine: remove unused and buggy grayPalette() QFontEngine::grayPalette() mistakenly returns an empty vector, so even if there's a user (the class it exported, after all), it cannot correctly use it. So, just remove it. Change-Id: Id5f70139e5f6ed9a2a3f28400cd0750d14cb7dc0 Reviewed-by: Olivier Goffart Reviewed-by: Jiang Jiang --- src/gui/text/qfontengine.cpp | 19 ------------------- src/gui/text/qfontengine_p.h | 1 - 2 files changed, 20 deletions(-) diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index a084a3dd8c..4bceb28ef7 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1148,25 +1148,6 @@ QByteArray QFontEngine::convertToPostscriptFontFamilyName(const QByteArray &fami return f; } -class QRgbGreyPalette: public QVector -{ -public: - QRgbGreyPalette() - { - resize(256); - QRgb *it = data(); - for (int i = 0; i < size(); ++i, ++it) - *it = 0xff000000 | i | (i<<8) | (i<<16); - } -}; - -Q_GLOBAL_STATIC(QVector, qt_grayPalette) - -const QVector &QFontEngine::grayPalette() -{ - return *qt_grayPalette(); -} - QFixed QFontEngine::lastRightBearing(const QGlyphLayout &glyphs, bool round) { if (glyphs.numGlyphs >= 1) { diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 023882d560..cf9c26f2a4 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -278,7 +278,6 @@ public: int m_subPixelPositionCount; // Number of positions within a single pixel for this cache protected: - static const QVector &grayPalette(); QFixed lastRightBearing(const QGlyphLayout &glyphs, bool round = false); private: From 67ac8d72d5288c77540ed0db3039695ff533b002 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 25 Feb 2012 13:56:11 +0100 Subject: [PATCH 09/37] QTestlib: no need to use the preprocessor to distinguish qreal The code paths are actually the same, so merge them. Change-Id: I456b8a9a825cccdd80cd6a52a0a6737cde252363 Reviewed-by: Jason McDonald --- src/testlib/qtestcase.h | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index e4f4020461..c64420b000 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -264,38 +264,20 @@ namespace QTest template bool qCompare(T1 const &, T2 const &, const char *, const char *, const char *, int); -#if defined(QT_COORD_TYPE) && (defined(Q_PROCESSOR_ARM) || defined(QT_NO_FPU) || defined(Q_OS_WINCE)) template <> - inline bool qCompare(qreal const &t1, float const &t2, const char *actual, + inline bool qCompare(double const &t1, float const &t2, const char *actual, const char *expected, const char *file, int line) { - return qCompare(t1, qreal(t2), actual, expected, file, line); + return qCompare(qreal(t1), qreal(t2), actual, expected, file, line); } template <> - inline bool qCompare(float const &t1, qreal const &t2, const char *actual, + inline bool qCompare(float const &t1, double const &t2, const char *actual, const char *expected, const char *file, int line) { - return qCompare(qreal(t1), t2, actual, expected, file, line); + return qCompare(qreal(t1), qreal(t2), actual, expected, file, line); } -#elif defined(QT_COORD_TYPE) || defined(Q_PROCESSOR_ARM) || defined(QT_NO_FPU) || defined(Q_OS_WINCE) - template <> - inline bool qCompare(qreal const &t1, double const &t2, const char *actual, - const char *expected, const char *file, int line) - { - return qCompare(float(t1), float(t2), actual, expected, file, line); - } - - template <> - inline bool qCompare(double const &t1, qreal const &t2, const char *actual, - const char *expected, const char *file, int line) - { - return qCompare(float(t1), float(t2), actual, expected, file, line); - } - -#endif - template inline bool qCompare(const T *t1, const T *t2, const char *actual, const char *expected, const char *file, int line) From c06e932c7307530d23d218ef7ed86bc06583f2d1 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sat, 25 Feb 2012 17:00:15 +0100 Subject: [PATCH 10/37] Move the QString comparison operator as non member function The operator== and similar should not be member of the class. This ensure a symertry. Indeed, consider this code string == string1 + string2; string1 + string2 == string; The first line compile fine even if QStringBuilder is used, because QStringBuilder will be converted to QString implicitly. But the second line do not compile if the operator== is a member of QString, because the implicit conversion rules do not apply. For this reason, the symetric operators should not be declared as member. Change-Id: I3f7c11fab45a9133f7a424bdfcb894f97da9282b Reviewed-by: Thiago Macieira --- src/corelib/tools/qstring.cpp | 44 ++++++++++++++++++++--------------- src/corelib/tools/qstring.h | 12 +++++----- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 14b8782dae..d0c5506228 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -2139,7 +2139,8 @@ QString &QString::replace(QChar c, const QLatin1String &after, Qt::CaseSensitivi /*! - Returns true if string \a other is equal to this string; otherwise + \relates QString + Returns true if string \a s1 is equal to string \a s2; otherwise returns false. The comparison is based exclusively on the numeric Unicode values of @@ -2147,12 +2148,12 @@ QString &QString::replace(QChar c, const QLatin1String &after, Qt::CaseSensitivi expect. Consider sorting user-interface strings with localeAwareCompare(). */ -bool QString::operator==(const QString &other) const +bool operator==(const QString &s1, const QString &s2) { - if (d->size != other.d->size) + if (s1.d->size != s2.d->size) return false; - return qMemEquals(d->data(), other.d->data(), d->size); + return qMemEquals(s1.d->data(), s2.d->data(), s1.d->size); } /*! @@ -2207,17 +2208,18 @@ bool QString::operator==(const QLatin1String &other) const */ /*! - Returns true if this string is lexically less than string \a - other; otherwise returns false. + \relates QString + Returns true if string \a s1 is lexically less than string + \a s2; otherwise returns false. The comparison is based exclusively on the numeric Unicode values of the characters and is very fast, but is not what a human would expect. Consider sorting user-interface strings using the QString::localeAwareCompare() function. */ -bool QString::operator<(const QString &other) const +bool operator<(const QString &s1, const QString &s2) { - return ucstrcmp(constData(), length(), other.constData(), other.length()) < 0; + return ucstrcmp(s1.constData(), s1.length(), s2.constData(), s2.length()) < 0; } /*! @@ -2268,10 +2270,11 @@ bool QString::operator<(const QLatin1String &other) const go through QObject::tr(), for example. */ -/*! \fn bool QString::operator<=(const QString &other) const +/*! \fn bool operator<=(const QString &s1, const QString &s2) + \relates QString - Returns true if this string is lexically less than or equal to - string \a other; otherwise returns false. + Returns true if string \a s1 is lexically less than or equal to + string \a s2; otherwise returns false. The comparison is based exclusively on the numeric Unicode values of the characters and is very fast, but is not what a human would @@ -2311,10 +2314,11 @@ bool QString::operator<(const QLatin1String &other) const go through QObject::tr(), for example. */ -/*! \fn bool QString::operator>(const QString &other) const +/*! \fn bool operator>(const QString &s1, const QString &s2) + \relates QString - Returns true if this string is lexically greater than string \a - other; otherwise returns false. + Returns true if string \a s1 is lexically greater than string \a + s2; otherwise returns false. The comparison is based exclusively on the numeric Unicode values of the characters and is very fast, but is not what a human would @@ -2370,10 +2374,11 @@ bool QString::operator>(const QLatin1String &other) const for example. */ -/*! \fn bool QString::operator>=(const QString &other) const +/*! \fn bool operator>=(const QString &s1, const QString &s2) + \relates QString - Returns true if this string is lexically greater than or equal to - string \a other; otherwise returns false. + Returns true if string \a s1 is lexically greater than or equal to + string \a s2; otherwise returns false. The comparison is based exclusively on the numeric Unicode values of the characters and is very fast, but is not what a human would @@ -2413,9 +2418,10 @@ bool QString::operator>(const QLatin1String &other) const for example. */ -/*! \fn bool QString::operator!=(const QString &other) const +/*! \fn bool operator!=(const QString &s1, const QString &s2) + \relates QString - Returns true if this string is not equal to string \a other; + Returns true if string \a s1 is not equal to string \a s2; otherwise returns false. The comparison is based exclusively on the numeric Unicode values diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 12a5acb689..bdadba8bd4 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -486,12 +486,12 @@ public: static QString number(qulonglong, int base=10); static QString number(double, char f='g', int prec=6); - bool operator==(const QString &s) const; - bool operator<(const QString &s) const; - inline bool operator>(const QString &s) const { return s < *this; } - inline bool operator!=(const QString &s) const { return !operator==(s); } - inline bool operator<=(const QString &s) const { return !operator>(s); } - inline bool operator>=(const QString &s) const { return !operator<(s); } + friend Q_CORE_EXPORT bool operator==(const QString &s1, const QString &s2); + friend Q_CORE_EXPORT bool operator<(const QString &s1, const QString &s2); + friend inline bool operator>(const QString &s1, const QString &s2) { return s2 < s1; } + friend inline bool operator!=(const QString &s1, const QString &s2) { return !(s1 == s2); } + friend inline bool operator<=(const QString &s1, const QString &s2) { return !(s1 > s2); } + friend inline bool operator>=(const QString &s1, const QString &s2) { return !(s1 < s2); } bool operator==(const QLatin1String &s) const; bool operator<(const QLatin1String &s) const; From f79768cd39a58529656b320bfaa9c096eccb191d Mon Sep 17 00:00:00 2001 From: Matthew Vogt Date: Fri, 24 Feb 2012 10:51:42 +1000 Subject: [PATCH 11/37] Remove Q_DECLARATIVE_EXPORT and Q_QTQUICK1_EXPORT Theses definitions are no longer required in qtbase. Task-number: QTBUG-23737 Change-Id: Ib11e5840086b44120adabe83a1b068c991920f2f Reviewed-by: Martin Jones Reviewed-by: Thiago Macieira --- src/corelib/global/qglobal.h | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 1fb5778f14..fb6eaeb452 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -610,16 +610,6 @@ class QDataStream; # else # define Q_SVG_EXPORT Q_DECL_IMPORT # endif -# if defined(QT_BUILD_QTQUICK1_LIB) -# define Q_QTQUICK1_EXPORT Q_DECL_EXPORT -# else -# define Q_QTQUICK1_EXPORT Q_DECL_IMPORT -# endif -# if defined(QT_BUILD_DECLARATIVE_LIB) -# define Q_DECLARATIVE_EXPORT Q_DECL_EXPORT -# else -# define Q_DECLARATIVE_EXPORT Q_DECL_IMPORT -# endif # if defined(QT_BUILD_OPENGL_LIB) # define Q_OPENGL_EXPORT Q_DECL_EXPORT # else @@ -680,8 +670,6 @@ class QDataStream; # define Q_SQL_EXPORT Q_DECL_IMPORT # define Q_NETWORK_EXPORT Q_DECL_IMPORT # define Q_SVG_EXPORT Q_DECL_IMPORT -# define Q_DECLARATIVE_EXPORT Q_DECL_IMPORT -# define Q_QTQUICK1_EXPORT Q_DECL_IMPORT # define Q_CANVAS_EXPORT Q_DECL_IMPORT # define Q_OPENGL_EXPORT Q_DECL_IMPORT # define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT @@ -714,8 +702,6 @@ class QDataStream; # define Q_SQL_EXPORT Q_DECL_EXPORT # define Q_NETWORK_EXPORT Q_DECL_EXPORT # define Q_SVG_EXPORT Q_DECL_EXPORT -# define Q_DECLARATIVE_EXPORT Q_DECL_EXPORT -# define Q_QTQUICK1_EXPORT Q_DECL_EXPORT # define Q_OPENGL_EXPORT Q_DECL_EXPORT # define Q_MULTIMEDIA_EXPORT Q_DECL_EXPORT # define Q_OPENVG_EXPORT Q_DECL_EXPORT @@ -734,8 +720,6 @@ class QDataStream; # define Q_SQL_EXPORT # define Q_NETWORK_EXPORT # define Q_SVG_EXPORT -# define Q_DECLARATIVE_EXPORT -# define Q_QTQUICK1_EXPORT # define Q_OPENGL_EXPORT # define Q_MULTIMEDIA_EXPORT # define Q_OPENVG_EXPORT From 6c1bdc1854a7700c2b3a345b95f6a2fdca84037d Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 23 Feb 2012 22:40:01 +0100 Subject: [PATCH 12/37] QFontMetrics: make conversion from QFont to QFontMetrics explicit There is no user of this in qtbase, and I don't think this is a desireable feature anyway. Change-Id: Ifebba5872b0eadb0daba3c3cd5f8b19abeed5c12 Reviewed-by: Lars Knoll Reviewed-by: Olivier Goffart --- src/gui/text/qfontmetrics.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qfontmetrics.h b/src/gui/text/qfontmetrics.h index 7ddc8975e4..e48460ffd0 100644 --- a/src/gui/text/qfontmetrics.h +++ b/src/gui/text/qfontmetrics.h @@ -61,7 +61,7 @@ class QRect; class Q_GUI_EXPORT QFontMetrics { public: - QFontMetrics(const QFont &); + explicit QFontMetrics(const QFont &); QFontMetrics(const QFont &, QPaintDevice *pd); QFontMetrics(const QFontMetrics &); ~QFontMetrics(); @@ -127,7 +127,7 @@ private: class Q_GUI_EXPORT QFontMetricsF { public: - QFontMetricsF(const QFont &); + explicit QFontMetricsF(const QFont &); QFontMetricsF(const QFont &, QPaintDevice *pd); QFontMetricsF(const QFontMetrics &); QFontMetricsF(const QFontMetricsF &); From ec234625c0bde3eeb67cd4681cb66277bdf115b3 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 29 Feb 2012 12:28:57 +0100 Subject: [PATCH 13/37] Remove include for no-longer-supported compiler. Change-Id: I162da3e373a0191f69e50e110114ef78c2d5fc66 Reviewed-by: Olivier Goffart --- src/corelib/tools/qstringbuilder.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index 4c963185ad..0fd164c2e4 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -45,12 +45,6 @@ #include #include -#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) -# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ == 0) -# include -# endif -#endif - #include QT_BEGIN_HEADER From 8b33be0054517e7506f1ed4378232fa81e710df1 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 28 Feb 2012 22:27:48 +0100 Subject: [PATCH 14/37] QScopedValueRollback: make constructor explicit I'm not even sure whether you could implicitly convert a T& into a QScopedValueRollback, seeing as the constructor takes a non-const reference, but it looks wrong without explicit and QObject o = new QObject(parent); also won't compile even with implicit QObject(QObject*) under a conformant compiler because of the disabled copy constructor, and we still make QObject(QObject*) explicit, so add it here, too. Change-Id: I722a6e8431644e450fe2b401ccfb707a8e982380 Reviewed-by: Olivier Goffart Reviewed-by: Lars Knoll Reviewed-by: Shane Kearns --- src/corelib/tools/qscopedvaluerollback.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qscopedvaluerollback.h b/src/corelib/tools/qscopedvaluerollback.h index 23d2d9eda0..d53cabd315 100644 --- a/src/corelib/tools/qscopedvaluerollback.h +++ b/src/corelib/tools/qscopedvaluerollback.h @@ -51,7 +51,7 @@ template class QScopedValueRollback { public: - QScopedValueRollback(T &var) : + explicit QScopedValueRollback(T &var) : varRef(var) { oldValue = varRef; From 85e050b0b3f1eb36007abd6b12158ce3496a4dc4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 27 Feb 2012 22:06:54 +0100 Subject: [PATCH 15/37] Make qlocale.h not depend on qvariant.h. As a consequence, we have to add more explicit includes. Change-Id: Ib3137031f0554b846c7bbd08f1f7df10dfeb8e61 Reviewed-by: Olivier Goffart --- src/corelib/io/qstandardpaths_unix.cpp | 1 + src/corelib/json/qjsonarray.cpp | 1 + src/corelib/json/qjsondocument.cpp | 1 + src/corelib/json/qjsonobject.cpp | 1 + src/corelib/tools/qlocale.h | 1 - src/corelib/tools/qlocale_p.h | 2 +- 6 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp index 62c846738e..5499751751 100644 --- a/src/corelib/io/qstandardpaths_unix.cpp +++ b/src/corelib/io/qstandardpaths_unix.cpp @@ -42,6 +42,7 @@ #include "qstandardpaths.h" #include #include +#include #include #include #include diff --git a/src/corelib/json/qjsonarray.cpp b/src/corelib/json/qjsonarray.cpp index 0eb1974147..6ffb9639f7 100644 --- a/src/corelib/json/qjsonarray.cpp +++ b/src/corelib/json/qjsonarray.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include "qjsonwriter_p.h" diff --git a/src/corelib/json/qjsondocument.cpp b/src/corelib/json/qjsondocument.cpp index 8a7fa760ae..c2204bf696 100644 --- a/src/corelib/json/qjsondocument.cpp +++ b/src/corelib/json/qjsondocument.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include "qjsonwriter_p.h" #include "qjsonparser_p.h" diff --git a/src/corelib/json/qjsonobject.cpp b/src/corelib/json/qjsonobject.cpp index b7af8c22cf..289a752c8b 100644 --- a/src/corelib/json/qjsonobject.cpp +++ b/src/corelib/json/qjsonobject.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include "qjson_p.h" #include "qjsonwriter_p.h" diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h index c029f627b2..2ecd934100 100644 --- a/src/corelib/tools/qlocale.h +++ b/src/corelib/tools/qlocale.h @@ -42,7 +42,6 @@ #ifndef QLOCALE_H #define QLOCALE_H -#include #include #include diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index c6902ca206..ad7c9706c4 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -55,7 +55,7 @@ #include "QtCore/qstring.h" #include "QtCore/qvarlengtharray.h" -#include "QtCore/qmetatype.h" +#include "QtCore/qvariant.h" #include "qlocale.h" From 612152fad8f531e66ecda9ef72eae32061af7139 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 27 Feb 2012 21:57:12 +0100 Subject: [PATCH 16/37] Make qobject_p.h not need qvariant.h. Move definition of ExtraData to the implementation file. As a side effect, we need to include qhash.h in some other places. Change-Id: I8bb4ec0940ae51c7d6961c9a51adb80fd444e1e3 Reviewed-by: Olivier Goffart --- src/corelib/io/qfilesystemwatcher_polling_p.h | 1 + src/corelib/kernel/qeventdispatcher_win_p.h | 1 + src/corelib/kernel/qobject.cpp | 10 ++++++++++ src/corelib/kernel/qobject_p.h | 11 +---------- src/gui/kernel/qopenglcontext_p.h | 2 -- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/corelib/io/qfilesystemwatcher_polling_p.h b/src/corelib/io/qfilesystemwatcher_polling_p.h index 14f6345412..e50082c6d3 100644 --- a/src/corelib/io/qfilesystemwatcher_polling_p.h +++ b/src/corelib/io/qfilesystemwatcher_polling_p.h @@ -58,6 +58,7 @@ #include #include #include +#include #include "qfilesystemwatcher_p.h" diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h index c404967e6a..a831ad39e8 100644 --- a/src/corelib/kernel/qeventdispatcher_win_p.h +++ b/src/corelib/kernel/qeventdispatcher_win_p.h @@ -55,6 +55,7 @@ #include "QtCore/qabstracteventdispatcher.h" #include "QtCore/qt_windows.h" +#include "QtCore/qhash.h" #include "qabstracteventdispatcher_p.h" diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 8fa5dcdcff..2231518253 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -69,6 +69,16 @@ QT_BEGIN_NAMESPACE +struct QObjectPrivate::ExtraData +{ + ExtraData() {} +#ifndef QT_NO_USERDATA + QVector userData; +#endif + QList propertyNames; + QList propertyValues; +}; + static int DIRECT_CONNECTION_ONLY = 0; static int *queuedConnectionTypes(const QList &typeNames) diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index fa1aee8173..f75d4464b2 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -60,7 +60,6 @@ #include "QtCore/qlist.h" #include "QtCore/qvector.h" #include "QtCore/qreadwritelock.h" -#include "QtCore/qvariant.h" QT_BEGIN_NAMESPACE @@ -98,16 +97,8 @@ class Q_CORE_EXPORT QObjectPrivate : public QObjectData { Q_DECLARE_PUBLIC(QObject) + struct ExtraData; public: - struct ExtraData - { - ExtraData() {} -#ifndef QT_NO_USERDATA - QVector userData; -#endif - QList propertyNames; - QList propertyValues; - }; typedef void (*StaticMetaCallFunction)(QObject *, QMetaObject::Call, int, void **); struct Connection diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h index 3e2c35f088..d5c4d6c762 100644 --- a/src/gui/kernel/qopenglcontext_p.h +++ b/src/gui/kernel/qopenglcontext_p.h @@ -49,9 +49,7 @@ #include #include -#ifndef QT_NO_DEBUG #include -#endif QT_BEGIN_HEADER From e1cc0d6bbc2c65b10f23b2935a68a3a34b7c26a0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 29 Feb 2012 11:54:29 +0100 Subject: [PATCH 17/37] Allow QChar::SpecialCharacter with QStringBuilder. Change-Id: I3c91fd516bb13e5534aa6f26ee9df745c990dfb5 Reviewed-by: Olivier Goffart --- src/corelib/tools/qstringbuilder.h | 10 ++++++++++ .../qstringbuilder/qstringbuilder1/stringbuilder.cpp | 3 +++ 2 files changed, 13 insertions(+) diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h index 0fd164c2e4..e34425be7e 100644 --- a/src/corelib/tools/qstringbuilder.h +++ b/src/corelib/tools/qstringbuilder.h @@ -167,6 +167,16 @@ template <> struct QConcatenable : private QAbstractConcatenable { *out++ = c; } }; +template <> struct QConcatenable : private QAbstractConcatenable +{ + typedef QChar::SpecialCharacter type; + typedef QString ConvertTo; + enum { ExactSize = true }; + static int size(const QChar::SpecialCharacter) { return 1; } + static inline void appendTo(const QChar::SpecialCharacter c, QChar *&out) + { *out++ = c; } +}; + template <> struct QConcatenable : private QAbstractConcatenable { typedef QCharRef type; diff --git a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp index afc16078b8..556b9ac16a 100644 --- a/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp +++ b/tests/auto/corelib/tools/qstringbuilder/qstringbuilder1/stringbuilder.cpp @@ -73,6 +73,7 @@ void runScenario() QString string(l1string); QStringRef stringref(&string, 2, 10); QLatin1Char achar('c'); + QChar::SpecialCharacter special(QChar::Nbsp); QString r2(QLatin1String(LITERAL LITERAL)); QString r3 = QString::fromUtf8(UTF8_LITERAL UTF8_LITERAL); QString r; @@ -97,6 +98,8 @@ void runScenario() QCOMPARE(r, QString(string P achar)); r = achar + string; QCOMPARE(r, QString(achar P string)); + r = special + string; + QCOMPARE(r, QString(special P string)); #ifdef Q_COMPILER_UNICODE_STRINGS r = QStringLiteral(UNICODE_LITERAL); From 85161946337c25b1d23d661d4d748ab0270db2f4 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 28 Feb 2012 14:49:19 +0100 Subject: [PATCH 18/37] don't duplicate QLibraryInfo declaration there is no reason for doing that. there is even reason for *not* doing it (the enums running out of sync). Change-Id: Ieb7d015ca497a6675cc85da4c2e0af0c1533dd7a Reviewed-by: Joerg Bornemann --- qmake/option.h | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/qmake/option.h b/qmake/option.h index b8a3b561fa..b812f14a49 100644 --- a/qmake/option.h +++ b/qmake/option.h @@ -46,6 +46,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -216,28 +217,6 @@ private: inline QString fixEnvVariables(const QString &x) { return Option::fixString(x, Option::FixEnvVars); } inline QStringList splitPathList(const QString &paths) { return paths.split(Option::dirlist_sep); } -// this is a stripped down version of the one found in QtCore -class QLibraryInfo -{ -public: - enum LibraryLocation - { - PrefixPath, - DocumentationPath, - HeadersPath, - LibrariesPath, - BinariesPath, - PluginsPath, - DataPath, - TranslationsPath, - SettingsPath, - ExamplesPath, - ImportsPath, - TestsPath - }; - static QString location(LibraryLocation); -}; - QT_END_NAMESPACE #endif // OPTION_H From da08210494c132e8990ae3ba2ddb78983d266461 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 28 Feb 2012 09:54:53 +0100 Subject: [PATCH 19/37] remove pointless ifdefs configure always defines all of these constants. the exception is SettingsPath which is unix-only, so make the #ifdef explicit about that. Change-Id: I339d2d7cb9d188a8e74d79310c3a80b5d4dbb806 Reviewed-by: Thiago Macieira --- src/corelib/global/qlibraryinfo.cpp | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index c871675334..72db761e2d 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -226,66 +226,44 @@ QLibraryInfo::location(LibraryLocation loc) if(!QLibraryInfoPrivate::configuration()) { const char *path = 0; switch (loc) { -#ifdef QT_CONFIGURE_PREFIX_PATH case PrefixPath: path = QT_CONFIGURE_PREFIX_PATH; break; -#endif -#ifdef QT_CONFIGURE_DOCUMENTATION_PATH case DocumentationPath: path = QT_CONFIGURE_DOCUMENTATION_PATH; break; -#endif -#ifdef QT_CONFIGURE_HEADERS_PATH case HeadersPath: path = QT_CONFIGURE_HEADERS_PATH; break; -#endif -#ifdef QT_CONFIGURE_LIBRARIES_PATH case LibrariesPath: path = QT_CONFIGURE_LIBRARIES_PATH; break; -#endif -#ifdef QT_CONFIGURE_BINARIES_PATH case BinariesPath: path = QT_CONFIGURE_BINARIES_PATH; break; -#endif -#ifdef QT_CONFIGURE_PLUGINS_PATH case PluginsPath: path = QT_CONFIGURE_PLUGINS_PATH; break; -#endif -#ifdef QT_CONFIGURE_IMPORTS_PATH case ImportsPath: path = QT_CONFIGURE_IMPORTS_PATH; break; -#endif -#ifdef QT_CONFIGURE_DATA_PATH case DataPath: path = QT_CONFIGURE_DATA_PATH; break; -#endif -#ifdef QT_CONFIGURE_TRANSLATIONS_PATH case TranslationsPath: path = QT_CONFIGURE_TRANSLATIONS_PATH; break; -#endif -#ifdef QT_CONFIGURE_SETTINGS_PATH +#ifndef Q_OS_WIN // On Windows we use the registry case SettingsPath: path = QT_CONFIGURE_SETTINGS_PATH; break; #endif -#ifdef QT_CONFIGURE_EXAMPLES_PATH case ExamplesPath: path = QT_CONFIGURE_EXAMPLES_PATH; break; -#endif -#ifdef QT_CONFIGURE_TESTS_PATH case TestsPath: path = QT_CONFIGURE_TESTS_PATH; break; -#endif default: break; } From 3b1b5be911102402cb0d932a4da87319d2d04435 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 28 Feb 2012 10:20:34 +0100 Subject: [PATCH 20/37] remove bizarre padstring voodoo evidently, The Author had no clue that the compiler will do that automatically. as it happens, the windows configure already did it right. Change-Id: I7ebc018c254b316205348874ffa527526329b630 Reviewed-by: Thiago Macieira --- config.tests/unix/padstring | 22 ---------- configure | 87 +++++++++++++------------------------ 2 files changed, 29 insertions(+), 80 deletions(-) delete mode 100755 config.tests/unix/padstring diff --git a/config.tests/unix/padstring b/config.tests/unix/padstring deleted file mode 100755 index 283475d071..0000000000 --- a/config.tests/unix/padstring +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -LEN="$1" -STR="$2" -PAD='\0' -STRLEN=`echo $STR | wc -c` -RES="$STR" - -EXTRALEN=`expr $LEN - $STRLEN` -while [ "$EXTRALEN" -gt 32 ]; do - RES="$RES$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD$PAD" - EXTRALEN=`expr $EXTRALEN - 32` -done -while [ "$EXTRALEN" -gt 0 ]; do - RES="$RES$PAD" - EXTRALEN=`expr $EXTRALEN - 1` -done -cat < "$outpath/src/corelib/global/qconfig.cpp.new" <> "$outpath/src/corelib/global/qconfig.cpp.new" <> "$outpath/src/corelib/global/qconfig.cpp.new" </dev/null 2>&1; then - EVALKEY=`"$relpath/config.tests/unix/padstring" 524 "qt_qevalkey="` + EVALKEY=qt_qevalkey= fi if [ -n "$EVALKEY" ]; then From 486bde8372b30a2133e911268147704c699f8284 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 28 Feb 2012 11:01:52 +0100 Subject: [PATCH 21/37] make qlibraryinfo table-driven switch blocks are noisy. this is nicer. reshuffled the LibraryLocation enum to make table lookups possible and future-safe. using pointer-free tables to avoid adding data relocations. Change-Id: I70ec2c2142ce02a15e67284e4b285d754d930da3 Reviewed-by: Thiago Macieira --- configure | 65 +++++++-------- src/corelib/global/qlibraryinfo.cpp | 120 +++++++--------------------- src/corelib/global/qlibraryinfo.h | 8 +- tools/configure/configureapp.cpp | 59 ++++++-------- 4 files changed, 90 insertions(+), 162 deletions(-) diff --git a/configure b/configure index 3101982f84..7aa8adaa43 100755 --- a/configure +++ b/configure @@ -3995,36 +3995,40 @@ if [ ! -z "$QT_HOST_PREFIX" ]; then #if defined(QT_BOOTSTRAPPED) || defined(QT_BUILD_QMAKE) /* Installation Info */ -static const char qt_configure_prefix_path_str [256 + 12] = "qt_prfxpath=$QT_HOST_PREFIX"; -static const char qt_configure_documentation_path_str[256 + 12] = "qt_docspath=$QT_HOST_PREFIX/doc"; -static const char qt_configure_headers_path_str [256 + 12] = "qt_hdrspath=$QT_HOST_PREFIX/include"; -static const char qt_configure_libraries_path_str [256 + 12] = "qt_libspath=$QT_HOST_PREFIX/lib"; -static const char qt_configure_binaries_path_str [256 + 12] = "qt_binspath=$QT_HOST_PREFIX/bin"; -static const char qt_configure_plugins_path_str [256 + 12] = "qt_plugpath=$QT_HOST_PREFIX/plugins"; -static const char qt_configure_imports_path_str [256 + 12] = "qt_impspath=$QT_HOST_PREFIX/IMPORTS"; -static const char qt_configure_data_path_str [256 + 12] = "qt_datapath=$QT_HOST_PREFIX"; -static const char qt_configure_translations_path_str [256 + 12] = "qt_trnspath=$QT_HOST_PREFIX/translations"; -static const char qt_configure_settings_path_str [256 + 12] = "qt_stngpath=$QT_INSTALL_SETTINGS"; -static const char qt_configure_examples_path_str [256 + 12] = "qt_xmplpath=$QT_INSTALL_EXAMPLES"; -static const char qt_configure_tests_path_str [256 + 12] = "qt_tstspath=$QT_INSTALL_TESTS"; +static const char qt_configure_prefix_path_strs[][256 + 12] = { + "qt_prfxpath=$QT_HOST_PREFIX", + "qt_docspath=$QT_HOST_PREFIX/doc", + "qt_hdrspath=$QT_HOST_PREFIX/include", + "qt_libspath=$QT_HOST_PREFIX/lib", + "qt_binspath=$QT_HOST_PREFIX/bin", + "qt_plugpath=$QT_HOST_PREFIX/plugins", + "qt_impspath=$QT_HOST_PREFIX/IMPORTS", + "qt_datapath=$QT_HOST_PREFIX", + "qt_trnspath=$QT_HOST_PREFIX/translations", + "qt_xmplpath=$QT_INSTALL_EXAMPLES", + "qt_tstspath=$QT_INSTALL_TESTS", +}; +static const char qt_configure_settings_path_str[256 + 12] = "qt_stngpath=$QT_INSTALL_SETTINGS"; #else // QT_BOOTSTRAPPED EOF fi cat >> "$outpath/src/corelib/global/qconfig.cpp.new" <> "$outpath/src/corelib/global/qconfig.cpp.new" <= 0 && loc < sizeof(qt_configure_prefix_path_strs)/sizeof(qt_configure_prefix_path_strs[0])) + path = qt_configure_prefix_path_strs[loc] + 12; #ifndef Q_OS_WIN // On Windows we use the registry - case SettingsPath: + else if (loc == SettingsPath) path = QT_CONFIGURE_SETTINGS_PATH; - break; #endif - case ExamplesPath: - path = QT_CONFIGURE_EXAMPLES_PATH; - break; - case TestsPath: - path = QT_CONFIGURE_TESTS_PATH; - break; - default: - break; - } if (path) ret = QString::fromLocal8Bit(path); } else { QString key; QString defaultValue; - switch(loc) { - case PrefixPath: - key = QLatin1String("Prefix"); - break; - case DocumentationPath: - key = QLatin1String("Documentation"); - defaultValue = QLatin1String("doc"); - break; - case HeadersPath: - key = QLatin1String("Headers"); - defaultValue = QLatin1String("include"); - break; - case LibrariesPath: - key = QLatin1String("Libraries"); - defaultValue = QLatin1String("lib"); - break; - case BinariesPath: - key = QLatin1String("Binaries"); - defaultValue = QLatin1String("bin"); - break; - case PluginsPath: - key = QLatin1String("Plugins"); - defaultValue = QLatin1String("plugins"); - break; - case ImportsPath: - key = QLatin1String("Imports"); - defaultValue = QLatin1String("imports"); - break; - case DataPath: - key = QLatin1String("Data"); - break; - case TranslationsPath: - key = QLatin1String("Translations"); - defaultValue = QLatin1String("translations"); - break; - case SettingsPath: - key = QLatin1String("Settings"); - break; - case ExamplesPath: - key = QLatin1String("Examples"); - break; - case TestsPath: - key = QLatin1String("Tests"); - defaultValue = QLatin1String("tests"); - break; - default: - break; + if (loc >= 0 && loc < sizeof(qtConfEntries)/sizeof(qtConfEntries[0])) { + key = QLatin1String(qtConfEntries[loc].key); + defaultValue = QLatin1String(qtConfEntries[loc].value); } +#ifndef Q_OS_WIN // On Windows we use the registry + else if (loc == SettingsPath) + key = QLatin1String("Settings"); +#endif if(!key.isNull()) { QSettings *config = QLibraryInfoPrivate::configuration(); @@ -391,9 +331,9 @@ QLibraryInfo::location(LibraryLocation loc) \value ImportsPath The location of installed QML extensions to import. \value DataPath The location of general Qt data. \value TranslationsPath The location of translation information for Qt strings. - \value SettingsPath The location for Qt settings. \value ExamplesPath The location for examples upon install. \value TestsPath The location of installed Qt testcases. + \value SettingsPath The location for Qt settings. Not applicable on Windows. \sa location() */ @@ -421,9 +361,9 @@ void qt_core_boilerplate() "Library path: %s\n" "Include path: %s\n", qt_configure_installation + 12, - qt_configure_prefix_path_str + 12, - qt_configure_libraries_path_str + 12, - qt_configure_headers_path_str + 12); + qt_configure_prefix_path_strs[QT_PREPEND_NAMESPACE(QLibraryInfo)::PrefixPath] + 12, + qt_configure_prefix_path_strs[QT_PREPEND_NAMESPACE(QLibraryInfo)::LibrariesPath] + 12, + qt_configure_prefix_path_strs[QT_PREPEND_NAMESPACE(QLibraryInfo)::HeadersPath] + 12); QT_PREPEND_NAMESPACE(qDumpCPUFeatures)(); diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h index 66f3d40792..f6234d1eb4 100644 --- a/src/corelib/global/qlibraryinfo.h +++ b/src/corelib/global/qlibraryinfo.h @@ -66,18 +66,18 @@ public: enum LibraryLocation { - PrefixPath, + PrefixPath = 0, DocumentationPath, HeadersPath, LibrariesPath, BinariesPath, PluginsPath, + ImportsPath, DataPath, TranslationsPath, - SettingsPath, ExamplesPath, - ImportsPath, - TestsPath + TestsPath, + SettingsPath = 100 }; static QString location(LibraryLocation); // ### Qt 5: consider renaming it to path() diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index b7eeea6b60..e4c9bb2010 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -2857,48 +2857,41 @@ void Configure::generateConfigfiles() << endl; if (!dictionary[ "QT_HOST_PREFIX" ].isNull()) tmpStream << "#if !defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE)" << endl; - tmpStream << "static const char qt_configure_prefix_path_str [512 + 12] = \"qt_prfxpath=" << escapeSeparators(dictionary["QT_INSTALL_PREFIX"]) << "\";" << endl - << "static const char qt_configure_documentation_path_str[512 + 12] = \"qt_docspath=" << escapeSeparators(dictionary["QT_INSTALL_DOCS"]) << "\";" << endl - << "static const char qt_configure_headers_path_str [512 + 12] = \"qt_hdrspath=" << escapeSeparators(dictionary["QT_INSTALL_HEADERS"]) << "\";" << endl - << "static const char qt_configure_libraries_path_str [512 + 12] = \"qt_libspath=" << escapeSeparators(dictionary["QT_INSTALL_LIBS"]) << "\";" << endl - << "static const char qt_configure_binaries_path_str [512 + 12] = \"qt_binspath=" << escapeSeparators(dictionary["QT_INSTALL_BINS"]) << "\";" << endl - << "static const char qt_configure_plugins_path_str [512 + 12] = \"qt_plugpath=" << escapeSeparators(dictionary["QT_INSTALL_PLUGINS"]) << "\";" << endl - << "static const char qt_configure_imports_path_str [512 + 12] = \"qt_impspath=" << escapeSeparators(dictionary["QT_INSTALL_IMPORTS"]) << "\";" << endl - << "static const char qt_configure_data_path_str [512 + 12] = \"qt_datapath=" << escapeSeparators(dictionary["QT_INSTALL_DATA"]) << "\";" << endl - << "static const char qt_configure_translations_path_str [512 + 12] = \"qt_trnspath=" << escapeSeparators(dictionary["QT_INSTALL_TRANSLATIONS"]) << "\";" << endl - << "static const char qt_configure_examples_path_str [512 + 12] = \"qt_xmplpath=" << escapeSeparators(dictionary["QT_INSTALL_EXAMPLES"]) << "\";" << endl - << "static const char qt_configure_tests_path_str [512 + 12] = \"qt_tstspath=" << escapeSeparators(dictionary["QT_INSTALL_TESTS"]) << "\";" << endl + tmpStream << "static const char qt_configure_prefix_path_strs[][12 + 512] = {" << endl + << " \"qt_prfxpath=" << escapeSeparators(dictionary["QT_INSTALL_PREFIX"]) << "\"," << endl + << " \"qt_docspath=" << escapeSeparators(dictionary["QT_INSTALL_DOCS"]) << "\"," << endl + << " \"qt_hdrspath=" << escapeSeparators(dictionary["QT_INSTALL_HEADERS"]) << "\"," << endl + << " \"qt_libspath=" << escapeSeparators(dictionary["QT_INSTALL_LIBS"]) << "\"," << endl + << " \"qt_binspath=" << escapeSeparators(dictionary["QT_INSTALL_BINS"]) << "\"," << endl + << " \"qt_plugpath=" << escapeSeparators(dictionary["QT_INSTALL_PLUGINS"]) << "\"," << endl + << " \"qt_impspath=" << escapeSeparators(dictionary["QT_INSTALL_IMPORTS"]) << "\"," << endl + << " \"qt_datapath=" << escapeSeparators(dictionary["QT_INSTALL_DATA"]) << "\"," << endl + << " \"qt_trnspath=" << escapeSeparators(dictionary["QT_INSTALL_TRANSLATIONS"]) << "\"," << endl + << " \"qt_xmplpath=" << escapeSeparators(dictionary["QT_INSTALL_EXAMPLES"]) << "\"," << endl + << " \"qt_tstspath=" << escapeSeparators(dictionary["QT_INSTALL_TESTS"]) << "\"," << endl + << "};" << endl //<< "static const char qt_configure_settings_path_str [256] = \"qt_stngpath=" << escapeSeparators(dictionary["QT_INSTALL_SETTINGS"]) << "\";" << endl ; if (!dictionary[ "QT_HOST_PREFIX" ].isNull()) { tmpStream << "#else" << endl - << "static const char qt_configure_prefix_path_str [512 + 12] = \"qt_prfxpath=" << escapeSeparators(dictionary[ "QT_HOST_PREFIX" ]) << "\";" << endl - << "static const char qt_configure_documentation_path_str[512 + 12] = \"qt_docspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/doc", true) <<"\";" << endl - << "static const char qt_configure_headers_path_str [512 + 12] = \"qt_hdrspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/include", true) <<"\";" << endl - << "static const char qt_configure_libraries_path_str [512 + 12] = \"qt_libspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/lib", true) <<"\";" << endl - << "static const char qt_configure_binaries_path_str [512 + 12] = \"qt_binspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/bin", true) <<"\";" << endl - << "static const char qt_configure_plugins_path_str [512 + 12] = \"qt_plugpath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/plugins", true) <<"\";" << endl - << "static const char qt_configure_imports_path_str [512 + 12] = \"qt_impspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/imports", true) <<"\";" << endl - << "static const char qt_configure_data_path_str [512 + 12] = \"qt_datapath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ], true) <<"\";" << endl - << "static const char qt_configure_translations_path_str [512 + 12] = \"qt_trnspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/translations", true) <<"\";" << endl - << "static const char qt_configure_examples_path_str [512 + 12] = \"qt_xmplpath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/example", true) <<"\";" << endl - << "static const char qt_configure_tests_path_str [512 + 12] = \"qt_tstspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/tests", true) <<"\";" << endl + << "static const char qt_configure_prefix_path_strs[][12 + 512] = {" << endl + << " \"qt_prfxpath=" << escapeSeparators(dictionary[ "QT_HOST_PREFIX" ]) << "\";" << endl + << " \"qt_docspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/doc", true) <<"\"," << endl + << " \"qt_hdrspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/include", true) <<"\"," << endl + << " \"qt_libspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/lib", true) <<"\"," << endl + << " \"qt_binspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/bin", true) <<"\"," << endl + << " \"qt_plugpath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/plugins", true) <<"\"," << endl + << " \"qt_impspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/imports", true) <<"\"," << endl + << " \"qt_datapath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ], true) <<"\"," << endl + << " \"qt_trnspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/translations", true) <<"\"," << endl + << " \"qt_xmplpath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/example", true) <<"\"," << endl + << " \"qt_tstspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/tests", true) <<"\"," << endl + << "};" << endl << "#endif //QT_BOOTSTRAPPED" << endl; } tmpStream << "/* strlen( \"qt_lcnsxxxx\") == 12 */" << endl << "#define QT_CONFIGURE_LICENSEE qt_configure_licensee_str + 12;" << endl << "#define QT_CONFIGURE_LICENSED_PRODUCTS qt_configure_licensed_products_str + 12;" << endl - << "#define QT_CONFIGURE_PREFIX_PATH qt_configure_prefix_path_str + 12;" << endl - << "#define QT_CONFIGURE_DOCUMENTATION_PATH qt_configure_documentation_path_str + 12;" << endl - << "#define QT_CONFIGURE_HEADERS_PATH qt_configure_headers_path_str + 12;" << endl - << "#define QT_CONFIGURE_LIBRARIES_PATH qt_configure_libraries_path_str + 12;" << endl - << "#define QT_CONFIGURE_BINARIES_PATH qt_configure_binaries_path_str + 12;" << endl - << "#define QT_CONFIGURE_PLUGINS_PATH qt_configure_plugins_path_str + 12;" << endl - << "#define QT_CONFIGURE_IMPORTS_PATH qt_configure_imports_path_str + 12;" << endl - << "#define QT_CONFIGURE_DATA_PATH qt_configure_data_path_str + 12;" << endl - << "#define QT_CONFIGURE_TRANSLATIONS_PATH qt_configure_translations_path_str + 12;" << endl - << "#define QT_CONFIGURE_EXAMPLES_PATH qt_configure_examples_path_str + 12;" << endl - << "#define QT_CONFIGURE_TESTS_PATH qt_configure_tests_path_str + 12;" << endl //<< "#define QT_CONFIGURE_SETTINGS_PATH qt_configure_settings_path_str + 12;" << endl << endl; From 1ff1486d5372177798ea3c8785a4b80a1f6cbe1e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 28 Feb 2012 22:39:07 +0100 Subject: [PATCH 22/37] QCryptographicHash: make constructor explicit The copy constructor of QCH is disabled, so there's no point in providing an implicit conversion from the Algorithm enum anyway, so make the ctor explicit. Change-Id: I4ea74ffb0963b4f49415da17778c3e6050454a6b Reviewed-by: Olivier Goffart --- src/corelib/tools/qcryptographichash.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qcryptographichash.h b/src/corelib/tools/qcryptographichash.h index 2bfc03373a..6ebe389faf 100644 --- a/src/corelib/tools/qcryptographichash.h +++ b/src/corelib/tools/qcryptographichash.h @@ -65,7 +65,7 @@ public: Sha512 }; - QCryptographicHash(Algorithm method); + explicit QCryptographicHash(Algorithm method); ~QCryptographicHash(); void reset(); From eb4828bbfd54540b2b987bbae1cd6385e49c2a67 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 28 Feb 2012 09:34:20 +0100 Subject: [PATCH 23/37] Add operator<<(QTestData &, QStringBuilder) So this code still compiles with QStringBuilder QTest::newRow("foo") << foo + bar; Change-Id: Ie82a21c8fd07ec2d27ad85015aa1a0c4e94700d6 Reviewed-by: Jason McDonald --- src/testlib/qtestdata.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/testlib/qtestdata.h b/src/testlib/qtestdata.h index 22dae76167..8849b15ddb 100644 --- a/src/testlib/qtestdata.h +++ b/src/testlib/qtestdata.h @@ -89,6 +89,14 @@ inline QTestData &operator<<(QTestData &data, const char * value) return data; } +#ifdef QT_USE_QSTRINGBUILDER +template +inline QTestData &operator<<(QTestData &data, const QStringBuilder &value) +{ + return data << typename QConcatenable >::ConvertTo(value); +} +#endif + QT_END_NAMESPACE QT_END_HEADER From 3f1a4be30263a676b7e188bf6cfa809c7788c87f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 28 Feb 2012 15:46:01 +0100 Subject: [PATCH 24/37] Make loadAcquire const. Change-Id: Iad2d60d1abe363a3b85eaf152861d0979a997d81 Reviewed-by: Thiago Macieira --- src/corelib/arch/qatomic_gcc.h | 2 +- src/corelib/arch/qatomic_ia64.h | 4 ++-- src/corelib/thread/qbasicatomic.h | 4 ++-- src/corelib/thread/qgenericatomic.h | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/corelib/arch/qatomic_gcc.h b/src/corelib/arch/qatomic_gcc.h index 225a7809eb..9edb74fa73 100644 --- a/src/corelib/arch/qatomic_gcc.h +++ b/src/corelib/arch/qatomic_gcc.h @@ -84,7 +84,7 @@ template struct QAtomicOps: QGenericAtomicOps > typedef T Type; #ifndef __ia64__ - static T loadAcquire(T &_q_value) + static T loadAcquire(const T &_q_value) { T tmp = _q_value; __sync_synchronize(); diff --git a/src/corelib/arch/qatomic_ia64.h b/src/corelib/arch/qatomic_ia64.h index d82ad12223..5108751f2a 100644 --- a/src/corelib/arch/qatomic_ia64.h +++ b/src/corelib/arch/qatomic_ia64.h @@ -143,9 +143,9 @@ template struct QBasicAtomicOps: QGenericAtomicOps static inline - T loadAcquire(T &_q_value) + T loadAcquire(const T &_q_value) { - return *static_cast(&_q_value); + return *static_cast(&_q_value); } template static inline diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index 96338c62dc..01a69dbd8b 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -136,7 +136,7 @@ public: // Atomic API, implemented in qatomic_XXX.h - T loadAcquire() { return Ops::loadAcquire(_q_value); } + T loadAcquire() const { return Ops::loadAcquire(_q_value); } void storeRelease(T newValue) { Ops::storeRelease(_q_value, newValue); } static bool isReferenceCountingNative() { return Ops::isReferenceCountingNative(); } @@ -206,7 +206,7 @@ public: void store(Type newValue) { _q_value = newValue; } // Atomic API, implemented in qatomic_XXX.h - Type loadAcquire() { return Ops::loadAcquire(_q_value); } + Type loadAcquire() const { return Ops::loadAcquire(_q_value); } void storeRelease(Type newValue) { Ops::storeRelease(_q_value, newValue); } static bool isTestAndSetNative() { return Ops::isTestAndSetNative(); } diff --git a/src/corelib/thread/qgenericatomic.h b/src/corelib/thread/qgenericatomic.h index f4d5e2f8d9..34c040c39b 100644 --- a/src/corelib/thread/qgenericatomic.h +++ b/src/corelib/thread/qgenericatomic.h @@ -85,7 +85,7 @@ template struct QGenericAtomicOps static void orderedMemoryFence() { } template static inline always_inline - T load(T &_q_value) + T load(const T &_q_value) { return _q_value; } @@ -97,9 +97,9 @@ template struct QGenericAtomicOps } template static inline always_inline - T loadAcquire(T &_q_value) + T loadAcquire(const T &_q_value) { - T tmp = *static_cast(&_q_value); + T tmp = *static_cast(&_q_value); BaseClass::acquireMemoryFence(); return tmp; } From ff004175bcd5dc23f8c080cd390b04117c9f51df Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 26 Feb 2012 23:01:46 +0100 Subject: [PATCH 25/37] QFlags: mark as Q_PRIMITIVE_TYPE I originally tried to put Q_DECLARE_TYPEINFOs into Q_DECLARE_OPERATORS_FOR_FLAGS, to declare not only the flags type, but also the underlying enum as primitive, but too many users (arguably correctly) used Q_DECLARE_OPERATORS_FOR_FLAGS at (non-global) namespace scope where QTypeInfo would have been specialised in the wrong namespace. So specialise QTypeInfo for QFlags only. Change-Id: I4af6e29aefbd9460a3d2bc6405f03cdf6b1096bc Reviewed-by: Thiago Macieira Reviewed-by: Stephen Kelly Reviewed-by: Olivier Goffart --- src/corelib/global/qtypeinfo.h | 4 ++++ tests/auto/corelib/global/qflags/tst_qflags.cpp | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h index 6297b35b9c..815be935f7 100644 --- a/src/corelib/global/qtypeinfo.h +++ b/src/corelib/global/qtypeinfo.h @@ -161,6 +161,10 @@ public: \ template<> \ Q_DECLARE_TYPEINFO_BODY(TYPE, FLAGS) +/* Specialize QTypeInfo for QFlags */ +template class QFlags; +template +Q_DECLARE_TYPEINFO_BODY(QFlags, Q_PRIMITIVE_TYPE); /* Specialize a shared type with: diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp index d466d7b8d8..2794c174ba 100644 --- a/tests/auto/corelib/global/qflags/tst_qflags.cpp +++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp @@ -123,6 +123,15 @@ void tst_QFlags::constExpr() #endif } +// (statically) check QTypeInfo for QFlags instantiations: +enum MyEnum { Zero, One, Two, Four=4 }; +Q_DECLARE_FLAGS( MyFlags, MyEnum ); +Q_DECLARE_OPERATORS_FOR_FLAGS( MyFlags ); + +Q_STATIC_ASSERT( !QTypeInfo::isComplex ); +Q_STATIC_ASSERT( !QTypeInfo::isStatic ); +Q_STATIC_ASSERT( !QTypeInfo::isLarge ); +Q_STATIC_ASSERT( !QTypeInfo::isPointer ); QTEST_MAIN(tst_QFlags) #include "tst_qflags.moc" From fb4dccee9a8d616ec43390f855caca08594d75b8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 29 Feb 2012 12:57:34 +0100 Subject: [PATCH 26/37] Fix build of QNetworkReply benchmark with QT_USE_QSTRINGBUILDER. Change-Id: Ie46126aed0d2e83dc7784c027066c789d3fd7652 Reviewed-by: Olivier Goffart --- .../network/access/qnetworkreply/tst_qnetworkreply.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp index fe9efa55b7..16f9625eba 100644 --- a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -530,7 +530,7 @@ void tst_qnetworkreply::downloadPerformance() // unlike the above function, this one tries to send as fast as possible // and measures how fast it was. TimedSender sender(5000); - QNetworkRequest request("debugpipe://127.0.0.1:" + QString::number(sender.serverPort()) + "/?bare=1"); + QNetworkRequest request(QUrl(QStringLiteral("debugpipe://127.0.0.1:") + QString::number(sender.serverPort()) + QStringLiteral("/?bare=1"))); QNetworkReplyPtr reply = manager.get(request); DataReader reader(reply, false); @@ -552,7 +552,7 @@ void tst_qnetworkreply::uploadPerformance() DataGenerator generator; - QNetworkRequest request("debugpipe://127.0.0.1:" + QString::number(reader.serverPort()) + "/?bare=1"); + QNetworkRequest request(QUrl(QStringLiteral("debugpipe://127.0.0.1:") + QString::number(reader.serverPort()) + QStringLiteral("/?bare=1"))); QNetworkReplyPtr reply = manager.put(request, &generator); generator.start(); connect(&reader, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); From 1cd4d6b1819f67b70dd359c7fc43ab06182cc34b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 29 Feb 2012 00:00:27 +0100 Subject: [PATCH 27/37] QEvent (and subclasses): make ctors explicit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do this regardless of whether the event subclass is public API or only used in examples. Examples are examples, used by others as templates or even copied verbatim, so they should also follow sound engineering rules. Anyway, there's only one in examples/... Change-Id: I586ff16407a956c9e89288fdd4377eed73f45c0f Reviewed-by: Samuel Rødal --- examples/animation/moveblocks/main.cpp | 2 +- src/concurrent/qfutureinterface_p.h | 2 +- src/corelib/kernel/qcoreevent.h | 6 +-- src/corelib/kernel/qeventdispatcher_win_p.h | 2 +- src/gui/kernel/qevent.h | 42 +++++++++---------- .../graphicsview/qgraphicssceneevent.h | 14 +++---- src/widgets/kernel/qgesture.h | 2 +- .../kernel/qeventloop/tst_qeventloop.cpp | 2 +- tests/auto/other/gestures/tst_gestures.cpp | 2 +- .../testlib/selftests/alive/qtestalive.cpp | 2 +- .../widgets/themeevent.cpp | 2 +- .../widgets/themeevent.h | 2 +- 12 files changed, 40 insertions(+), 40 deletions(-) diff --git a/examples/animation/moveblocks/main.cpp b/examples/animation/moveblocks/main.cpp index 8e7c04e9f0..d807bb63d9 100644 --- a/examples/animation/moveblocks/main.cpp +++ b/examples/animation/moveblocks/main.cpp @@ -50,7 +50,7 @@ public: { } - StateSwitchEvent(int rand) + explicit StateSwitchEvent(int rand) : QEvent(Type(StateSwitchType)), m_rand(rand) { diff --git a/src/concurrent/qfutureinterface_p.h b/src/concurrent/qfutureinterface_p.h index 3a73f846ac..b985e31ab6 100644 --- a/src/concurrent/qfutureinterface_p.h +++ b/src/concurrent/qfutureinterface_p.h @@ -80,7 +80,7 @@ public: QFutureCallOutEvent() : QEvent(QEvent::FutureCallOut), callOutType(CallOutType(0)), index1(-1), index2(-1) { } - QFutureCallOutEvent(CallOutType callOutType, int index1 = -1) + explicit QFutureCallOutEvent(CallOutType callOutType, int index1 = -1) : QEvent(QEvent::FutureCallOut), callOutType(callOutType), index1(index1), index2(-1) { } QFutureCallOutEvent(CallOutType callOutType, int index1, int index2) diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h index 1f36f9c9c8..cac89f2b13 100644 --- a/src/corelib/kernel/qcoreevent.h +++ b/src/corelib/kernel/qcoreevent.h @@ -288,7 +288,7 @@ public: MaxUser = 65535 // last user event id }; - QEvent(Type type); + explicit QEvent(Type type); virtual ~QEvent(); inline Type type() const { return static_cast(t); } inline bool spontaneous() const { return spont; } @@ -330,7 +330,7 @@ private: class Q_CORE_EXPORT QTimerEvent : public QEvent { public: - QTimerEvent( int timerId ); + explicit QTimerEvent( int timerId ); ~QTimerEvent(); int timerId() const { return id; } protected: @@ -355,7 +355,7 @@ protected: class Q_CORE_EXPORT QDynamicPropertyChangeEvent : public QEvent { public: - QDynamicPropertyChangeEvent(const QByteArray &name); + explicit QDynamicPropertyChangeEvent(const QByteArray &name); ~QDynamicPropertyChangeEvent(); inline QByteArray propertyName() const { return n; } diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h index a831ad39e8..565f1ef4b3 100644 --- a/src/corelib/kernel/qeventdispatcher_win_p.h +++ b/src/corelib/kernel/qeventdispatcher_win_p.h @@ -131,7 +131,7 @@ struct WinTimerInfo { // internal timer info class QZeroTimerEvent : public QTimerEvent { public: - inline QZeroTimerEvent(int timerId) + explicit inline QZeroTimerEvent(int timerId) : QTimerEvent(timerId) { t = QEvent::ZeroTimerEvent; } }; diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index ca93095a94..feee7fa837 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -71,7 +71,7 @@ class QScreen; class Q_GUI_EXPORT QInputEvent : public QEvent { public: - QInputEvent(Type type, Qt::KeyboardModifiers modifiers = Qt::NoModifier); + explicit QInputEvent(Type type, Qt::KeyboardModifiers modifiers = Qt::NoModifier); ~QInputEvent(); inline Qt::KeyboardModifiers modifiers() const { return modState; } inline void setModifiers(Qt::KeyboardModifiers amodifiers) { modState = amodifiers; } @@ -276,7 +276,7 @@ protected: class Q_GUI_EXPORT QFocusEvent : public QEvent { public: - QFocusEvent(Type type, Qt::FocusReason reason=Qt::OtherFocusReason); + explicit QFocusEvent(Type type, Qt::FocusReason reason=Qt::OtherFocusReason); ~QFocusEvent(); inline bool gotFocus() const { return type() == FocusIn; } @@ -292,8 +292,8 @@ private: class Q_GUI_EXPORT QPaintEvent : public QEvent { public: - QPaintEvent(const QRegion& paintRegion); - QPaintEvent(const QRect &paintRect); + explicit QPaintEvent(const QRegion& paintRegion); + explicit QPaintEvent(const QRect &paintRect); ~QPaintEvent(); inline const QRect &rect() const { return m_rect; } @@ -311,7 +311,7 @@ protected: class Q_GUI_EXPORT QUpdateLaterEvent : public QEvent { public: - QUpdateLaterEvent(const QRegion& paintRegion); + explicit QUpdateLaterEvent(const QRegion& paintRegion); ~QUpdateLaterEvent(); inline const QRegion ®ion() const { return m_region; } @@ -337,7 +337,7 @@ protected: class Q_GUI_EXPORT QExposeEvent : public QEvent { public: - QExposeEvent(const QRegion &rgn); + explicit QExposeEvent(const QRegion &rgn); ~QExposeEvent(); inline const QRegion ®ion() const { return rgn; } @@ -468,7 +468,7 @@ private: class Q_GUI_EXPORT QInputMethodQueryEvent : public QEvent { public: - QInputMethodQueryEvent(Qt::InputMethodQueries queries); + explicit QInputMethodQueryEvent(Qt::InputMethodQueries queries); ~QInputMethodQueryEvent(); Qt::InputMethodQueries queries() const { return m_queries; } @@ -586,7 +586,7 @@ private: class Q_GUI_EXPORT QStatusTipEvent : public QEvent { public: - QStatusTipEvent(const QString &tip); + explicit QStatusTipEvent(const QString &tip); ~QStatusTipEvent(); inline QString tip() const { return s; } @@ -599,7 +599,7 @@ private: class Q_GUI_EXPORT QWhatsThisClickedEvent : public QEvent { public: - QWhatsThisClickedEvent(const QString &href); + explicit QWhatsThisClickedEvent(const QString &href); ~QWhatsThisClickedEvent(); inline QString href() const { return s; } @@ -624,8 +624,8 @@ public: class Q_GUI_EXPORT QFileOpenEvent : public QEvent { public: - QFileOpenEvent(const QString &file); - QFileOpenEvent(const QUrl &url); + explicit QFileOpenEvent(const QString &file); + explicit QFileOpenEvent(const QUrl &url); ~QFileOpenEvent(); inline QString file() const { return f; } @@ -639,7 +639,7 @@ private: class Q_GUI_EXPORT QToolBarChangeEvent : public QEvent { public: - QToolBarChangeEvent(bool t); + explicit QToolBarChangeEvent(bool t); ~QToolBarChangeEvent(); inline bool toggle() const { return tog; } @@ -669,7 +669,7 @@ protected: class Q_GUI_EXPORT QClipboardEvent : public QEvent { public: - QClipboardEvent(QEventPrivate *data); + explicit QClipboardEvent(QEventPrivate *data); ~QClipboardEvent(); QEventPrivate *data() { return d; } @@ -679,7 +679,7 @@ public: class Q_GUI_EXPORT QWindowStateChangeEvent: public QEvent { public: - QWindowStateChangeEvent(Qt::WindowStates aOldState); + explicit QWindowStateChangeEvent(Qt::WindowStates aOldState); QWindowStateChangeEvent(Qt::WindowStates aOldState, bool isOverride); ~QWindowStateChangeEvent(); @@ -711,7 +711,7 @@ public: }; Q_DECLARE_FLAGS(InfoFlags, InfoFlag) - TouchPoint(int id = -1); + explicit TouchPoint(int id = -1); TouchPoint(const QTouchEvent::TouchPoint &other); ~TouchPoint(); @@ -783,11 +783,11 @@ public: }; #endif - QTouchEvent(QEvent::Type eventType, - QTouchDevice *device = 0, - Qt::KeyboardModifiers modifiers = Qt::NoModifier, - Qt::TouchPointStates touchPointStates = 0, - const QList &touchPoints = QList()); + explicit QTouchEvent(QEvent::Type eventType, + QTouchDevice *device = 0, + Qt::KeyboardModifiers modifiers = Qt::NoModifier, + Qt::TouchPointStates touchPointStates = 0, + const QList &touchPoints = QList()); ~QTouchEvent(); inline QWindow *window() const { return _window; } @@ -825,7 +825,7 @@ class QScrollPrepareEventPrivate; class Q_GUI_EXPORT QScrollPrepareEvent : public QEvent { public: - QScrollPrepareEvent(const QPointF &startPos); + explicit QScrollPrepareEvent(const QPointF &startPos); ~QScrollPrepareEvent(); QPointF startPos() const; diff --git a/src/widgets/graphicsview/qgraphicssceneevent.h b/src/widgets/graphicsview/qgraphicssceneevent.h index be93c47476..95de435846 100644 --- a/src/widgets/graphicsview/qgraphicssceneevent.h +++ b/src/widgets/graphicsview/qgraphicssceneevent.h @@ -66,7 +66,7 @@ class QGraphicsSceneEventPrivate; class Q_WIDGETS_EXPORT QGraphicsSceneEvent : public QEvent { public: - QGraphicsSceneEvent(Type type); + explicit QGraphicsSceneEvent(Type type); ~QGraphicsSceneEvent(); QWidget *widget() const; @@ -84,7 +84,7 @@ class QGraphicsSceneMouseEventPrivate; class Q_WIDGETS_EXPORT QGraphicsSceneMouseEvent : public QGraphicsSceneEvent { public: - QGraphicsSceneMouseEvent(Type type = None); + explicit QGraphicsSceneMouseEvent(Type type = None); ~QGraphicsSceneMouseEvent(); QPointF pos() const; @@ -132,7 +132,7 @@ class QGraphicsSceneWheelEventPrivate; class Q_WIDGETS_EXPORT QGraphicsSceneWheelEvent : public QGraphicsSceneEvent { public: - QGraphicsSceneWheelEvent(Type type = None); + explicit QGraphicsSceneWheelEvent(Type type = None); ~QGraphicsSceneWheelEvent(); QPointF pos() const; @@ -167,7 +167,7 @@ class Q_WIDGETS_EXPORT QGraphicsSceneContextMenuEvent : public QGraphicsSceneEve public: enum Reason { Mouse, Keyboard, Other }; - QGraphicsSceneContextMenuEvent(Type type = None); + explicit QGraphicsSceneContextMenuEvent(Type type = None); ~QGraphicsSceneContextMenuEvent(); QPointF pos() const; @@ -194,7 +194,7 @@ class QGraphicsSceneHoverEventPrivate; class Q_WIDGETS_EXPORT QGraphicsSceneHoverEvent : public QGraphicsSceneEvent { public: - QGraphicsSceneHoverEvent(Type type = None); + explicit QGraphicsSceneHoverEvent(Type type = None); ~QGraphicsSceneHoverEvent(); QPointF pos() const; @@ -227,7 +227,7 @@ class QGraphicsSceneHelpEventPrivate; class Q_WIDGETS_EXPORT QGraphicsSceneHelpEvent : public QGraphicsSceneEvent { public: - QGraphicsSceneHelpEvent(Type type = None); + explicit QGraphicsSceneHelpEvent(Type type = None); ~QGraphicsSceneHelpEvent(); QPointF scenePos() const; @@ -245,7 +245,7 @@ class QGraphicsSceneDragDropEventPrivate; class Q_WIDGETS_EXPORT QGraphicsSceneDragDropEvent : public QGraphicsSceneEvent { public: - QGraphicsSceneDragDropEvent(Type type = None); + explicit QGraphicsSceneDragDropEvent(Type type = None); ~QGraphicsSceneDragDropEvent(); QPointF pos() const; diff --git a/src/widgets/kernel/qgesture.h b/src/widgets/kernel/qgesture.h index 8c412680b8..5e121def41 100644 --- a/src/widgets/kernel/qgesture.h +++ b/src/widgets/kernel/qgesture.h @@ -270,7 +270,7 @@ class QGestureEventPrivate; class Q_WIDGETS_EXPORT QGestureEvent : public QEvent { public: - QGestureEvent(const QList &gestures); + explicit QGestureEvent(const QList &gestures); ~QGestureEvent(); QList gestures() const; diff --git a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp index e2144134d9..61484c1736 100644 --- a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp +++ b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp @@ -132,7 +132,7 @@ public: class StartStopEvent: public QEvent { public: - StartStopEvent(int type, QEventLoop *loop = 0) + explicit StartStopEvent(int type, QEventLoop *loop = 0) : QEvent(Type(type)), el(loop) { } diff --git a/tests/auto/other/gestures/tst_gestures.cpp b/tests/auto/other/gestures/tst_gestures.cpp index 01e26b6608..81881fc700 100644 --- a/tests/auto/other/gestures/tst_gestures.cpp +++ b/tests/auto/other/gestures/tst_gestures.cpp @@ -87,7 +87,7 @@ class CustomEvent : public QEvent public: static int EventType; - CustomEvent(int serial_ = 0) + explicit CustomEvent(int serial_ = 0) : QEvent(QEvent::Type(CustomEvent::EventType)), serial(serial_), hasHotSpot(false) { diff --git a/tests/auto/testlib/selftests/alive/qtestalive.cpp b/tests/auto/testlib/selftests/alive/qtestalive.cpp index c2e597ac18..d962b7801f 100644 --- a/tests/auto/testlib/selftests/alive/qtestalive.cpp +++ b/tests/auto/testlib/selftests/alive/qtestalive.cpp @@ -50,7 +50,7 @@ public: enum { AliveEventType = QEvent::User + 422 }; - inline QTestAliveEvent(int aSequenceId) + explicit inline QTestAliveEvent(int aSequenceId) : QEvent(QEvent::Type(AliveEventType)), seqId(aSequenceId) {} inline int sequenceId() const { return seqId; } diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/themeevent.cpp b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/themeevent.cpp index 1ebdf2e0bb..3ce3d5c2c1 100644 --- a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/themeevent.cpp +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/themeevent.cpp @@ -41,7 +41,7 @@ #include "themeevent.h" -ThemeEvent::ThemeEvent( QString newTheme, Type type) : QEvent(type), +ThemeEvent::ThemeEvent( const QString &newTheme, Type type) : QEvent(type), m_theme(newTheme) { diff --git a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/themeevent.h b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/themeevent.h index c98f90da55..3603b5966f 100644 --- a/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/themeevent.h +++ b/tests/benchmarks/gui/graphicsview/functional/GraphicsViewBenchmark/widgets/themeevent.h @@ -50,7 +50,7 @@ static QEvent::Type ThemeEventType = (QEvent::Type) 1010; class ThemeEvent : public QEvent { public: - ThemeEvent(QString newTheme, QEvent::Type type = ThemeEventType ); + explicit ThemeEvent(const QString &newTheme, QEvent::Type type = ThemeEventType ); ~ThemeEvent(); public: From e17440586252551c6de169d9141daef1c31a1e7e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 29 Feb 2012 23:53:20 +0100 Subject: [PATCH 28/37] Make some tests and benchmarks pass with QT_NO_QSTRINGBUILDER Change-Id: I6c91a613007043d0f26ac11e98353a0b9ce646ae Reviewed-by: Olivier Goffart --- .../kernel/qauthenticator/tst_qauthenticator.cpp | 6 +++--- .../network/socket/qtcpsocket/tst_qtcpsocket.cpp | 4 ++-- .../tools/containers-associative/main.cpp | 8 ++++---- .../corelib/tools/containers-sequential/main.cpp | 16 ++++++++-------- tests/benchmarks/dbus/qdbustype/main.cpp | 2 +- .../gui/styles/qstylesheetstyle/main.cpp | 6 +++--- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp index 9c1b8c32f6..7cb5dfd5cd 100644 --- a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp +++ b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp @@ -93,7 +93,7 @@ void tst_QAuthenticator::basicAuth() QVERIFY(priv->phase == QAuthenticatorPrivate::Start); QList > headers; - headers << qMakePair(QByteArray("WWW-Authenticate"), "Basic " + data.toUtf8()); + headers << qMakePair(QByteArray("WWW-Authenticate"), "Basic " + data.toUtf8()); priv->parseHttpResponse(headers, /*isProxy = */ false); QCOMPARE(auth.realm(), realm); @@ -104,7 +104,7 @@ void tst_QAuthenticator::basicAuth() QVERIFY(priv->phase == QAuthenticatorPrivate::Start); - QCOMPARE(priv->calculateResponse("GET", "/").constData(), ("Basic " + expectedReply).constData()); + QCOMPARE(priv->calculateResponse("GET", "/").constData(), QByteArray("Basic " + expectedReply).constData()); } void tst_QAuthenticator::ntlmAuth_data() @@ -138,7 +138,7 @@ void tst_QAuthenticator::ntlmAuth() // NTLM phase 2: challenge headers.clear(); - headers << qMakePair(QByteArray("WWW-Authenticate"), "NTLM " + data.toUtf8()); + headers << qMakePair(QByteArray("WWW-Authenticate"), "NTLM " + data.toUtf8()); priv->parseHttpResponse(headers, /*isProxy = */ false); QEXPECT_FAIL("with-realm", "NTLM authentication code doesn't extract the realm", Continue); diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index 2c2b551257..08938be4d1 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -2240,7 +2240,7 @@ void tst_QTcpSocket::suddenRemoteDisconnect() QString::fromLatin1("Could not start %1: %2").arg(processExe, serverProcess.errorString()))); while (!serverProcess.canReadLine()) QVERIFY(serverProcess.waitForReadyRead(10000)); - QCOMPARE(serverProcess.readLine().data(), (server.toLatin1() + "\n").data()); + QCOMPARE(serverProcess.readLine().data(), QByteArray(server.toLatin1() + "\n").data()); // Start client QProcess clientProcess; @@ -2250,7 +2250,7 @@ void tst_QTcpSocket::suddenRemoteDisconnect() QString::fromLatin1("Could not start %1: %2").arg(processExe, clientProcess.errorString()))); while (!clientProcess.canReadLine()) QVERIFY(clientProcess.waitForReadyRead(10000)); - QCOMPARE(clientProcess.readLine().data(), (client.toLatin1() + "\n").data()); + QCOMPARE(clientProcess.readLine().data(), QByteArray(client.toLatin1() + "\n").data()); // Let them play for a while qDebug("Running stress test for 5 seconds"); diff --git a/tests/benchmarks/corelib/tools/containers-associative/main.cpp b/tests/benchmarks/corelib/tools/containers-associative/main.cpp index 7f2e7b68ca..ab1c406708 100644 --- a/tests/benchmarks/corelib/tools/containers-associative/main.cpp +++ b/tests/benchmarks/corelib/tools/containers-associative/main.cpp @@ -72,8 +72,8 @@ void tst_associative_containers::insert_data() const QByteArray sizeString = QByteArray::number(size); - QTest::newRow(("hash--" + sizeString).constData()) << true << size; - QTest::newRow(("map--" + sizeString).constData()) << false << size; + QTest::newRow(QByteArray("hash--" + sizeString).constData()) << true << size; + QTest::newRow(QByteArray("map--" + sizeString).constData()) << false << size; } } @@ -104,8 +104,8 @@ void tst_associative_containers::lookup_data() const QByteArray sizeString = QByteArray::number(size); - QTest::newRow(("hash--" + sizeString).constData()) << true << size; - QTest::newRow(("map--" + sizeString).constData()) << false << size; + QTest::newRow(QByteArray("hash--" + sizeString).constData()) << true << size; + QTest::newRow(QByteArray("map--" + sizeString).constData()) << false << size; } } diff --git a/tests/benchmarks/corelib/tools/containers-sequential/main.cpp b/tests/benchmarks/corelib/tools/containers-sequential/main.cpp index e42a40b110..43eadb6633 100644 --- a/tests/benchmarks/corelib/tools/containers-sequential/main.cpp +++ b/tests/benchmarks/corelib/tools/containers-sequential/main.cpp @@ -176,8 +176,8 @@ void tst_vector_vs_std::insert_int_data() for (int size = 10; size < 20000; size += 100) { const QByteArray sizeString = QByteArray::number(size); - QTest::newRow(("std::vector-int--" + sizeString).constData()) << true << size; - QTest::newRow(("QVector-int--" + sizeString).constData()) << false << size; + QTest::newRow(QByteArray("std::vector-int--" + sizeString).constData()) << true << size; + QTest::newRow(QByteArray("QVector-int--" + sizeString).constData()) << false << size; } } @@ -199,8 +199,8 @@ void tst_vector_vs_std::insert_Large_data() for (int size = 10; size < LARGE_MAX_SIZE; size += 100) { const QByteArray sizeString = QByteArray::number(size); - QTest::newRow(("std::vector-Large--" + sizeString).constData()) << true << size; - QTest::newRow(("QVector-Large--" + sizeString).constData()) << false << size; + QTest::newRow(QByteArray("std::vector-Large--" + sizeString).constData()) << true << size; + QTest::newRow(QByteArray("QVector-Large--" + sizeString).constData()) << false << size; } } @@ -222,8 +222,8 @@ void tst_vector_vs_std::lookup_int_data() for (int size = 10; size < 20000; size += 100) { const QByteArray sizeString = QByteArray::number(size); - QTest::newRow(("std::vector-int--" + sizeString).constData()) << true << size; - QTest::newRow(("QVector-int--" + sizeString).constData()) << false << size; + QTest::newRow(QByteArray("std::vector-int--" + sizeString).constData()) << true << size; + QTest::newRow(QByteArray("QVector-int--" + sizeString).constData()) << false << size; } } @@ -245,8 +245,8 @@ void tst_vector_vs_std::lookup_Large_data() for (int size = 10; size < LARGE_MAX_SIZE; size += 100) { const QByteArray sizeString = QByteArray::number(size); - QTest::newRow(("std::vector-Large--" + sizeString).constData()) << true << size; - QTest::newRow(("QVector-Large--" + sizeString).constData()) << false << size; + QTest::newRow(QByteArray("std::vector-Large--" + sizeString).constData()) << true << size; + QTest::newRow(QByteArray("QVector-Large--" + sizeString).constData()) << false << size; } } diff --git a/tests/benchmarks/dbus/qdbustype/main.cpp b/tests/benchmarks/dbus/qdbustype/main.cpp index 0e0ce358bb..b0f6988425 100644 --- a/tests/benchmarks/dbus/qdbustype/main.cpp +++ b/tests/benchmarks/dbus/qdbustype/main.cpp @@ -56,7 +56,7 @@ private Q_SLOTS: static inline void benchmarkAddRow(const char *name, const char *data) { - QTest::newRow(QByteArray("native-") + name) << data << true; + QTest::newRow(QByteArray(QByteArray("native-") + name)) << data << true; QTest::newRow(name) << data << false; } diff --git a/tests/benchmarks/gui/styles/qstylesheetstyle/main.cpp b/tests/benchmarks/gui/styles/qstylesheetstyle/main.cpp index fcddf5ed90..45acd41749 100644 --- a/tests/benchmarks/gui/styles/qstylesheetstyle/main.cpp +++ b/tests/benchmarks/gui/styles/qstylesheetstyle/main.cpp @@ -153,9 +153,9 @@ void tst_qstylesheetstyle::grid_data() QTest::addColumn("N"); for (int n = 5; n <= 25; n += 5) { const QByteArray nString = QByteArray::number(n*n); - QTest::newRow(("simple--" + nString).constData()) << false << false << n; - QTest::newRow(("events--" + nString).constData()) << true << false << n; - QTest::newRow(("show--" + nString).constData()) << true << true << n; + QTest::newRow(QByteArray("simple--" + nString).constData()) << false << false << n; + QTest::newRow(QByteArray("events--" + nString).constData()) << true << false << n; + QTest::newRow(QByteArray("show--" + nString).constData()) << true << true << n; } } From 15c141511fab24233d42b3c8593f0781a4931c8a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 28 Feb 2012 19:54:46 +0100 Subject: [PATCH 29/37] QPair: specialise QTypeInfo based on the typeinfos of its arguments Specialise QTypeInfo> based on the properties of T1 and T2: - If either T1 or T2 is Q_COMPLEX_TYPE, so is QPair. - Otherwise, if either T1 or T2 is Q_MOVABLE_TYPE, so is QPair. - Otherwise, QPair is Q_PRIMITIVE_TYPE. Change-Id: I8aecbd37e3b7924f77f38967498deabf1a19ca24 Reviewed-by: Olivier Goffart Reviewed-by: Thiago Macieira Reviewed-by: Stephen Kelly --- src/corelib/tools/qpair.h | 16 +++ .../kernel/qmetatype/tst_qmetatype.cpp | 39 +++++++ tests/auto/corelib/tools/qpair/qpair.pro | 4 + tests/auto/corelib/tools/qpair/tst_qpair.cpp | 105 ++++++++++++++++++ tests/auto/corelib/tools/tools.pro | 1 + 5 files changed, 165 insertions(+) create mode 100644 tests/auto/corelib/tools/qpair/qpair.pro create mode 100644 tests/auto/corelib/tools/qpair/tst_qpair.cpp diff --git a/src/corelib/tools/qpair.h b/src/corelib/tools/qpair.h index 501f2af3e6..29eb58bd22 100644 --- a/src/corelib/tools/qpair.h +++ b/src/corelib/tools/qpair.h @@ -65,6 +65,22 @@ struct QPair T2 second; }; +// mark QPair as complex/movable/primitive depending on the +// typeinfos of the constituents: +template +class QTypeInfo< QPair > +{ +public: + enum { + isComplex = QTypeInfo::isComplex || QTypeInfo::isComplex, + isStatic = QTypeInfo::isStatic || QTypeInfo::isStatic, + isLarge = sizeof(QPair) > sizeof(void*), + isPointer = false, + isDummy = false, + sizeOf = sizeof(QPair) + }; +}; + template Q_INLINE_TEMPLATE bool operator==(const QPair &p1, const QPair &p2) { return p1.first == p2.first && p1.second == p2.second; } diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 72913d10f2..06919c6f58 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -682,6 +682,36 @@ public: }; Q_DECLARE_METATYPE(CustomMultiInheritanceObject*); +class C { char _[4]; }; +class M { char _[4]; }; +class P { char _[4]; }; + +QT_BEGIN_NAMESPACE +Q_DECLARE_TYPEINFO(M, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(P, Q_PRIMITIVE_TYPE); +QT_END_NAMESPACE + +// avoid the comma: +typedef QPair QPairCC; +typedef QPair QPairCM; +typedef QPair QPairCP; +typedef QPair QPairMC; +typedef QPair QPairMM; +typedef QPair QPairMP; +typedef QPair QPairPC; +typedef QPair QPairPM; +typedef QPair QPairPP; + +Q_DECLARE_METATYPE(QPairCC) +Q_DECLARE_METATYPE(QPairCM) +Q_DECLARE_METATYPE(QPairCP) +Q_DECLARE_METATYPE(QPairMC) +Q_DECLARE_METATYPE(QPairMM) +Q_DECLARE_METATYPE(QPairMP) +Q_DECLARE_METATYPE(QPairPC) +Q_DECLARE_METATYPE(QPairPM) +Q_DECLARE_METATYPE(QPairPP) + void tst_QMetaType::flags_data() { QTest::addColumn("type"); @@ -700,6 +730,15 @@ QT_FOR_EACH_STATIC_CORE_POINTER(ADD_METATYPE_TEST_ROW) QTest::newRow("CustomMovable") << ::qMetaTypeId() << true << true << false; QTest::newRow("CustomObject*") << ::qMetaTypeId() << true << false << true; QTest::newRow("CustomMultiInheritanceObject*") << ::qMetaTypeId() << true << false << true; + QTest::newRow("QPair") << ::qMetaTypeId >() << false << true << false; + QTest::newRow("QPair") << ::qMetaTypeId >() << false << true << false; + QTest::newRow("QPair") << ::qMetaTypeId >() << false << true << false; + QTest::newRow("QPair") << ::qMetaTypeId >() << false << true << false; + QTest::newRow("QPair") << ::qMetaTypeId >() << true << true << false; + QTest::newRow("QPair") << ::qMetaTypeId >() << true << true << false; + QTest::newRow("QPair") << ::qMetaTypeId >() << false << true << false; + QTest::newRow("QPair") << ::qMetaTypeId >() << true << true << false; + QTest::newRow("QPair") << ::qMetaTypeId >() << true << false << false; } void tst_QMetaType::flags() diff --git a/tests/auto/corelib/tools/qpair/qpair.pro b/tests/auto/corelib/tools/qpair/qpair.pro new file mode 100644 index 0000000000..9c7752327e --- /dev/null +++ b/tests/auto/corelib/tools/qpair/qpair.pro @@ -0,0 +1,4 @@ +CONFIG += testcase parallel_test +TARGET = tst_qpair +QT = core testlib +SOURCES = tst_qpair.cpp diff --git a/tests/auto/corelib/tools/qpair/tst_qpair.cpp b/tests/auto/corelib/tools/qpair/tst_qpair.cpp new file mode 100644 index 0000000000..5de1e8f8bb --- /dev/null +++ b/tests/auto/corelib/tools/qpair/tst_qpair.cpp @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz +** Contact: http://www.qt-project.org/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include + +class tst_QPair : public QObject +{ + Q_OBJECT +private Q_SLOTS: + void dummy() {} +}; + +class C { char _[4]; }; +class M { char _[4]; }; +class P { char _[4]; }; + +QT_BEGIN_NAMESPACE +Q_DECLARE_TYPEINFO(M, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(P, Q_PRIMITIVE_TYPE); +QT_END_NAMESPACE + +// avoid the comma: +typedef QPair QPairCC; +typedef QPair QPairCM; +typedef QPair QPairCP; +typedef QPair QPairMC; +typedef QPair QPairMM; +typedef QPair QPairMP; +typedef QPair QPairPC; +typedef QPair QPairPM; +typedef QPair QPairPP; + +Q_STATIC_ASSERT( QTypeInfo::isComplex); +Q_STATIC_ASSERT( QTypeInfo::isStatic ); + +Q_STATIC_ASSERT( QTypeInfo::isComplex); +Q_STATIC_ASSERT( QTypeInfo::isStatic ); + +Q_STATIC_ASSERT( QTypeInfo::isComplex); +Q_STATIC_ASSERT( QTypeInfo::isStatic ); + +Q_STATIC_ASSERT( QTypeInfo::isComplex); +Q_STATIC_ASSERT( QTypeInfo::isStatic ); + +Q_STATIC_ASSERT( QTypeInfo::isComplex); +Q_STATIC_ASSERT(!QTypeInfo::isStatic ); + +Q_STATIC_ASSERT( QTypeInfo::isComplex); +Q_STATIC_ASSERT(!QTypeInfo::isStatic ); + +Q_STATIC_ASSERT( QTypeInfo::isComplex); +Q_STATIC_ASSERT( QTypeInfo::isStatic ); + +Q_STATIC_ASSERT( QTypeInfo::isComplex); +Q_STATIC_ASSERT(!QTypeInfo::isStatic ); + +Q_STATIC_ASSERT(!QTypeInfo::isComplex); +Q_STATIC_ASSERT(!QTypeInfo::isStatic ); + +Q_STATIC_ASSERT(!QTypeInfo::isDummy ); +Q_STATIC_ASSERT(!QTypeInfo::isPointer); + + +QTEST_APPLESS_MAIN(tst_QPair) +#include "tst_qpair.moc" diff --git a/tests/auto/corelib/tools/tools.pro b/tests/auto/corelib/tools/tools.pro index 930799e3b3..89bb3bc416 100644 --- a/tests/auto/corelib/tools/tools.pro +++ b/tests/auto/corelib/tools/tools.pro @@ -20,6 +20,7 @@ SUBDIRS=\ qlocale \ qmap \ qmargins \ + qpair \ qpoint \ qqueue \ qrect \ From d3eb877951b4fb295e1ddc35e5ee53c782784142 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 1 Mar 2012 10:14:08 +0100 Subject: [PATCH 30/37] QInputMethodEvent::Attribute: mark as Q_MOVABLE_TYPE Change-Id: Ifb41afdcf17fa8192f37b4900c59e81d4e0bf60f Reviewed-by: Thiago Macieira --- src/gui/kernel/qevent.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index feee7fa837..d70f6be201 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -464,6 +464,7 @@ private: int replace_length; QString tentativeCommit; }; +Q_DECLARE_TYPEINFO(QInputMethodEvent::Attribute, Q_MOVABLE_TYPE); class Q_GUI_EXPORT QInputMethodQueryEvent : public QEvent { From a1c75534a4bca417204725e77945e53059895726 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 24 Feb 2012 22:27:32 +0100 Subject: [PATCH 31/37] QtGlobal: remove qIsDetached() There's not a single in-tree user of this function, and the concept is a broken one in MT programs: By the time qIsDetached() returns, the result can already be different due to another thread taking a copy, or a copy in another thread being destroyed (note that this doesn't require mutex use by the user, since we promise (implicitly, if not explicitly) that you can copy from const objects without holding a lock). QTBUG-10813 talks about a use in QCache::trim(), but 677cf76340f88e0fe51c1f75aa512b6d835414ca removed it, so there's no reason to keep it anymore. Change-Id: I20380c12bdf00ac764b89d84392f0f34727b1971 Reviewed-by: Lars Knoll --- dist/changes-5.0.0 | 2 ++ src/corelib/global/qtypeinfo.h | 4 ---- src/gui/image/qpixmapcache_p.h | 2 -- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0 index 5a9ce7e6c7..e1f1f07203 100644 --- a/dist/changes-5.0.0 +++ b/dist/changes-5.0.0 @@ -45,6 +45,8 @@ information about a particular change. in Qt4, so these methods return a bool now. If your code used the undocumented QBool, simply replace it with bool. +- qIsDetached<> has been removed without replacement. + - QMetaType: * QMetaType::construct() has been renamed to QMetaType::create(). * QMetaType::unregisterType() has been removed. diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h index 815be935f7..1c08bbe1cf 100644 --- a/src/corelib/global/qtypeinfo.h +++ b/src/corelib/global/qtypeinfo.h @@ -49,15 +49,12 @@ QT_BEGIN_NAMESPACE /* QTypeInfo - type trait functionality - qIsDetached - data sharing functionality */ /* The catch-all template. */ -template inline bool qIsDetached(T &) { return true; } - template class QTypeInfo { @@ -188,7 +185,6 @@ QT_BEGIN_NAMESPACE #endif #define Q_DECLARE_SHARED(TYPE) \ -template <> inline bool qIsDetached(TYPE &t) { return t.isDetached(); } \ template <> inline void qSwap(TYPE &value1, TYPE &value2) \ { qSwap(value1.data_ptr(), value2.data_ptr()); } \ Q_DECLARE_SHARED_STL(TYPE) diff --git a/src/gui/image/qpixmapcache_p.h b/src/gui/image/qpixmapcache_p.h index 6ca109b03f..426a6d9954 100644 --- a/src/gui/image/qpixmapcache_p.h +++ b/src/gui/image/qpixmapcache_p.h @@ -96,8 +96,6 @@ public: QPixmapCache::Key key; }; -inline bool qIsDetached(QPixmapCacheEntry &t) { return t.isDetached(); } - QT_END_NAMESPACE #endif // QPIXMAPCACHE_P_H From d13bedb9d8fb66f58ba901864555bcc9b6e463e0 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 29 Feb 2012 15:56:28 +0100 Subject: [PATCH 32/37] remove assignment of QMAKE_MOC & QMAKE_UIC from mkspecs there is entirely no point in having it there. Change-Id: Ie2fc1e94495119725131cbd50564648cbb4a7dc8 Reviewed-by: Joerg Bornemann Reviewed-by: Marius Storm-Olsen --- mkspecs/aix-g++-64/qmake.conf | 3 --- mkspecs/aix-g++/qmake.conf | 3 --- mkspecs/aix-xlc-64/qmake.conf | 3 --- mkspecs/aix-xlc/qmake.conf | 3 --- mkspecs/common/linux.conf | 3 --- mkspecs/common/mac.conf | 3 --- mkspecs/cygwin-g++/qmake.conf | 3 --- mkspecs/darwin-g++/qmake.conf | 3 --- mkspecs/freebsd-g++/qmake.conf | 3 --- mkspecs/freebsd-g++34/qmake.conf | 3 --- mkspecs/freebsd-g++40/qmake.conf | 3 --- mkspecs/freebsd-icc/qmake.conf | 3 --- mkspecs/hpux-acc-64/qmake.conf | 3 --- mkspecs/hpux-acc-o64/qmake.conf | 3 --- mkspecs/hpux-acc/qmake.conf | 3 --- mkspecs/hpux-g++-64/qmake.conf | 3 --- mkspecs/hpux-g++/qmake.conf | 3 --- mkspecs/hpuxi-acc-32/qmake.conf | 3 --- mkspecs/hpuxi-acc-64/qmake.conf | 3 --- mkspecs/hpuxi-g++-64/qmake.conf | 3 --- mkspecs/hurd-g++/qmake.conf | 3 --- mkspecs/irix-cc-64/qmake.conf | 3 --- mkspecs/irix-cc/qmake.conf | 3 --- mkspecs/irix-g++-64/qmake.conf | 3 --- mkspecs/irix-g++/qmake.conf | 3 --- mkspecs/linux-cxx/qmake.conf | 3 --- mkspecs/linux-ecc-64/qmake.conf | 3 --- mkspecs/linux-icc/qmake.conf | 3 --- mkspecs/linux-kcc/qmake.conf | 3 --- mkspecs/linux-pgcc/qmake.conf | 3 --- mkspecs/lynxos-g++/qmake.conf | 3 --- mkspecs/macx-xlc/qmake.conf | 3 --- mkspecs/netbsd-g++/qmake.conf | 3 --- mkspecs/openbsd-g++/qmake.conf | 3 --- mkspecs/sco-cc/qmake.conf | 3 --- mkspecs/sco-g++/qmake.conf | 3 --- mkspecs/solaris-cc-64/qmake.conf | 3 --- mkspecs/solaris-cc/qmake.conf | 3 --- mkspecs/solaris-g++-64/qmake.conf | 3 --- mkspecs/solaris-g++/qmake.conf | 3 --- mkspecs/tru64-cxx/qmake.conf | 3 --- mkspecs/tru64-g++/qmake.conf | 3 --- mkspecs/unixware-cc/qmake.conf | 3 --- mkspecs/unixware-g++/qmake.conf | 3 --- mkspecs/unsupported/integrity-ghs/qmake.conf | 3 --- mkspecs/unsupported/linux-host-g++/qmake.conf | 3 --- mkspecs/unsupported/qnx-g++/qmake.conf | 3 --- mkspecs/unsupported/vxworks-ppc-dcc/qmake.conf | 3 --- mkspecs/unsupported/vxworks-simpentium-dcc/qmake.conf | 3 --- 49 files changed, 147 deletions(-) diff --git a/mkspecs/aix-g++-64/qmake.conf b/mkspecs/aix-g++-64/qmake.conf index b0179d5603..5a73aeb8c1 100644 --- a/mkspecs/aix-g++-64/qmake.conf +++ b/mkspecs/aix-g++-64/qmake.conf @@ -67,9 +67,6 @@ QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthreads -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar -X64 cq QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = ranlib -X64 diff --git a/mkspecs/aix-g++/qmake.conf b/mkspecs/aix-g++/qmake.conf index 2e2e991f54..9ddb1619ab 100644 --- a/mkspecs/aix-g++/qmake.conf +++ b/mkspecs/aix-g++/qmake.conf @@ -67,9 +67,6 @@ QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthreads -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/aix-xlc-64/qmake.conf b/mkspecs/aix-xlc-64/qmake.conf index 486b8c6f0f..db5ddc33cd 100644 --- a/mkspecs/aix-xlc-64/qmake.conf +++ b/mkspecs/aix-xlc-64/qmake.conf @@ -66,9 +66,6 @@ QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthreads -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar -X64 cq QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = ranlib -X64 diff --git a/mkspecs/aix-xlc/qmake.conf b/mkspecs/aix-xlc/qmake.conf index 8655db6d82..ff83a45702 100644 --- a/mkspecs/aix-xlc/qmake.conf +++ b/mkspecs/aix-xlc/qmake.conf @@ -67,9 +67,6 @@ QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthreads -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cq QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = ranlib diff --git a/mkspecs/common/linux.conf b/mkspecs/common/linux.conf index f8f007bada..a809a6b6f9 100644 --- a/mkspecs/common/linux.conf +++ b/mkspecs/common/linux.conf @@ -46,9 +46,6 @@ QMAKE_CFLAGS_XCB = QMAKE_LIBS_XCB = QMAKE_DEFINES_XCB = -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/common/mac.conf b/mkspecs/common/mac.conf index b22b852013..6ba55325e8 100644 --- a/mkspecs/common/mac.conf +++ b/mkspecs/common/mac.conf @@ -21,9 +21,6 @@ QMAKE_LIBS_OPENGL = -framework OpenGL -framework AGL QMAKE_LIBS_OPENGL_QT = $$QMAKE_LIBS_OPENGL QMAKE_LIBS_THREAD = -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cq QMAKE_RANLIB = ranlib -s diff --git a/mkspecs/cygwin-g++/qmake.conf b/mkspecs/cygwin-g++/qmake.conf index c46384fc8b..ece21e226f 100644 --- a/mkspecs/cygwin-g++/qmake.conf +++ b/mkspecs/cygwin-g++/qmake.conf @@ -72,9 +72,6 @@ QMAKE_PREFIX_SHLIB = lib QMAKE_PREFIX_STATICLIB = lib QMAKE_EXTENSION_STATICLIB = a -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/darwin-g++/qmake.conf b/mkspecs/darwin-g++/qmake.conf index 84dc764e6b..c059f0cb6f 100644 --- a/mkspecs/darwin-g++/qmake.conf +++ b/mkspecs/darwin-g++/qmake.conf @@ -78,9 +78,6 @@ QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cq QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = ranlib -s diff --git a/mkspecs/freebsd-g++/qmake.conf b/mkspecs/freebsd-g++/qmake.conf index 9d7c4431d8..f1db098c19 100644 --- a/mkspecs/freebsd-g++/qmake.conf +++ b/mkspecs/freebsd-g++/qmake.conf @@ -32,9 +32,6 @@ QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/freebsd-g++34/qmake.conf b/mkspecs/freebsd-g++34/qmake.conf index 0f52993451..ee597de6c5 100644 --- a/mkspecs/freebsd-g++34/qmake.conf +++ b/mkspecs/freebsd-g++34/qmake.conf @@ -67,9 +67,6 @@ QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/freebsd-g++40/qmake.conf b/mkspecs/freebsd-g++40/qmake.conf index bf4271126a..331c267b9e 100644 --- a/mkspecs/freebsd-g++40/qmake.conf +++ b/mkspecs/freebsd-g++40/qmake.conf @@ -67,9 +67,6 @@ QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/freebsd-icc/qmake.conf b/mkspecs/freebsd-icc/qmake.conf index acc8f14b3a..fc7251bcbf 100644 --- a/mkspecs/freebsd-icc/qmake.conf +++ b/mkspecs/freebsd-icc/qmake.conf @@ -90,9 +90,6 @@ QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/hpux-acc-64/qmake.conf b/mkspecs/hpux-acc-64/qmake.conf index b9aaf5ab24..de0fff1d91 100644 --- a/mkspecs/hpux-acc-64/qmake.conf +++ b/mkspecs/hpux-acc-64/qmake.conf @@ -111,9 +111,6 @@ QMAKE_LIBS_OPENGL_QT = -lGL -lXt QMAKE_LIBS_THREAD = -lpthread QMAKE_LIBS_YACC = -ly -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/hpux-acc-o64/qmake.conf b/mkspecs/hpux-acc-o64/qmake.conf index 389e813dba..5773566b9e 100644 --- a/mkspecs/hpux-acc-o64/qmake.conf +++ b/mkspecs/hpux-acc-o64/qmake.conf @@ -109,9 +109,6 @@ QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread QMAKE_LIBS_YACC = -ly -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/hpux-acc/qmake.conf b/mkspecs/hpux-acc/qmake.conf index d1b6e5ce56..6bc226c7e2 100644 --- a/mkspecs/hpux-acc/qmake.conf +++ b/mkspecs/hpux-acc/qmake.conf @@ -90,9 +90,6 @@ QMAKE_LIBS_OPENGL_QT = -lGL -lXt QMAKE_LIBS_THREAD = -lpthread QMAKE_LIBS_YACC = -ly -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/hpux-g++-64/qmake.conf b/mkspecs/hpux-g++-64/qmake.conf index f796496c56..1f478ccca4 100644 --- a/mkspecs/hpux-g++-64/qmake.conf +++ b/mkspecs/hpux-g++-64/qmake.conf @@ -73,9 +73,6 @@ QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread QMAKE_LIBS_YACC = -ly -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/hpux-g++/qmake.conf b/mkspecs/hpux-g++/qmake.conf index e9891e79f1..6685fe1a5e 100644 --- a/mkspecs/hpux-g++/qmake.conf +++ b/mkspecs/hpux-g++/qmake.conf @@ -73,9 +73,6 @@ QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread QMAKE_LIBS_YACC = -ly -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/hpuxi-acc-32/qmake.conf b/mkspecs/hpuxi-acc-32/qmake.conf index d7e4a0ad34..53d05b7450 100644 --- a/mkspecs/hpuxi-acc-32/qmake.conf +++ b/mkspecs/hpuxi-acc-32/qmake.conf @@ -65,9 +65,6 @@ QMAKE_LIBS_OPENGL_QT = -lGL -lXt QMAKE_LIBS_THREAD = -lpthread QMAKE_LIBS_YACC = -ly -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/hpuxi-acc-64/qmake.conf b/mkspecs/hpuxi-acc-64/qmake.conf index 3ed9b55073..d5d51a9dea 100644 --- a/mkspecs/hpuxi-acc-64/qmake.conf +++ b/mkspecs/hpuxi-acc-64/qmake.conf @@ -108,9 +108,6 @@ QMAKE_LIBS_OPENGL_QT = -lGL -lXt QMAKE_LIBS_THREAD = -lpthread QMAKE_LIBS_YACC = -ly -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/hpuxi-g++-64/qmake.conf b/mkspecs/hpuxi-g++-64/qmake.conf index a8f445ca00..9d4daae5c3 100644 --- a/mkspecs/hpuxi-g++-64/qmake.conf +++ b/mkspecs/hpuxi-g++-64/qmake.conf @@ -76,9 +76,6 @@ QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread QMAKE_LIBS_YACC = -ly -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/hurd-g++/qmake.conf b/mkspecs/hurd-g++/qmake.conf index 09a72fa0d7..e7416cd9f6 100644 --- a/mkspecs/hurd-g++/qmake.conf +++ b/mkspecs/hurd-g++/qmake.conf @@ -42,9 +42,6 @@ QMAKE_LIBS_OPENGL_ES2 = -lGLESv2 QMAKE_LIBS_OPENVG = -lOpenVG QMAKE_LIBS_THREAD = -lpthread -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/irix-cc-64/qmake.conf b/mkspecs/irix-cc-64/qmake.conf index ec94824be6..ac5f3b5847 100644 --- a/mkspecs/irix-cc-64/qmake.conf +++ b/mkspecs/irix-cc-64/qmake.conf @@ -98,9 +98,6 @@ QMAKE_LIBS_OPENGL = -lGL -lm QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = CC -ar -o QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/irix-cc/qmake.conf b/mkspecs/irix-cc/qmake.conf index 777da9b5db..eaec795f2a 100644 --- a/mkspecs/irix-cc/qmake.conf +++ b/mkspecs/irix-cc/qmake.conf @@ -98,9 +98,6 @@ QMAKE_LIBS_OPENGL = -lGL -lm QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = CC -ar -o QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/irix-g++-64/qmake.conf b/mkspecs/irix-g++-64/qmake.conf index aa853dedfe..2dcd690c5a 100644 --- a/mkspecs/irix-g++-64/qmake.conf +++ b/mkspecs/irix-g++-64/qmake.conf @@ -71,9 +71,6 @@ QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cq QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/irix-g++/qmake.conf b/mkspecs/irix-g++/qmake.conf index 77d47a9ce9..c532a35f6f 100644 --- a/mkspecs/irix-g++/qmake.conf +++ b/mkspecs/irix-g++/qmake.conf @@ -71,9 +71,6 @@ QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cq QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/linux-cxx/qmake.conf b/mkspecs/linux-cxx/qmake.conf index 79aa834a90..0bd1193730 100644 --- a/mkspecs/linux-cxx/qmake.conf +++ b/mkspecs/linux-cxx/qmake.conf @@ -63,9 +63,6 @@ QMAKE_LIBS_NIS = -lnsl QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_RANLIB = diff --git a/mkspecs/linux-ecc-64/qmake.conf b/mkspecs/linux-ecc-64/qmake.conf index 50f841f1d4..a4b9e03f2c 100644 --- a/mkspecs/linux-ecc-64/qmake.conf +++ b/mkspecs/linux-ecc-64/qmake.conf @@ -67,9 +67,6 @@ QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/linux-icc/qmake.conf b/mkspecs/linux-icc/qmake.conf index 4ff63cda71..49a3306538 100644 --- a/mkspecs/linux-icc/qmake.conf +++ b/mkspecs/linux-icc/qmake.conf @@ -74,9 +74,6 @@ QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = xiar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/linux-kcc/qmake.conf b/mkspecs/linux-kcc/qmake.conf index 23fd6298ac..ab1847f42d 100644 --- a/mkspecs/linux-kcc/qmake.conf +++ b/mkspecs/linux-kcc/qmake.conf @@ -76,9 +76,6 @@ QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/linux-pgcc/qmake.conf b/mkspecs/linux-pgcc/qmake.conf index ed88215609..80b4cc28ba 100644 --- a/mkspecs/linux-pgcc/qmake.conf +++ b/mkspecs/linux-pgcc/qmake.conf @@ -67,9 +67,6 @@ QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/lynxos-g++/qmake.conf b/mkspecs/lynxos-g++/qmake.conf index 6b6f4057bf..500dc498ee 100644 --- a/mkspecs/lynxos-g++/qmake.conf +++ b/mkspecs/lynxos-g++/qmake.conf @@ -70,9 +70,6 @@ QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/macx-xlc/qmake.conf b/mkspecs/macx-xlc/qmake.conf index f84524bbdf..77c300a4ae 100644 --- a/mkspecs/macx-xlc/qmake.conf +++ b/mkspecs/macx-xlc/qmake.conf @@ -77,9 +77,6 @@ QMAKE_LIBS_OPENGL = -framework OpenGL -framework AGL QMAKE_LIBS_OPENGL_QT = $$QMAKE_LIBS_OPENGL #QMAKE_LIBS_THREAD = -lpthreads -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cq QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = ranlib -s diff --git a/mkspecs/netbsd-g++/qmake.conf b/mkspecs/netbsd-g++/qmake.conf index ab4b7c374c..17609f2fb7 100644 --- a/mkspecs/netbsd-g++/qmake.conf +++ b/mkspecs/netbsd-g++/qmake.conf @@ -68,9 +68,6 @@ QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = ranlib diff --git a/mkspecs/openbsd-g++/qmake.conf b/mkspecs/openbsd-g++/qmake.conf index 56d94160e3..1539c46960 100644 --- a/mkspecs/openbsd-g++/qmake.conf +++ b/mkspecs/openbsd-g++/qmake.conf @@ -69,9 +69,6 @@ QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar q QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = ranlib diff --git a/mkspecs/sco-cc/qmake.conf b/mkspecs/sco-cc/qmake.conf index 179b774e03..4cb71db520 100644 --- a/mkspecs/sco-cc/qmake.conf +++ b/mkspecs/sco-cc/qmake.conf @@ -63,9 +63,6 @@ QMAKE_LIBS_X11SM = -lSM -lICE QMAKE_LIBS_OPENGL = -lGL -lXt QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cq QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/sco-g++/qmake.conf b/mkspecs/sco-g++/qmake.conf index 9b321a486a..b4839eb571 100644 --- a/mkspecs/sco-g++/qmake.conf +++ b/mkspecs/sco-g++/qmake.conf @@ -64,9 +64,6 @@ QMAKE_LIBS_X11 = -lXext -lX11 -lsocket -lm QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/solaris-cc-64/qmake.conf b/mkspecs/solaris-cc-64/qmake.conf index 80709af5f4..b28c4505c9 100644 --- a/mkspecs/solaris-cc-64/qmake.conf +++ b/mkspecs/solaris-cc-64/qmake.conf @@ -88,9 +88,6 @@ QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread -lrt QMAKE_LIBS_NETWORK = -lresolv -lsocket -lxnet -lnsl -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = CC -xar -o QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/solaris-cc/qmake.conf b/mkspecs/solaris-cc/qmake.conf index 0672841acc..e29d37bc87 100644 --- a/mkspecs/solaris-cc/qmake.conf +++ b/mkspecs/solaris-cc/qmake.conf @@ -71,9 +71,6 @@ QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread -lrt QMAKE_LIBS_NETWORK = -lresolv -lsocket -lxnet -lnsl -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = CC -xar -o QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/solaris-g++-64/qmake.conf b/mkspecs/solaris-g++-64/qmake.conf index 7bc7b9fd60..c08212765d 100644 --- a/mkspecs/solaris-g++-64/qmake.conf +++ b/mkspecs/solaris-g++-64/qmake.conf @@ -92,9 +92,6 @@ QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread -lrt QMAKE_LIBS_NETWORK = -lresolv -lsocket -lxnet -lnsl -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cq QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/solaris-g++/qmake.conf b/mkspecs/solaris-g++/qmake.conf index be21cdd1da..5c9909210f 100644 --- a/mkspecs/solaris-g++/qmake.conf +++ b/mkspecs/solaris-g++/qmake.conf @@ -75,9 +75,6 @@ QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread -lrt QMAKE_LIBS_NETWORK = -lresolv -lsocket -lxnet -lnsl -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cq QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/tru64-cxx/qmake.conf b/mkspecs/tru64-cxx/qmake.conf index afabf3e220..a8db2a3c3a 100644 --- a/mkspecs/tru64-cxx/qmake.conf +++ b/mkspecs/tru64-cxx/qmake.conf @@ -64,9 +64,6 @@ QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lrt -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/tru64-g++/qmake.conf b/mkspecs/tru64-g++/qmake.conf index 6acd5cdb22..e1236cf5f8 100644 --- a/mkspecs/tru64-g++/qmake.conf +++ b/mkspecs/tru64-g++/qmake.conf @@ -66,9 +66,6 @@ QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread -lexc -lrt -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/unixware-cc/qmake.conf b/mkspecs/unixware-cc/qmake.conf index 74478d66e2..4e55970aa7 100644 --- a/mkspecs/unixware-cc/qmake.conf +++ b/mkspecs/unixware-cc/qmake.conf @@ -69,9 +69,6 @@ QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cq QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/unixware-g++/qmake.conf b/mkspecs/unixware-g++/qmake.conf index a158d9522a..753c3a86a7 100644 --- a/mkspecs/unixware-g++/qmake.conf +++ b/mkspecs/unixware-g++/qmake.conf @@ -68,9 +68,6 @@ QMAKE_LIBS_OPENGL = -lGL -lXt QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lthread -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cq QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/unsupported/integrity-ghs/qmake.conf b/mkspecs/unsupported/integrity-ghs/qmake.conf index 54253edc8f..7f2ac2fb04 100644 --- a/mkspecs/unsupported/integrity-ghs/qmake.conf +++ b/mkspecs/unsupported/integrity-ghs/qmake.conf @@ -50,9 +50,6 @@ QMAKE_LIBS_X11 = QMAKE_LIBS_X11SM = QMAKE_LIBS_THREAD = -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_RANLIB = diff --git a/mkspecs/unsupported/linux-host-g++/qmake.conf b/mkspecs/unsupported/linux-host-g++/qmake.conf index 1ad529ebae..2e0b7dba44 100644 --- a/mkspecs/unsupported/linux-host-g++/qmake.conf +++ b/mkspecs/unsupported/linux-host-g++/qmake.conf @@ -108,9 +108,6 @@ QMAKE_LIBS_OPENGL_ES2 = -lGLESv2 QMAKE_LIBS_OPENVG = -lOpenVG QMAKE_LIBS_THREAD = -lpthread -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = host-ar cqs QMAKE_OBJCOPY = host-objcopy QMAKE_RANLIB = diff --git a/mkspecs/unsupported/qnx-g++/qmake.conf b/mkspecs/unsupported/qnx-g++/qmake.conf index 83c4a26e06..bc96c21e9f 100644 --- a/mkspecs/unsupported/qnx-g++/qmake.conf +++ b/mkspecs/unsupported/qnx-g++/qmake.conf @@ -37,9 +37,6 @@ QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = QMAKE_LIBS_NETWORK = -lsocket -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_RANLIB = diff --git a/mkspecs/unsupported/vxworks-ppc-dcc/qmake.conf b/mkspecs/unsupported/vxworks-ppc-dcc/qmake.conf index a3b571b144..10f2627d66 100644 --- a/mkspecs/unsupported/vxworks-ppc-dcc/qmake.conf +++ b/mkspecs/unsupported/vxworks-ppc-dcc/qmake.conf @@ -84,9 +84,6 @@ QMAKE_LIBS_THREAD = QMAKE_LIBS_NETWORK = # -lnetwrap # only needed if kernel is missing gethostbyname and friends -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = diff --git a/mkspecs/unsupported/vxworks-simpentium-dcc/qmake.conf b/mkspecs/unsupported/vxworks-simpentium-dcc/qmake.conf index 8bdf1c5011..c3c974e3e7 100644 --- a/mkspecs/unsupported/vxworks-simpentium-dcc/qmake.conf +++ b/mkspecs/unsupported/vxworks-simpentium-dcc/qmake.conf @@ -83,9 +83,6 @@ QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = QMAKE_LIBS_NETWORK = # -lnet # only needed if kernel is missing gethostbyname and friends -QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -QMAKE_UIC = $$[QT_INSTALL_BINS]/uic - QMAKE_AR = ar cqs QMAKE_OBJCOPY = objcopy QMAKE_RANLIB = From 8c7aa37aa7d34860a9c062808416cef0118b36d6 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 28 Feb 2012 17:12:32 +0100 Subject: [PATCH 33/37] dispose of BOOTSTRAPPING define this is used only in qmake, not in other bootstrapped tools Change-Id: Ie2841e69dbd82c86d2297ddf51443ee75760766c Reviewed-by: Joerg Bornemann Reviewed-by: Marius Storm-Olsen --- src/corelib/global/qlibraryinfo.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index ac99b80cb0..ff1fd6bfdd 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -46,11 +46,7 @@ #include "qlibraryinfo.h" #include "qscopedpointer.h" -#if defined(QT_BUILD_QMAKE) || defined(QT_BOOTSTRAPPED) -# define BOOTSTRAPPING -#endif - -#ifdef BOOTSTRAPPING +#ifdef QT_BUILD_QMAKE QT_BEGIN_NAMESPACE extern QString qmake_libraryInfoFile(); QT_END_NAMESPACE @@ -97,7 +93,7 @@ public: QLibrarySettings::QLibrarySettings() : settings(QLibraryInfoPrivate::findConfiguration()) { -#ifndef BOOTSTRAPPING +#ifndef QT_BUILD_QMAKE qAddPostRoutine(QLibraryInfoPrivate::cleanup); #endif } @@ -105,7 +101,7 @@ QLibrarySettings::QLibrarySettings() QSettings *QLibraryInfoPrivate::findConfiguration() { QString qtconfig = QLatin1String(":/qt/etc/qt.conf"); -#ifdef BOOTSTRAPPING +#ifdef QT_BUILD_QMAKE if(!QFile::exists(qtconfig)) qtconfig = qmake_libraryInfoFile(); #else @@ -286,7 +282,7 @@ QLibraryInfo::location(LibraryLocation loc) QString baseDir; if (loc == PrefixPath) { // we make the prefix path absolute to the executable's directory -#ifdef BOOTSTRAPPING +#ifdef QT_BUILD_QMAKE baseDir = QFileInfo(qmake_libraryInfoFile()).absolutePath(); #else if (QCoreApplication::instance()) { From 6663b5ebac7f750a3fb53dc61fbfb466bebec931 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 28 Feb 2012 17:26:59 +0100 Subject: [PATCH 34/37] exclude some code from the qmake build Change-Id: Ic989a2cc5106496a2c5f13c863a0a87d5cd2d963 Reviewed-by: Joerg Bornemann Reviewed-by: Marius Storm-Olsen --- src/corelib/global/qlibraryinfo.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index ff1fd6bfdd..c7f0cd1c28 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -148,6 +148,8 @@ QSettings *QLibraryInfoPrivate::findConfiguration() \sa QSysInfo, {Using qt.conf} */ +#ifndef QT_BUILD_QMAKE + /*! \internal You cannot create a QLibraryInfo, instead only the static functions are available to query @@ -210,6 +212,8 @@ QLibraryInfo::isDebugBuild() return false; } +#endif // QT_BUILD_QMAKE + static const struct { char key[14], value[13]; } qtConfEntries[] = { From c0e9041b6dc2cc46334df2dffe640f1ead1e0898 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 29 Feb 2012 14:02:48 +0100 Subject: [PATCH 35/37] optimize QMakeProperty make it table-driven and have it cache the immutable values from QLibraryInfo. Change-Id: I07ed89152aa964bc9edf4436ee7c42f99cc6bcd3 Reviewed-by: Joerg Bornemann Reviewed-by: Marius Storm-Olsen --- qmake/property.cpp | 66 +++++++++++++++++++--------------------------- qmake/property.h | 4 +++ 2 files changed, 31 insertions(+), 39 deletions(-) diff --git a/qmake/property.cpp b/qmake/property.cpp index 4221605545..dec204cb9c 100644 --- a/qmake/property.cpp +++ b/qmake/property.cpp @@ -51,8 +51,30 @@ QT_BEGIN_NAMESPACE QStringList qmake_mkspec_paths(); //project.cpp +static const struct { + const char *name; + QLibraryInfo::LibraryLocation loc; +} propList[] = { + { "QT_INSTALL_PREFIX", QLibraryInfo::PrefixPath }, + { "QT_INSTALL_DATA", QLibraryInfo::DataPath }, + { "QT_INSTALL_DOCS", QLibraryInfo::DocumentationPath }, + { "QT_INSTALL_HEADERS", QLibraryInfo::HeadersPath }, + { "QT_INSTALL_LIBS", QLibraryInfo::LibrariesPath }, + { "QT_INSTALL_BINS", QLibraryInfo::BinariesPath }, + { "QT_INSTALL_TESTS", QLibraryInfo::TestsPath }, + { "QT_INSTALL_PLUGINS", QLibraryInfo::PluginsPath }, + { "QT_INSTALL_IMPORTS", QLibraryInfo::ImportsPath }, + { "QT_INSTALL_TRANSLATIONS", QLibraryInfo::TranslationsPath }, + { "QT_INSTALL_CONFIGURATION", QLibraryInfo::SettingsPath }, + { "QT_INSTALL_EXAMPLES", QLibraryInfo::ExamplesPath }, + { "QT_INSTALL_DEMOS", QLibraryInfo::ExamplesPath }, // Just backwards compat +}; + QMakeProperty::QMakeProperty() : settings(0) { + for (int i = 0; i < sizeof(propList)/sizeof(propList[0]); i++) + m_values[QString::fromLatin1(propList[i].name)] = + QLibraryInfo::location(propList[i].loc); } QMakeProperty::~QMakeProperty() @@ -80,32 +102,9 @@ QMakeProperty::keyBase(bool version) const QString QMakeProperty::value(QString v, bool just_check) { - if(v == "QT_INSTALL_PREFIX") - return QLibraryInfo::location(QLibraryInfo::PrefixPath); - else if(v == "QT_INSTALL_DATA") - return QLibraryInfo::location(QLibraryInfo::DataPath); - else if(v == "QT_INSTALL_DOCS") - return QLibraryInfo::location(QLibraryInfo::DocumentationPath); - else if(v == "QT_INSTALL_HEADERS") - return QLibraryInfo::location(QLibraryInfo::HeadersPath); - else if(v == "QT_INSTALL_LIBS") - return QLibraryInfo::location(QLibraryInfo::LibrariesPath); - else if(v == "QT_INSTALL_BINS") - return QLibraryInfo::location(QLibraryInfo::BinariesPath); - else if(v == "QT_INSTALL_TESTS") - return QLibraryInfo::location(QLibraryInfo::TestsPath); - else if(v == "QT_INSTALL_PLUGINS") - return QLibraryInfo::location(QLibraryInfo::PluginsPath); - else if(v == "QT_INSTALL_IMPORTS") - return QLibraryInfo::location(QLibraryInfo::ImportsPath); - else if(v == "QT_INSTALL_TRANSLATIONS") - return QLibraryInfo::location(QLibraryInfo::TranslationsPath); - else if(v == "QT_INSTALL_CONFIGURATION") - return QLibraryInfo::location(QLibraryInfo::SettingsPath); - else if(v == "QT_INSTALL_EXAMPLES") - return QLibraryInfo::location(QLibraryInfo::ExamplesPath); - else if(v == "QT_INSTALL_DEMOS") - return QLibraryInfo::location(QLibraryInfo::ExamplesPath); + QString val = m_values.value(v); + if (!val.isNull()) + return val; else if(v == "QMAKE_MKSPECS") return qmake_mkspec_paths().join(Option::dirlist_sep); else if(v == "QMAKE_VERSION") @@ -194,19 +193,8 @@ QMakeProperty::exec() } } QStringList specialProps; - specialProps.append("QT_INSTALL_PREFIX"); - specialProps.append("QT_INSTALL_DATA"); - specialProps.append("QT_INSTALL_DOCS"); - specialProps.append("QT_INSTALL_HEADERS"); - specialProps.append("QT_INSTALL_LIBS"); - specialProps.append("QT_INSTALL_BINS"); - specialProps.append("QT_INSTALL_TESTS"); - specialProps.append("QT_INSTALL_PLUGINS"); - specialProps.append("QT_INSTALL_IMPORTS"); - specialProps.append("QT_INSTALL_TRANSLATIONS"); - specialProps.append("QT_INSTALL_CONFIGURATION"); - specialProps.append("QT_INSTALL_EXAMPLES"); - specialProps.append("QT_INSTALL_DEMOS"); + for (int i = 0; i < sizeof(propList)/sizeof(propList[0]); i++) + specialProps.append(QString::fromLatin1(propList[i].name)); specialProps.append("QMAKE_MKSPECS"); specialProps.append("QMAKE_VERSION"); #ifdef QT_VERSION_STR diff --git a/qmake/property.h b/qmake/property.h index d67d0ad09d..6195e482fb 100644 --- a/qmake/property.h +++ b/qmake/property.h @@ -44,6 +44,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -55,6 +56,9 @@ class QMakeProperty void initSettings(); QString keyBase(bool =true) const; QString value(QString, bool just_check); + + QHash m_values; + public: QMakeProperty(); ~QMakeProperty(); From 012f799254eedc610e2e33842e62d2a184b14fcc Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 28 Feb 2012 20:57:38 +0100 Subject: [PATCH 36/37] revamp -sysroot and -hostprefix handling instead of being a variable added to the makespec (via qconfig.pri), QT_SYSROOT is now a property. the QT_INSTALL_... properties are now automatically prefixed with the sysroot; the raw values are available as QT_RAW_INSTALL_... - this is expected to cause the least migration effort for existing projects. -hostprefix and the new -hostbindir & -hostdatadir now feed the new QT_HOST_... properties. adapted the qmake feature files and the qtbase build system accordingly. Change-Id: Iaa9b65bc10d9fe9c4988d620c70a8ce72177f8d4 Reviewed-by: Marius Storm-Olsen --- configure | 103 ++++++++++++++++--------- dist/changes-5.0.0 | 6 +- mkspecs/features/default_pre.prf | 4 +- mkspecs/features/module.prf | 2 +- mkspecs/features/qt_config.prf | 2 +- mkspecs/features/qt_functions.prf | 4 +- mkspecs/features/qt_module.prf | 2 +- mkspecs/features/qt_module_config.prf | 22 +++--- qmake/generators/makefile.cpp | 2 +- qmake/generators/win32/msvc_vcproj.cpp | 10 +-- qmake/project.cpp | 6 +- qmake/property.cpp | 48 ++++++++---- qtbase.pro | 8 +- src/corelib/global/qlibraryinfo.cpp | 44 ++++++++++- src/corelib/global/qlibraryinfo.h | 12 +++ src/tools/moc/moc.pro | 2 +- src/tools/rcc/rcc.pro | 2 +- src/tools/uic/uic.pro | 2 +- tools/configure/configureapp.cpp | 80 +++++++++++++------ 19 files changed, 244 insertions(+), 117 deletions(-) diff --git a/configure b/configure index 7aa8adaa43..de65cdc7bc 100755 --- a/configure +++ b/configure @@ -825,7 +825,10 @@ QT_INSTALL_TRANSLATIONS= QT_INSTALL_SETTINGS= QT_INSTALL_EXAMPLES= QT_INSTALL_TESTS= +CFG_SYSROOT= QT_HOST_PREFIX= +QT_HOST_BINS= +QT_HOST_DATA= #flags for SQL drivers QT_CFLAGS_PSQL= @@ -978,7 +981,7 @@ while [ "$#" -gt 0 ]; do shift VAL=$1 ;; - -prefix|-docdir|-headerdir|-plugindir|-importdir|-datadir|-libdir|-bindir|-translationdir|-sysconfdir|-examplesdir|-testsdir|-depths|-make|-nomake|-platform|-xplatform|-sdk|-arch|-host-arch|-mysql_config|-sysroot) + -prefix|-docdir|-headerdir|-plugindir|-importdir|-datadir|-libdir|-bindir|-translationdir|-sysconfdir|-examplesdir|-testsdir|-depths|-make|-nomake|-platform|-xplatform|-sdk|-arch|-host-arch|-mysql_config|-sysroot|-hostdatadir|-hostbindir) VAR=`echo $1 | sed "s,^-\(.*\),\1,"` shift VAL="$1" @@ -1169,6 +1172,12 @@ while [ "$#" -gt 0 ]; do hostprefix) QT_HOST_PREFIX="$VAL" ;; + hostdatadir) + QT_HOST_DATA="$VAL" + ;; + hostbindir) + QT_HOST_BINS="$VAL" + ;; force-pkg-config) QT_FORCE_PKGCONFIG=yes ;; @@ -3116,6 +3125,40 @@ if [ -z "$QT_INSTALL_TESTS" ]; then #default fi QT_INSTALL_TESTS=`"$relpath/config.tests/unix/makeabs" "$QT_INSTALL_TESTS"` +#------- host paths -------- + +if [ -z "$QT_HOST_PREFIX" ]; then + QT_HOST_PREFIX=$QT_INSTALL_PREFIX + haveHpx=false +else + QT_HOST_PREFIX=`"$relpath/config.tests/unix/makeabs" "$QT_HOST_PREFIX"` + haveHpx=true +fi + +if [ -z "$QT_HOST_BINS" ]; then #default + if $haveHpx; then + if [ "$CFG_PREFIX_INSTALL" = "no" ]; then + if [ "$BUILD_ON_MAC" = "yes" ]; then + QT_HOST_BINS="/Developer/Applications/Qt" + fi + fi + [ -z "$QT_HOST_BINS" ] && QT_HOST_BINS="$QT_HOST_PREFIX/bin" #fallback + else + QT_HOST_BINS="$QT_INSTALL_BINS" + fi +fi +QT_HOST_BINS=`"$relpath/config.tests/unix/makeabs" "$QT_HOST_BINS"` + +if [ -z "$QT_HOST_DATA" ]; then #default + if $haveHpx; then + QT_HOST_DATA="$QT_HOST_PREFIX" + else + QT_HOST_DATA="$QT_INSTALL_DATA" + fi +else + QT_HOST_DATA=`"$relpath/config.tests/unix/makeabs" "$QT_HOST_DATA"` +fi + #------------------------------------------------------------------------------- # help - interactive parts of the script _after_ this section please #------------------------------------------------------------------------------- @@ -3233,6 +3276,7 @@ cat < ....... Tests will be installed to (default PREFIX/tests) +EOF +if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then +cat < .. Host executables will be installed to + (default HOSTPREFIX/bin) + -hostdatadir . Data used by qmake will be installed to + (default HOSTPREFIX) +EOF +fi +cat <> "$outpath/src/corelib/global/qconfig.cpp.new" <> "$outpath/src/corelib/global/qconfig.cpp.new" <> "$outpath/src/corelib/global/qconfig.cpp.new" <> "$outpath/src/corelib/global/qconfig.cpp.new" <>"$QTCONFIG.tmp" echo `basename "$XQMAKESPEC"` \{ >>"$QTCONFIG.tmp" - echo " QT_SYSROOT += \$\$quote($CFG_SYSROOT)" >>"$QTCONFIG.tmp" - echo " QMAKE_CFLAGS += --sysroot=\$\$QT_SYSROOT" >>"$QTCONFIG.tmp" - echo " QMAKE_CXXFLAGS += --sysroot=\$\$QT_SYSROOT" >>"$QTCONFIG.tmp" - echo " QMAKE_LFLAGS += --sysroot=\$\$QT_SYSROOT" >>"$QTCONFIG.tmp" + echo " QMAKE_CFLAGS += --sysroot=\$\$[QT_SYSROOT]" >>"$QTCONFIG.tmp" + echo " QMAKE_CXXFLAGS += --sysroot=\$\$[QT_SYSROOT]" >>"$QTCONFIG.tmp" + echo " QMAKE_LFLAGS += --sysroot=\$\$[QT_SYSROOT]" >>"$QTCONFIG.tmp" echo "}" >> "$QTCONFIG.tmp" echo >> "$QTCONFIG.tmp" fi diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0 index e1f1f07203..ca9047b682 100644 --- a/dist/changes-5.0.0 +++ b/dist/changes-5.0.0 @@ -202,7 +202,11 @@ information about a particular change. - qmake * Projects which explicitly set an empty TARGET are considered broken now. - * several functions and built-in variables were modified to return normalized paths. + * Configure's -sysroot and -hostprefix are now handled slightly differently. + The QT_INSTALL_... properties are now automatically prefixed with the sysroot; + the raw values are available as QT_RAW_INSTALL_... and the sysroot as QT_SYSROOT. + The new QT_HOST_... properties can be used to refer to the Qt host tools. + * Several functions and built-in variables were modified to return normalized paths. - QTextCodecPlugin has been removed since it is no longer used. All text codecs are now built into QtCore. diff --git a/mkspecs/features/default_pre.prf b/mkspecs/features/default_pre.prf index 1a56787d15..aa706393a5 100644 --- a/mkspecs/features/default_pre.prf +++ b/mkspecs/features/default_pre.prf @@ -26,10 +26,10 @@ CONFIG = lex yacc warn_on debug uic resources $$CONFIG # can we tell syncqt to do a -developer-build win32 { CMP_QDIR = $$upper($$QTDIR) - CMP_INSTALL_PREFIX = $$upper($$[QT_INSTALL_PREFIX]) + CMP_INSTALL_PREFIX = $$upper($$[QT_HOST_PREFIX]) } else { CMP_QDIR = $$QTDIR - CMP_INSTALL_PREFIX = $$[QT_INSTALL_PREFIX] + CMP_INSTALL_PREFIX = $$[QT_HOST_PREFIX] } contains(CMP_QDIR, $$CMP_INSTALL_PREFIX):QTFWD = -qtdir $$QTDIR -module-fwd $$QTDIR/mkspecs/modules -developer-build unset(CMP_QDIR) diff --git a/mkspecs/features/module.prf b/mkspecs/features/module.prf index 85639f0345..d95c7a418d 100644 --- a/mkspecs/features/module.prf +++ b/mkspecs/features/module.prf @@ -1,5 +1,5 @@ !isEmpty(MODULE_PRI) { - pritarget.path = $$[QT_INSTALL_DATA]/mkspecs/modules + pritarget.path = $$[QT_HOST_DATA]/mkspecs/modules pritarget.files = $$MODULE_PRI INSTALLS += pritarget } else { diff --git a/mkspecs/features/qt_config.prf b/mkspecs/features/qt_config.prf index 8441728815..8d0dcce92c 100644 --- a/mkspecs/features/qt_config.prf +++ b/mkspecs/features/qt_config.prf @@ -8,7 +8,7 @@ exists($$_QMAKE_CACHE_) { isEmpty(QMAKE_QT_CONFIG)|!exists($$QMAKE_QT_CONFIG) { !isEmpty(QT_BUILD_TREE):QMAKE_QT_CONFIG = $$QT_BUILD_TREE else:exists($$_QMAKE_CACHE_):QMAKE_QT_CONFIG = $$fromfile($$_QMAKE_CACHE_, QT_BUILD_TREE) - isEmpty(QMAKE_QT_CONFIG):QMAKE_QT_CONFIG = $$[QT_INSTALL_DATA] + isEmpty(QMAKE_QT_CONFIG):QMAKE_QT_CONFIG = $$[QT_HOST_DATA] QMAKE_QT_CONFIG = $$QMAKE_QT_CONFIG/mkspecs/qconfig.pri } !exists($$QMAKE_QT_CONFIG)|!include($$QMAKE_QT_CONFIG, "", true) { diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf index 65eec35bfc..31b28156e8 100644 --- a/mkspecs/features/qt_functions.prf +++ b/mkspecs/features/qt_functions.prf @@ -132,7 +132,7 @@ defineTest(qtAddModule) { isEmpty(LINKAGE) { # Make sure we can link to uninstalled libraries - !isEqual(MODULE_LIBS, $$[QT_INSTALL_LIBS]) { + !isEqual(MODULE_LIBS, $$[QT_INSTALL_LIBS]) { ### XXX QMAKE_LIBDIR *= $$MODULE_LIBS unix:!mac:QMAKE_LFLAGS *= "-Wl,-rpath-link,$$MODULE_LIBS" } @@ -164,7 +164,7 @@ defineTest(qtAddModule) { # variable, default defineTest(qtPrepareTool) { - MODBASE = $$[QT_INSTALL_BINS] + MODBASE = $$[QT_HOST_BINS] !isEmpty(QT_BUILD_TREE):MODBASE = $$QT_BUILD_TREE/bin count(ARGS, 2, greaterThan) { isEmpty(QT.$${3}.bins):warning("No QT.$${3}.bins, module path ignored for qtPrepareTool($$1, $$2, $$3)") diff --git a/mkspecs/features/qt_module.prf b/mkspecs/features/qt_module.prf index aee95295e8..b71ef61252 100644 --- a/mkspecs/features/qt_module.prf +++ b/mkspecs/features/qt_module.prf @@ -8,7 +8,7 @@ isEmpty(QMAKE_QT_MODULE)|!exists($$QMAKE_QT_MODULE) { !exists($$QMAKE_QT_MODULE):exists($$QMAKE_CACHE_DIR/mkspecs/qmodule.pri):QMAKE_QT_MODULE = $$QMAKE_CACHE_DIR/mkspecs/qmodule.pri !exists($$QMAKE_QT_MODULE):exists($$QMAKE_CACHE_DIR/qtbase/mkspecs/qmodule.pri):QMAKE_QT_MODULE = $$QMAKE_CACHE_DIR/qtbase/mkspecs/qmodule.pri !exists($$QMAKE_QT_MODULE):if(!isEmpty(QT_BUILD_TREE) & exists($$QT_BUILD_TREE/mkspecs/qmodule.pri)):QMAKE_QT_MODULE = $$QT_BUILD_TREE/mkspecs/qmodule.pri - !exists($$QMAKE_QT_MODULE):exists($$[QT_INSTALL_DATA]/mkspecs/qmodule.pri):QMAKE_QT_MODULE = $$[QT_INSTALL_DATA]/mkspecs/qmodule.pri + !exists($$QMAKE_QT_MODULE):exists($$[QT_HOST_DATA]/mkspecs/qmodule.pri):QMAKE_QT_MODULE = $$[QT_HOST_DATA]/mkspecs/qmodule.pri } !contains(QMAKE_INTERNAL_INCLUDED_FILES, .*qmodule\\.pri) { diff --git a/mkspecs/features/qt_module_config.prf b/mkspecs/features/qt_module_config.prf index a8439198df..ad6990657b 100644 --- a/mkspecs/features/qt_module_config.prf +++ b/mkspecs/features/qt_module_config.prf @@ -118,18 +118,18 @@ load(qt_installs) unix { CONFIG += create_libtool create_pc explicitlib - QMAKE_LIBTOOL_LIBDIR = $$[QT_INSTALL_LIBS] - QMAKE_PRL_LIBDIR = $$[QT_INSTALL_LIBS] - QMAKE_PKGCONFIG_LIBDIR = $$[QT_INSTALL_LIBS] - QMAKE_PKGCONFIG_INCDIR = $$[QT_INSTALL_HEADERS]/$$TARGET - QMAKE_PKGCONFIG_CFLAGS = -I$$[QT_INSTALL_HEADERS] + QMAKE_LIBTOOL_LIBDIR = $$[QT_RAW_INSTALL_LIBS] + QMAKE_PRL_LIBDIR = $$[QT_RAW_INSTALL_LIBS] ### XXX + QMAKE_PKGCONFIG_LIBDIR = $$[QT_RAW_INSTALL_LIBS] + QMAKE_PKGCONFIG_INCDIR = $$[QT_RAW_INSTALL_HEADERS]/$$TARGET + QMAKE_PKGCONFIG_CFLAGS = -I$$[QT_RAW_INSTALL_HEADERS] QMAKE_PKGCONFIG_DESTDIR = pkgconfig include_replace.match = $$QMAKE_INCDIR_QT - include_replace.replace = $$[QT_INSTALL_HEADERS] + include_replace.replace = $$[QT_RAW_INSTALL_HEADERS] lib_replace.match = $$QMAKE_LIBDIR_QT - lib_replace.replace = $$[QT_INSTALL_LIBS] + lib_replace.replace = $$[QT_RAW_INSTALL_LIBS] prefix_replace.match = $$QT_BUILD_TREE - prefix_replace.replace = $$[QT_INSTALL_PREFIX] + prefix_replace.replace = $$[QT_RAW_INSTALL_PREFIX] QMAKE_PRL_INSTALL_REPLACE += include_replace lib_replace QMAKE_LIBTOOL_INSTALL_REPLACE += include_replace lib_replace QMAKE_PKGCONFIG_INSTALL_REPLACE += include_replace lib_replace prefix_replace @@ -137,9 +137,9 @@ unix { win32-g++* { CONFIG += create_pc - QMAKE_PKGCONFIG_LIBDIR = $$[QT_INSTALL_LIBS] - QMAKE_PKGCONFIG_INCDIR = $$[QT_INSTALL_HEADERS]/$$TARGET - QMAKE_PKGCONFIG_CFLAGS = -I$$[QT_INSTALL_HEADERS] + QMAKE_PKGCONFIG_LIBDIR = $$[QT_RAW_INSTALL_LIBS] + QMAKE_PKGCONFIG_INCDIR = $$[QT_RAW_INSTALL_HEADERS]/$$TARGET + QMAKE_PKGCONFIG_CFLAGS = -I$$[QT_RAW_INSTALL_HEADERS] QMAKE_PKGCONFIG_DESTDIR = pkgconfig } diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 59a615e63a..45cb250fe1 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -3178,7 +3178,7 @@ MakefileGenerator::pkgConfigPrefix() const { if(!project->isEmpty("QMAKE_PKGCONFIG_PREFIX")) return project->first("QMAKE_PKGCONFIG_PREFIX"); - return QLibraryInfo::location(QLibraryInfo::PrefixPath); + return QLibraryInfo::rawLocation(QLibraryInfo::PrefixPath); } QString diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 109b50fd94..434d4b4559 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -1575,11 +1575,11 @@ QString VcprojGenerator::findTemplate(QString file) QString ret; if(!exists((ret = file)) && !exists((ret = QString(Option::mkfile::qmakespec + "/" + file))) && - !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::DataPath) + "/win32-msvc.net/" + file))) && - !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::DataPath) + "/win32-msvc2002/" + file))) && - !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::DataPath) + "/win32-msvc2003/" + file))) && - !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::DataPath) + "/win32-msvc2005/" + file))) && - !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::DataPath) + "/win32-msvc2008/" + file)))) + !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::HostDataPath) + "/win32-msvc.net/" + file))) && + !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::HostDataPath) + "/win32-msvc2002/" + file))) && + !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::HostDataPath) + "/win32-msvc2003/" + file))) && + !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::HostDataPath) + "/win32-msvc2005/" + file))) && + !exists((ret = QString(QLibraryInfo::location(QLibraryInfo::HostDataPath) + "/win32-msvc2008/" + file)))) return ""; debug_msg(1, "Generator: MSVC.NET: Found template \'%s\'", ret.toLatin1().constData()); return ret; diff --git a/qmake/project.cpp b/qmake/project.cpp index 52f2206410..bfd4511f2f 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -592,7 +592,7 @@ QStringList qmake_feature_paths(QMakeProperty *prop=0) } for(QStringList::Iterator concat_it = concat.begin(); concat_it != concat.end(); ++concat_it) - feature_roots << (QLibraryInfo::location(QLibraryInfo::DataPath) + + feature_roots << (QLibraryInfo::location(QLibraryInfo::HostDataPath) + mkspecs_concat + (*concat_it)); return feature_roots; } @@ -607,7 +607,7 @@ QStringList qmake_mkspec_paths() for(QStringList::ConstIterator it = lst.begin(); it != lst.end(); ++it) ret << ((*it) + concat); } - ret << QLibraryInfo::location(QLibraryInfo::DataPath) + concat; + ret << QLibraryInfo::location(QLibraryInfo::HostDataPath) + concat; return ret; } @@ -3113,7 +3113,7 @@ QStringList &QMakeProject::values(const QString &_var, QHash LastHostPath) { + QString sysroot = rawLocation(SysrootPath); + if (!sysroot.isEmpty() && ret.length() > 2 && ret.at(1) == QLatin1Char(':') + && (ret.at(2) == QLatin1Char('/') || ret.at(2) == QLatin1Char('\\'))) + ret.replace(0, 2, sysroot); // Strip out the drive on Windows targets + else + ret.prepend(sysroot); + } + + return ret; +} + +QString +QLibraryInfo::rawLocation(LibraryLocation loc) +{ +#else +# define rawLocation location +#endif QString ret; if(!QLibraryInfoPrivate::configuration()) { const char *path = 0; @@ -284,11 +311,19 @@ QLibraryInfo::location(LibraryLocation loc) if (QDir::isRelativePath(ret)) { QString baseDir; - if (loc == PrefixPath) { - // we make the prefix path absolute to the executable's directory #ifdef QT_BUILD_QMAKE + if (loc == HostPrefixPath || loc == PrefixPath) { + // We make the prefix path absolute to the executable's directory. + // loc == PrefixPath while a sysroot is set would make no sense here. baseDir = QFileInfo(qmake_libraryInfoFile()).absolutePath(); + } else if (loc == SysrootPath) { + // The sysroot is bare + return ret; + } else if (loc > SysrootPath && loc <= LastHostPath) { + // We make any other host path absolute to the host prefix directory. + baseDir = rawLocation(HostPrefixPath); #else + if (loc == PrefixPath) { if (QCoreApplication::instance()) { #ifdef Q_OS_MAC CFBundleRef bundleRef = CFBundleGetMainBundle(); @@ -300,6 +335,7 @@ QLibraryInfo::location(LibraryLocation loc) } } #endif + // We make the prefix path absolute to the executable's directory. baseDir = QCoreApplication::applicationDirPath(); } else { baseDir = QDir::currentPath(); @@ -307,7 +343,7 @@ QLibraryInfo::location(LibraryLocation loc) #endif } else { // we make any other path absolute to the prefix directory - baseDir = location(PrefixPath); + baseDir = rawLocation(PrefixPath); } ret = QDir::cleanPath(baseDir + QLatin1Char('/') + ret); } diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h index f6234d1eb4..d180e63198 100644 --- a/src/corelib/global/qlibraryinfo.h +++ b/src/corelib/global/qlibraryinfo.h @@ -77,9 +77,21 @@ public: TranslationsPath, ExamplesPath, TestsPath, + // Insert new values above this line +#ifdef QT_BUILD_QMAKE + // These are not subject to binary compatibility constraints + SysrootPath, + HostPrefixPath, + HostBinariesPath, + HostDataPath, + LastHostPath = HostDataPath, +#endif SettingsPath = 100 }; static QString location(LibraryLocation); // ### Qt 5: consider renaming it to path() +#ifdef QT_BUILD_QMAKE + static QString rawLocation(LibraryLocation); +#endif private: QLibraryInfo(); diff --git a/src/tools/moc/moc.pro b/src/tools/moc/moc.pro index 3ee507855c..5c96c96a4c 100644 --- a/src/tools/moc/moc.pro +++ b/src/tools/moc/moc.pro @@ -13,6 +13,6 @@ HEADERS += qdatetime_p.h SOURCES += main.cpp include(../bootstrap/bootstrap.pri) -target.path=$$[QT_INSTALL_BINS] +target.path = $$[QT_HOST_BINS] INSTALLS += target load(qt_targets) diff --git a/src/tools/rcc/rcc.pro b/src/tools/rcc/rcc.pro index 6c78642406..e87ef605b9 100644 --- a/src/tools/rcc/rcc.pro +++ b/src/tools/rcc/rcc.pro @@ -11,6 +11,6 @@ HEADERS += ../../corelib/kernel/qcorecmdlineargs_p.h SOURCES += main.cpp include(../bootstrap/bootstrap.pri) -target.path=$$[QT_INSTALL_BINS] +target.path = $$[QT_HOST_BINS] INSTALLS += target load(qt_targets) diff --git a/src/tools/uic/uic.pro b/src/tools/uic/uic.pro index 7a95db861f..0acc6e77c8 100644 --- a/src/tools/uic/uic.pro +++ b/src/tools/uic/uic.pro @@ -22,6 +22,6 @@ linux-g++-maemo { include(../bootstrap/bootstrap.pri) -target.path=$$[QT_INSTALL_BINS] +target.path = $$[QT_HOST_BINS] INSTALLS += target load(qt_targets) diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index e4c9bb2010..504728abc8 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -1063,11 +1063,33 @@ void Configure::parseCmdLine() dictionary[ "QT_INSTALL_TESTS" ] = configCmdLine.at(i); } - else if (configCmdLine.at(i) == "-hostprefix") { + else if (configCmdLine.at(i) == "-sysroot") { ++i; if (i == argCount) break; - dictionary[ "QT_HOST_PREFIX" ] = configCmdLine.at(i); + dictionary[ "CFG_SYSROOT" ] = configCmdLine.at(i); + } + + else if (configCmdLine.at(i) == "-hostprefix") { + ++i; + if (i == argCount || configCmdLine.at(i).startsWith('-')) + dictionary[ "QT_HOST_PREFIX" ] = dictionary[ "QT_BUILD_TREE" ]; + else + dictionary[ "QT_HOST_PREFIX" ] = configCmdLine.at(i); + } + + else if (configCmdLine.at(i) == "-hostbindir") { + ++i; + if (i == argCount) + break; + dictionary[ "QT_HOST_BINS" ] = configCmdLine.at(i); + } + + else if (configCmdLine.at(i) == "-hostdatadir") { + ++i; + if (i == argCount) + break; + dictionary[ "QT_HOST_DATA" ] = configCmdLine.at(i); } else if (configCmdLine.at(i) == "-make") { @@ -2381,6 +2403,16 @@ void Configure::generateOutputVars() if (!dictionary[ "QT_INSTALL_TESTS" ].size()) dictionary[ "QT_INSTALL_TESTS" ] = qipempty ? "" : fixSeparators(dictionary[ "QT_INSTALL_PREFIX" ] + "/tests"); + bool haveHpx = false; + if (dictionary[ "QT_HOST_PREFIX" ].isEmpty()) + dictionary[ "QT_HOST_PREFIX" ] = dictionary[ "QT_INSTALL_PREFIX" ]; + else + haveHpx = true; + if (dictionary[ "QT_HOST_BINS" ].isEmpty()) + dictionary[ "QT_HOST_BINS" ] = haveHpx ? fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/bin") : dictionary[ "QT_INSTALL_BINS" ]; + if (dictionary[ "QT_HOST_DATA" ].isEmpty()) + dictionary[ "QT_HOST_DATA" ] = haveHpx ? dictionary[ "QT_HOST_PREFIX" ] : dictionary[ "QT_INSTALL_DATA" ]; + if (dictionary.contains("XQMAKESPEC") && dictionary[ "XQMAKESPEC" ].startsWith("linux")) dictionary[ "QMAKE_RPATHDIR" ] = dictionary[ "QT_INSTALL_LIBS" ]; @@ -2599,6 +2631,17 @@ void Configure::generateCachefile() << "QT_MINOR_VERSION = " << dictionary["VERSION_MINOR"] << endl << "QT_PATCH_VERSION = " << dictionary["VERSION_PATCH"] << endl; + if (!dictionary["CFG_SYSROOT"].isEmpty()) { + QString targetSpec = dictionary.contains("XQMAKESPEC") ? dictionary[ "XQMAKESPEC" ] : dictionary[ "QMAKESPEC" ]; + configStream << endl + << "# sysroot" << endl + << targetSpec << " {" << endl + << " QMAKE_CFLAGS += --sysroot=$$[QT_SYSROOT]" << endl + << " QMAKE_CXXFLAGS += --sysroot=$$[QT_SYSROOT]" << endl + << " QMAKE_LFLAGS += --sysroot=$$[QT_SYSROOT]" << endl + << "}" << endl; + } + configStream.flush(); configFile.close(); } @@ -2854,10 +2897,8 @@ void Configure::generateConfigfiles() << endl << "/* Build date */" << endl << "static const char qt_configure_installation [11 + 12] = \"qt_instdate=" << QDate::currentDate().toString(Qt::ISODate) << "\";" << endl - << endl; - if (!dictionary[ "QT_HOST_PREFIX" ].isNull()) - tmpStream << "#if !defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE)" << endl; - tmpStream << "static const char qt_configure_prefix_path_strs[][12 + 512] = {" << endl + << endl + << "static const char qt_configure_prefix_path_strs[][12 + 512] = {" << endl << " \"qt_prfxpath=" << escapeSeparators(dictionary["QT_INSTALL_PREFIX"]) << "\"," << endl << " \"qt_docspath=" << escapeSeparators(dictionary["QT_INSTALL_DOCS"]) << "\"," << endl << " \"qt_hdrspath=" << escapeSeparators(dictionary["QT_INSTALL_HEADERS"]) << "\"," << endl @@ -2869,27 +2910,16 @@ void Configure::generateConfigfiles() << " \"qt_trnspath=" << escapeSeparators(dictionary["QT_INSTALL_TRANSLATIONS"]) << "\"," << endl << " \"qt_xmplpath=" << escapeSeparators(dictionary["QT_INSTALL_EXAMPLES"]) << "\"," << endl << " \"qt_tstspath=" << escapeSeparators(dictionary["QT_INSTALL_TESTS"]) << "\"," << endl + << "#ifdef QT_BUILD_QMAKE" << endl + << " \"qt_ssrtpath=" << escapeSeparators(dictionary["CFG_SYSROOT"]) << "\"," << endl + << " \"qt_hpfxpath=" << escapeSeparators(dictionary["QT_HOST_PREFIX"]) << "\"," << endl + << " \"qt_hbinpath=" << escapeSeparators(dictionary["QT_HOST_BINS"]) << "\"," << endl + << " \"qt_hdatpath=" << escapeSeparators(dictionary["QT_HOST_DATA"]) << "\"," << endl + << "#endif" << endl << "};" << endl //<< "static const char qt_configure_settings_path_str [256] = \"qt_stngpath=" << escapeSeparators(dictionary["QT_INSTALL_SETTINGS"]) << "\";" << endl - ; - if (!dictionary[ "QT_HOST_PREFIX" ].isNull()) { - tmpStream << "#else" << endl - << "static const char qt_configure_prefix_path_strs[][12 + 512] = {" << endl - << " \"qt_prfxpath=" << escapeSeparators(dictionary[ "QT_HOST_PREFIX" ]) << "\";" << endl - << " \"qt_docspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/doc", true) <<"\"," << endl - << " \"qt_hdrspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/include", true) <<"\"," << endl - << " \"qt_libspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/lib", true) <<"\"," << endl - << " \"qt_binspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/bin", true) <<"\"," << endl - << " \"qt_plugpath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/plugins", true) <<"\"," << endl - << " \"qt_impspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/imports", true) <<"\"," << endl - << " \"qt_datapath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ], true) <<"\"," << endl - << " \"qt_trnspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/translations", true) <<"\"," << endl - << " \"qt_xmplpath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/example", true) <<"\"," << endl - << " \"qt_tstspath=" << fixSeparators(dictionary[ "QT_HOST_PREFIX" ] + "/tests", true) <<"\"," << endl - << "};" << endl - << "#endif //QT_BOOTSTRAPPED" << endl; - } - tmpStream << "/* strlen( \"qt_lcnsxxxx\") == 12 */" << endl + << endl + << "/* strlen( \"qt_lcnsxxxx\") == 12 */" << endl << "#define QT_CONFIGURE_LICENSEE qt_configure_licensee_str + 12;" << endl << "#define QT_CONFIGURE_LICENSED_PRODUCTS qt_configure_licensed_products_str + 12;" << endl //<< "#define QT_CONFIGURE_SETTINGS_PATH qt_configure_settings_path_str + 12;" << endl From fb8c95bac09910c4dfa476ab97c6206b2e94ee53 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 29 Feb 2012 15:07:12 +0100 Subject: [PATCH 37/37] Automatic metatype registration of two-template-argument types. This commit is complimentary to the commit which introduced a similar partial specialization for single template argument types: 6b4f8a68c8da1af7c5be7dc6075b688c9d6ca55f If T and U are available as metatypes, then QHash is too. Change-Id: I09097b954666418b424c8c23577032beb814343a Reviewed-by: Olivier Goffart --- src/corelib/kernel/qmetatype.h | 22 +++ .../kernel/qmetatype/tst_qmetatype.cpp | 133 ++++++++++++++++++ 2 files changed, 155 insertions(+) diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index beb7294abd..f969875455 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -565,6 +565,7 @@ template class QSet; template class QSharedPointer; template class QMap; template class QHash; +template struct QPair; typedef QList QVariantList; typedef QMap QVariantMap; typedef QHash QVariantHash; @@ -586,6 +587,23 @@ struct QMetaTypeId< SINGLE_ARG_TEMPLATE > \ } \ }; +#define Q_DECLARE_METATYPE_TEMPLATE_2ARG(DOUBLE_ARG_TEMPLATE) \ +template \ +struct QMetaTypeId< DOUBLE_ARG_TEMPLATE > \ +{ \ + enum { \ + Defined = QMetaTypeId2::Defined && QMetaTypeId2::Defined \ + }; \ + static int qt_metatype_id() \ + { \ + static QBasicAtomicInt metatype_id = Q_BASIC_ATOMIC_INITIALIZER(0); \ + if (!metatype_id.load()) \ + metatype_id.storeRelease(qRegisterMetaType< DOUBLE_ARG_TEMPLATE >( QByteArray(QByteArray(#DOUBLE_ARG_TEMPLATE "<") + QMetaType::typeName(qMetaTypeId()) + ", " + QMetaType::typeName(qMetaTypeId()) + ">").constData(), \ + reinterpret_cast< DOUBLE_ARG_TEMPLATE *>(quintptr(-1)))); \ + return metatype_id.loadAcquire(); \ + } \ +}; + Q_DECLARE_METATYPE_TEMPLATE_1ARG(QList) Q_DECLARE_METATYPE_TEMPLATE_1ARG(QVector) Q_DECLARE_METATYPE_TEMPLATE_1ARG(QQueue) @@ -594,6 +612,10 @@ Q_DECLARE_METATYPE_TEMPLATE_1ARG(QSet) Q_DECLARE_METATYPE_TEMPLATE_1ARG(QSharedPointer) Q_DECLARE_METATYPE_TEMPLATE_1ARG(QLinkedList) +Q_DECLARE_METATYPE_TEMPLATE_2ARG(QHash) +Q_DECLARE_METATYPE_TEMPLATE_2ARG(QMap) +Q_DECLARE_METATYPE_TEMPLATE_2ARG(QPair) + inline QMetaType::QMetaType(const ExtensionFlag extensionFlags, const QMetaTypeInterface *info, Creator creator, Deleter deleter, diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 06919c6f58..f8403f11a1 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -1053,6 +1053,61 @@ void tst_QMetaType::registerStreamBuiltin() Q_DECLARE_METATYPE(QSharedPointer) +typedef QHash IntUIntHash; +Q_DECLARE_METATYPE(IntUIntHash) +typedef QMap IntUIntMap; +Q_DECLARE_METATYPE(IntUIntMap) +typedef QPair IntUIntPair; +Q_DECLARE_METATYPE(IntUIntPair) + +struct CustomComparable +{ + CustomComparable(int i_ = 0) :i(i_) { } + bool operator==(const CustomComparable &other) const + { + return i == other.i; + } + int i; +}; + +struct UnregisteredType {}; + +typedef QHash IntComparableHash; +Q_DECLARE_METATYPE(IntComparableHash) +typedef QMap IntComparableMap; +Q_DECLARE_METATYPE(IntComparableMap) +typedef QPair IntComparablePair; +Q_DECLARE_METATYPE(IntComparablePair) + +typedef QHash IntIntHash; +typedef int NaturalNumber; +class AutoMetaTypeObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(IntIntHash someHash READ someHash CONSTANT) + Q_PROPERTY(NaturalNumber someInt READ someInt CONSTANT) +public: + AutoMetaTypeObject(QObject *parent = 0) + : QObject(parent), m_int(42) + { + m_hash.insert(4, 2); + } + + QHash someHash() const + { + return m_hash; + } + + int someInt() const + { + return m_int; + } + +private: + QHash m_hash; + int m_int; +}; + void tst_QMetaType::automaticTemplateRegistration() { { @@ -1094,6 +1149,84 @@ void tst_QMetaType::automaticTemplateRegistration() vectorList << sharedPointerList; QVERIFY(QVariant::fromValue(vectorList).value > > >().first().first() == testObject); } + { + IntIntHash intIntHash; + intIntHash.insert(4, 2); + QCOMPARE(QVariant::fromValue(intIntHash).value().value(4), 2); + + AutoMetaTypeObject amto; + + qRegisterMetaType >("IntIntHash"); + QVariant hashVariant = amto.property("someHash"); + QCOMPARE(hashVariant.value().value(4), 2); + + qRegisterMetaType("NaturalNumber"); + QVariant intVariant = amto.property("someInt"); + QCOMPARE(intVariant.value(), 42); + } + { + IntUIntHash intUIntHash; + intUIntHash.insert(4, 2); + QCOMPARE(QVariant::fromValue(intUIntHash).value().value(4), (uint)2); + } + { + IntComparableHash intComparableHash; + CustomComparable m; + intComparableHash.insert(4, m); + QCOMPARE(QVariant::fromValue(intComparableHash).value().value(4), m); + } + { + QVariantHash variantHash; + variantHash.insert(QStringLiteral("4"), 2); + QCOMPARE(QVariant::fromValue(variantHash).value().value(QStringLiteral("4")), QVariant(2)); + } + { + typedef QMap IntIntMap; + IntIntMap intIntMap; + intIntMap.insert(4, 2); + QCOMPARE(QVariant::fromValue(intIntMap).value().value(4), 2); + } + { + IntUIntMap intUIntMap; + intUIntMap.insert(4, 2); + QCOMPARE(QVariant::fromValue(intUIntMap).value().value(4), (uint)2); + } + { + IntComparableMap intComparableMap; + CustomComparable m; + intComparableMap.insert(4, m); + QCOMPARE(QVariant::fromValue(intComparableMap).value().value(4), m); + } + { + QVariantMap variantMap; + variantMap.insert(QStringLiteral("4"), 2); + QCOMPARE(QVariant::fromValue(variantMap).value().value(QStringLiteral("4")), QVariant(2)); + } + { + typedef QPair IntIntPair; + IntIntPair intIntPair = qMakePair(4, 2); + QCOMPARE(QVariant::fromValue(intIntPair).value().first, 4); + QCOMPARE(QVariant::fromValue(intIntPair).value().second, 2); + } + { + IntUIntPair intUIntPair = qMakePair(4, 2); + QCOMPARE(QVariant::fromValue(intUIntPair).value().first, 4); + QCOMPARE(QVariant::fromValue(intUIntPair).value().second, (uint)2); + } + { + CustomComparable m; + IntComparablePair intComparablePair = qMakePair(4, m); + QCOMPARE(QVariant::fromValue(intComparablePair).value().first, 4); + QCOMPARE(QVariant::fromValue(intComparablePair).value().second, m); + } + { + typedef QHash IntUnregisteredTypeHash; + QVERIFY(qRegisterMetaType("IntUnregisteredTypeHash") > 0); + } + { + typedef QList UnregisteredTypeList; + QVERIFY(qRegisterMetaType("UnregisteredTypeList") > 0); + } } // Compile-time test, it should be possible to register function pointer types