summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mkspecs/features/qt.prf27
-rw-r--r--qmake/generators/integrity/gbuild.cpp4
-rw-r--r--qmake/generators/mac/pbuilder_pbx.cpp2
-rw-r--r--qmake/generators/makefiledeps.cpp4
-rw-r--r--qmake/generators/win32/msvc_objectmodel.cpp2
-rw-r--r--qmake/generators/win32/msvc_objectmodel.h2
-rw-r--r--qmake/project.cpp10
-rw-r--r--src/corelib/codecs/qtextcodec.cpp6
-rw-r--r--src/corelib/global/qglobal.h16
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp18
-rw-r--r--src/corelib/io/qsettings.cpp6
-rw-r--r--src/corelib/kernel/qobjectdefs.h12
-rw-r--r--src/corelib/kernel/qvariant.cpp2
-rw-r--r--src/corelib/tools/qbytearray.cpp6
-rw-r--r--src/corelib/tools/qbytearray.h12
-rw-r--r--src/corelib/tools/qlocale_unix.cpp2
-rw-r--r--src/corelib/tools/qstring.cpp46
-rw-r--r--src/corelib/tools/qstring.h16
-rw-r--r--src/corelib/tools/qstringmatcher.h2
-rw-r--r--src/corelib/xml/qxmlstream.h14
-rw-r--r--src/gui/image/qimage.cpp11
-rw-r--r--src/gui/image/qimage.h4
-rw-r--r--src/gui/image/qpixmap.cpp9
-rw-r--r--src/gui/image/qpixmap.h2
-rw-r--r--src/gui/image/qpixmap_raster.cpp4
-rw-r--r--src/gui/kernel/qpalette.cpp7
-rw-r--r--src/gui/kernel/qpalette.h4
-rw-r--r--src/gui/text/qfontengine.cpp19
-rw-r--r--src/gui/text/qfontengine_p.h1
-rw-r--r--src/gui/text/qfontmetrics.h4
-rw-r--r--src/gui/text/qtextcursor.cpp2
-rw-r--r--src/testlib/qtestcase.h26
-rw-r--r--src/tools/moc/main.cpp2
-rw-r--r--src/tools/moc/moc.cpp110
-rw-r--r--src/tools/moc/moc.h13
-rw-r--r--src/tools/rcc/rcc.cpp2
-rw-r--r--src/tools/uic/cpp/cppwriteicondata.cpp4
-rw-r--r--src/widgets/kernel/qicon.cpp8
-rw-r--r--src/widgets/kernel/qicon.h4
-rw-r--r--src/xml/dom/qdom.cpp8
-rw-r--r--src/xml/sax/qxml.cpp6
-rw-r--r--tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp2
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp152
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp2
44 files changed, 425 insertions, 190 deletions
diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf
index 6081342929..5328e6ccff 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
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 1179812b1b..52f2206410 100644
--- a/qmake/project.cpp
+++ b/qmake/project.cpp
@@ -1487,7 +1487,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);
@@ -2040,7 +2040,7 @@ QMakeProject::doProjectExpand(QString func, QList<QStringList> 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)
@@ -3120,12 +3120,12 @@ QStringList &QMakeProject::values(const QString &_var, QHash<QString, QStringLis
else if(var.startsWith(QLatin1String("QMAKE_TARGET."))) {
QString ret, type = var.mid(13);
if(type == "arch") {
- QString paths = qgetenv("PATH");
- QString vcBin64 = qgetenv("VCINSTALLDIR");
+ QString paths = QString::fromLocal8Bit(qgetenv("PATH"));
+ QString vcBin64 = QString::fromLocal8Bit(qgetenv("VCINSTALLDIR"));
if (!vcBin64.endsWith('\\'))
vcBin64.append('\\');
vcBin64.append("bin\\amd64");
- QString vcBinX86_64 = qgetenv("VCINSTALLDIR");
+ QString vcBinX86_64 = QString::fromLocal8Bit(qgetenv("VCINSTALLDIR"));
if (!vcBinX86_64.endsWith('\\'))
vcBinX86_64.append('\\');
vcBinX86_64.append("bin\\x86_amd64");
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 68866b9000..3119c4f661 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -111,7 +111,7 @@ static bool qisalnum(register char c)
static bool nameMatch(const QByteArray &name, const QByteArray &test)
{
// if they're the same, return a perfect score
- if (qstricmp(name, test) == 0)
+ if (qstricmp(name.constData(), test.constData()) == 0)
return true;
const char *n = name.constData();
@@ -510,7 +510,7 @@ static QTextCodec * ru_RU_hack(const char * i) {
koi8r, latin5, i);
}
#if !defined(QT_NO_SETLOCALE)
- setlocale(LC_CTYPE, origlocale);
+ setlocale(LC_CTYPE, origlocale.constData());
#endif
return ru_RU_codec;
@@ -648,7 +648,7 @@ static void setupLocaleMapper()
else if (try_locale_list(pt_154locales, lang))
localeMapper = QTextCodec::codecForName("PT 154");
else if (try_locale_list(probably_koi8_rlocales, lang))
- localeMapper = ru_RU_hack(lang);
+ localeMapper = ru_RU_hack(lang.constData());
}
}
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 5fbc8cdd19..99328d52ac 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -578,16 +578,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
@@ -648,8 +638,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
@@ -682,8 +670,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
@@ -702,8 +688,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
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index 5e466e480d..e8ff6107ce 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -476,12 +476,12 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea
slash = dirName.length();
}
if (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;
- } else if (QT_MKDIR(chunk, 0777) != 0) {
+ } else if (QT_MKDIR(chunk.constData(), 0777) != 0) {
return false;
}
}
@@ -492,7 +492,7 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea
if (dirName.endsWith(QLatin1Char('/')))
dirName.chop(1);
#endif
- return (QT_MKDIR(QFile::encodeName(dirName), 0777) == 0);
+ return (QT_MKDIR(QFile::encodeName(dirName).constData(), 0777) == 0);
}
//static
@@ -501,12 +501,12 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo
if (removeEmptyParents) {
QString dirName = QDir::cleanPath(entry.filePath());
for (int oldslash = 0, slash=dirName.length(); slash > 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/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index ec51251531..fa0226917f 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/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 1c18883fde..5eaa93c7b0 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -1696,7 +1696,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 bf50159de2..e73c52980f 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -2132,7 +2132,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
@@ -2140,12 +2141,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);
}
/*!
@@ -2200,17 +2201,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;
}
/*!
@@ -2261,10 +2263,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
@@ -2304,10 +2307,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
@@ -2363,10 +2367,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
@@ -2406,9 +2411,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
@@ -4727,7 +4733,7 @@ int QString::localeAwareCompare_helper(const QChar *data1, int length1,
} // else fall through
# endif
// declared in <string.h>
- 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/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index b1ade85a30..6fc86fc04b 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);
@@ -482,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;
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);
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);
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<const uchar *>(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/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<QRgb>
-{
-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<QRgb>, qt_grayPalette)
-
-const QVector<QRgb> &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<QRgb> &grayPalette();
QFixed lastRightBearing(const QGlyphLayout &glyphs, bool round = false);
private:
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 &);
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/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 <typename T1, typename T2>
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, float>(qreal const &t1, float const &t2, const char *actual,
+ inline bool qCompare<double, float>(double const &t1, float const &t2, const char *actual,
const char *expected, const char *file, int line)
{
- return qCompare<qreal>(t1, qreal(t2), actual, expected, file, line);
+ return qCompare<qreal>(qreal(t1), qreal(t2), actual, expected, file, line);
}
template <>
- inline bool qCompare<float, qreal>(float const &t1, qreal const &t2, const char *actual,
+ inline bool qCompare<float, double>(float const &t1, double const &t2, const char *actual,
const char *expected, const char *file, int line)
{
- return qCompare<qreal>(qreal(t1), t2, actual, expected, file, line);
+ return qCompare<qreal>(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, double>(qreal const &t1, double const &t2, const char *actual,
- const char *expected, const char *file, int line)
- {
- return qCompare<float>(float(t1), float(t2), actual, expected, file, line);
- }
-
- template <>
- inline bool qCompare<double, qreal>(double const &t1, qreal const &t2, const char *actual,
- const char *expected, const char *file, int line)
- {
- return qCompare<float>(float(t1), float(t2), actual, expected, file, line);
- }
-
-#endif
-
template <typename T>
inline bool qCompare(const T *t1, const T *t2, const char *actual, const char *expected,
const char *file, int line)
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<QString,QVariant>";
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<QByteArray> 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 <QStringList>
#include <QMap>
#include <QPair>
@@ -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/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp
index b31c47e7ad..dfe23983b7 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/widgets/kernel/qicon.cpp b/src/widgets/kernel/qicon.cpp
index eebd57f97e..97edb4fb0f 100644
--- a/src/widgets/kernel/qicon.cpp
+++ b/src/widgets/kernel/qicon.cpp
@@ -616,7 +616,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
@@ -633,11 +634,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/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp
index 0171fc7bef..c503302fbb 100644
--- a/src/xml/dom/qdom.cpp
+++ b/src/xml/dom/qdom.cpp
@@ -5684,24 +5684,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, "&#60;");
- d = tmp;
+ d = tmp.constData();
len += 4;
i += 5;
}
else if (d[i] == '"') {
tmp.replace(i, 1, "&#34;");
- d = tmp;
+ d = tmp.constData();
len += 4;
i += 5;
} else if (d[i] == '&' && i + 1 < len && d[i+1] == '#') {
// Dont encode &lt; or &quot; or &custom;.
// Only encode character references
tmp.replace(i, 1, "&#38;");
- 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());
}
}
}
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("<p style=\"background-image: url(testPixmap)\">Hello</p>");
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/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<typename T>
+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<DefinedName> p16 READ getP16)
+ Q_PROPERTY(RedefinedTemplateName<RedefinedName> p17 READ getP17)
+
+ Q_PROPERTY(DefinedTemplateName<DefinedName **> p18 READ getP18)
+ Q_PROPERTY(RedefinedTemplateName<RedefinedName **> p19 READ getP19)
+
+ Q_PROPERTY(DefinedTemplateName<DefinedName const * const> p20 READ getP20)
+ Q_PROPERTY(RedefinedTemplateName<RedefinedName const * const> 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<ActualName> tv;
+ ActualTemplateName<ActualName **> tvpp;
+ ActualTemplateName<ActualName const * const> 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<DefinedName> getP16() { return tv; }
+ RedefinedTemplateName<RedefinedName> getP17() { return tv; }
+
+ DefinedTemplateName<DefinedName **> getP18() { return tvpp; }
+ RedefinedTemplateName<RedefinedName **> getP19() { return tvpp; }
+
+ DefinedTemplateName<DefinedName const * const> getP20() { return tvcpc; }
+ RedefinedTemplateName<RedefinedName const * const> 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"
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index 0fe93995a1..f9eb8b6159 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -1335,7 +1335,7 @@ void tst_QComboBox::textpixmapdata()
for (int i = 0; i<text.count(); ++i) {
QIcon icon = testWidget->itemIcon(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());