diff options
67 files changed, 917 insertions, 282 deletions
diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf index 9ec22d57db..d1e0e39cff 100644 --- a/mkspecs/features/qt_functions.prf +++ b/mkspecs/features/qt_functions.prf @@ -240,13 +240,15 @@ defineTest(qtAddTargetEnv) { deppath += $$shell_path($$eval(QT.$${dep}.libs)) equals(QMAKE_HOST.os, Windows) { deppath.name = PATH - } else:contains(QMAKE_HOST.os, Linux|FreeBSD) { + } else:contains(QMAKE_HOST.os, Linux|FreeBSD|OpenBSD|NetBSD|DragonFly|SunOS|HP-UX|QNX|GNU) { deppath.name = LD_LIBRARY_PATH } else:equals(QMAKE_HOST.os, Darwin) { contains(QT_CONFIG, qt_framework): \ deppath.name = DYLD_FRAMEWORK_PATH else: \ deppath.name = DYLD_LIBRARY_PATH + } else:equals(QMAKE_HOST.os, AIX) { + deppath.name = LIBPATH } else { error("Operating system not supported.") } diff --git a/qmake/generators/integrity/gbuild.cpp b/qmake/generators/integrity/gbuild.cpp index 2266a3c06d..ace3558d7d 100644 --- a/qmake/generators/integrity/gbuild.cpp +++ b/qmake/generators/integrity/gbuild.cpp @@ -3,7 +3,7 @@ ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** -** This file is part of the QtGui module of the Qt Toolkit. +** This file is part of the qmake application of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage diff --git a/qmake/generators/integrity/gbuild.h b/qmake/generators/integrity/gbuild.h index 234a2be9af..e69d634abb 100644 --- a/qmake/generators/integrity/gbuild.h +++ b/qmake/generators/integrity/gbuild.h @@ -3,7 +3,7 @@ ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** -** This file is part of the QtGui module of the Qt Toolkit. +** This file is part of the qmake application of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index fb4bf08431..17c72fa5d0 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -200,8 +200,9 @@ const char _slnSolutionConf[] = "\n\tGlobalSection(SolutionConfiguration) = pr "\n\t\tConfigName.0 = Debug|Win32" "\n\t\tConfigName.1 = Release|Win32" "\n\tEndGlobalSection"; -const char _slnProjDepBeg[] = "\n\tGlobalSection(ProjectDependencies) = postSolution"; -const char _slnProjDepEnd[] = "\n\tEndGlobalSection"; + +const char _slnProjDepBeg[] = "\n\tProjectSection(ProjectDependencies) = postProject"; +const char _slnProjDepEnd[] = "\n\tEndProjectSection"; const char _slnProjConfBeg[] = "\n\tGlobalSection(ProjectConfiguration) = postSolution"; const char _slnProjRelConfTag1[]= ".Release|%1.ActiveCfg = Release|"; const char _slnProjRelConfTag2[]= ".Release|%1.Build.0 = Release|"; @@ -571,10 +572,6 @@ ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHash<QSt #endif solution_cleanup.append(newDep); solution_depends.insert(newDep->target, newDep); - t << _slnProjectBeg << _slnMSVCvcprojGUID << _slnProjectMid - << "\"" << newDep->orig_target << "\", \"" << newDep->vcprojFile - << "\", \"" << newDep->uuid << "\""; - t << _slnProjectEnd; } nextfile: qmake_setpwd(oldpwd); @@ -634,6 +631,30 @@ void VcprojGenerator::writeSubDirs(QTextStream &t) QHash<QString, ProStringList> subdirProjectLookup; collectDependencies(project, profileLookup, projGuids, extraSubdirs, solution_depends, solution_cleanup, t, subdirProjectLookup); + // write out projects + for (QList<VcsolutionDepend*>::Iterator it = solution_cleanup.begin(); it != solution_cleanup.end(); ++it) { + t << _slnProjectBeg << _slnMSVCvcprojGUID << _slnProjectMid + << "\"" << (*it)->orig_target << "\", \"" << (*it)->vcprojFile + << "\", \"" << (*it)->uuid << "\""; + + debug_msg(1, "Project %s has dependencies: %s", (*it)->target.toLatin1().constData(), (*it)->dependencies.join(" ").toLatin1().constData()); + + bool hasDependency = false; + for (QStringList::iterator dit = (*it)->dependencies.begin(); dit != (*it)->dependencies.end(); ++dit) { + if (VcsolutionDepend *vc = solution_depends[*dit]) { + if (!hasDependency) { + hasDependency = true; + t << _slnProjDepBeg; + } + t << "\n\t\t" << vc->uuid << " = " << vc->uuid; + } + } + if (hasDependency) + t << _slnProjDepEnd; + + t << _slnProjectEnd; + } + t << _slnGlobalBeg; QHashIterator<VcsolutionDepend *, QStringList> extraIt(extraSubdirs); @@ -657,20 +678,9 @@ void VcprojGenerator::writeSubDirs(QTextStream &t) } t << slnConf; - t << _slnProjDepBeg; - // Restore previous after_user_var options Option::globals->postcmds = old_after_vars; - // Figure out dependencies - for(QList<VcsolutionDepend*>::Iterator it = solution_cleanup.begin(); it != solution_cleanup.end(); ++it) { - int cnt = 0; - for(QStringList::iterator dit = (*it)->dependencies.begin(); dit != (*it)->dependencies.end(); ++dit) { - if(VcsolutionDepend *vc = solution_depends[*dit]) - t << "\n\t\t" << (*it)->uuid << "." << cnt++ << " = " << vc->uuid; - } - } - t << _slnProjDepEnd; t << _slnProjConfBeg; for(QList<VcsolutionDepend*>::Iterator it = solution_cleanup.begin(); it != solution_cleanup.end(); ++it) { QString platform = is64Bit ? "x64" : "Win32"; diff --git a/qmake/generators/xmloutput.cpp b/qmake/generators/xmloutput.cpp index 9cd0995a92..80008cae8c 100644 --- a/qmake/generators/xmloutput.cpp +++ b/qmake/generators/xmloutput.cpp @@ -183,7 +183,7 @@ XmlOutput& XmlOutput::operator<<(const xml_output& o) addRaw(QString("</%1>").arg(o.xo_text)); break; case tValueTag: - addRaw(QString("%1").arg(doConversion(o.xo_text))); + addRaw(doConversion(o.xo_text)); setFormat(NoNewLine); closeTag(); setFormat(NewLine); diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index 0a5cc04a17..44a3f06f50 100644 --- a/src/corelib/corelib.pro +++ b/src/corelib/corelib.pro @@ -58,7 +58,7 @@ QMAKE_DYNAMIC_LIST_FILE = $$PWD/QtCore.dynlist contains(DEFINES,QT_EVAL):include(eval.pri) -HOST_BINS = $$[QT_HOST_BINS/raw] +HOST_BINS = $$[QT_HOST_BINS] host_bins.name = host_bins host_bins.variable = HOST_BINS diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h index f2e5dc7633..4534e9bf13 100644 --- a/src/corelib/global/qfeatures.h +++ b/src/corelib/global/qfeatures.h @@ -311,6 +311,11 @@ #define QT_NO_LOCALSERVER #endif +// QPdf +#if !defined(QT_NO_PDF) && (defined(QT_NO_TEMPORARYFILE)) +#define QT_NO_PDF +#endif + // QMenu #if !defined(QT_NO_MENU) && (defined(QT_NO_ACTION)) #define QT_NO_MENU diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt index 43db585643..61a3df39f3 100644 --- a/src/corelib/global/qfeatures.txt +++ b/src/corelib/global/qfeatures.txt @@ -851,6 +851,13 @@ Requires: Name: Color Names SeeAlso: ??? +Feature: PDF +Description: Supports pdf format +Section: Painting +Requires: TEMPORARYFILE +Name: QPdf +SeeAlso: ??? + Feature: PRINTER Description: Supports printing Section: Painting diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 79e32fe793..4e63e5d0ba 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -45,11 +45,11 @@ #include <stddef.h> -#define QT_VERSION_STR "5.1.0" +#define QT_VERSION_STR "5.1.1" /* QT_VERSION is (major << 16) + (minor << 8) + patch. */ -#define QT_VERSION 0x050100 +#define QT_VERSION 0x050101 /* can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) */ diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp index ed3b399fbf..db81d65565 100644 --- a/src/corelib/io/qlockfile_unix.cpp +++ b/src/corelib/io/qlockfile_unix.cpp @@ -45,6 +45,7 @@ #include "QtCore/qcoreapplication.h" #include "QtCore/qfileinfo.h" #include "QtCore/qdebug.h" +#include "QtCore/qdatetime.h" #include "private/qcore_unix_p.h" // qt_safe_open #include "private/qabstractfileengine_p.h" @@ -80,12 +81,13 @@ static qint64 qt_write_loop(int fd, const char *data, qint64 len) int QLockFilePrivate::checkFcntlWorksAfterFlock() { +#ifndef QT_NO_TEMPORARYFILE QTemporaryFile file; if (!file.open()) - return -2; + return 0; const int fd = file.d_func()->engine()->handle(); if (flock(fd, LOCK_EX | LOCK_NB) == -1) // other threads, and other processes on a local fs - return -3; + return 0; struct flock flockData; flockData.l_type = F_WRLCK; flockData.l_whence = SEEK_SET; @@ -95,6 +97,9 @@ int QLockFilePrivate::checkFcntlWorksAfterFlock() if (fcntl(fd, F_SETLK, &flockData) == -1) // for networked filesystems return 0; return 1; +#else + return 0; +#endif } static QBasicAtomicInt fcntlOK = Q_BASIC_ATOMIC_INITIALIZER(-1); diff --git a/src/corelib/io/qsavefile.cpp b/src/corelib/io/qsavefile.cpp index f8b5ebcabd..5ed429c464 100644 --- a/src/corelib/io/qsavefile.cpp +++ b/src/corelib/io/qsavefile.cpp @@ -39,8 +39,11 @@ ** ****************************************************************************/ -#include "qplatformdefs.h" #include "qsavefile.h" + +#ifndef QT_NO_TEMPORARYFILE + +#include "qplatformdefs.h" #include "private/qsavefile_p.h" #include "qfileinfo.h" #include "qabstractfileengine_p.h" @@ -381,3 +384,5 @@ bool QSaveFile::directWriteFallback() const } QT_END_NAMESPACE + +#endif // QT_NO_TEMPORARYFILE diff --git a/src/corelib/io/qsavefile.h b/src/corelib/io/qsavefile.h index 6d81f58d42..ad18417124 100644 --- a/src/corelib/io/qsavefile.h +++ b/src/corelib/io/qsavefile.h @@ -42,6 +42,10 @@ #ifndef QSAVEFILE_H #define QSAVEFILE_H +#include <QtCore/qglobal.h> + +#ifndef QT_NO_TEMPORARYFILE + #include <QtCore/qfiledevice.h> #include <QtCore/qstring.h> @@ -51,7 +55,6 @@ QT_BEGIN_NAMESPACE - class QAbstractFileEngine; class QSaveFilePrivate; @@ -90,4 +93,6 @@ private: QT_END_NAMESPACE +#endif // QT_NO_TEMPORARYFILE + #endif // QSAVEFILE_H diff --git a/src/corelib/io/qsavefile_p.h b/src/corelib/io/qsavefile_p.h index 53a8b5eb34..b9efd1ee7c 100644 --- a/src/corelib/io/qsavefile_p.h +++ b/src/corelib/io/qsavefile_p.h @@ -53,6 +53,10 @@ // We mean it. // +#include <QtCore/qglobal.h> + +#ifndef QT_NO_TEMPORARYFILE + #include "private/qfiledevice_p.h" QT_BEGIN_NAMESPACE @@ -75,4 +79,6 @@ protected: QT_END_NAMESPACE +#endif // QT_NO_TEMPORARYFILE + #endif // QSAVEFILE_P_H diff --git a/src/corelib/io/qtemporaryfile_p.h b/src/corelib/io/qtemporaryfile_p.h index d274f60ecc..fe637c8dfd 100644 --- a/src/corelib/io/qtemporaryfile_p.h +++ b/src/corelib/io/qtemporaryfile_p.h @@ -42,6 +42,10 @@ #ifndef QTEMPORARYFILE_P_H #define QTEMPORARYFILE_P_H +#include <QtCore/qglobal.h> + +#ifndef QT_NO_TEMPORARYFILE + #include "private/qfsfileengine_p.h" #include "private/qfilesystemengine_p.h" #include "private/qfile_p.h" @@ -99,5 +103,7 @@ public: QT_END_NAMESPACE +#endif // QT_NO_TEMPORARYFILE + #endif /* QTEMPORARYFILE_P_H */ diff --git a/src/corelib/io/qurlidna.cpp b/src/corelib/io/qurlidna.cpp index fac1703da8..5fa4b5f7a1 100644 --- a/src/corelib/io/qurlidna.cpp +++ b/src/corelib/io/qurlidna.cpp @@ -1468,11 +1468,12 @@ static void mapToLowerCase(QString *str, int from) int l = 1; while (l < 4 && entry->mapping[l]) ++l; - if (l > 1) { + if (l > 1 || uc > 0xffff) { if (uc <= 0xffff) str->replace(i, 1, reinterpret_cast<const QChar *>(&entry->mapping[0]), l); else - str->replace(i-1, 2, reinterpret_cast<const QChar *>(&entry->mapping[0]), l); + str->replace(--i, 2, reinterpret_cast<const QChar *>(&entry->mapping[0]), l); + i += l - 1; d = 0; } else { if (!d) @@ -1501,18 +1502,20 @@ static bool isMappedToNothing(uint uc) } -static void stripProhibitedOutput(QString *str, int from) +static bool containsProhibitedOuptut(const QString *str, int from) { - ushort *out = (ushort *)str->data() + from; - const ushort *in = out; + const ushort *in = reinterpret_cast<const ushort *>(str->begin() + from); const ushort *end = (ushort *)str->data() + str->size(); - while (in < end) { + for ( ; in < end; ++in) { uint uc = *in; if (QChar(uc).isHighSurrogate() && in < end - 1) { ushort low = *(in + 1); if (QChar(low).isLowSurrogate()) { ++in; uc = QChar::surrogateToUcs4(uc, low); + } else { + // unpaired surrogates are prohibited + return true; } } if (uc <= 0xFFFF) { @@ -1537,7 +1540,7 @@ static void stripProhibitedOutput(QString *str, int from) || (uc >= 0xFDD0 && uc <= 0xFDEF) || uc == 0xFEFF || (uc >= 0xFFF9 && uc <= 0xFFFF))) { - *out++ = *in; + continue; } } else { if (!((uc >= 0x1D173 && uc <= 0x1D17A) @@ -1561,14 +1564,12 @@ static void stripProhibitedOutput(QString *str, int from) || (uc >= 0xFFFFE && uc <= 0xFFFFF) || (uc >= 0x100000 && uc <= 0x10FFFD) || (uc >= 0x10FFFE && uc <= 0x10FFFF))) { - *out++ = QChar::highSurrogate(uc); - *out++ = QChar::lowSurrogate(uc); + continue; } } - ++in; + return true; } - if (in != out) - str->truncate(out - str->utf16()); + return false; } static bool isBidirectionalRorAL(uint uc) @@ -2028,7 +2029,7 @@ Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from) for ( ; out < e; ++out) { register ushort uc = out->unicode(); - if (uc > 0x80) { + if (uc >= 0x80) { break; } else if (uc >= 'A' && uc <= 'Z') { *out = QChar(uc | 0x20); @@ -2065,8 +2066,8 @@ Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from) if (uc <= 0xFFFF) { *out++ = *in; } else { - *out++ = QChar::highSurrogate(uc); - *out++ = QChar::lowSurrogate(uc); + *out++ = in[-1]; + *out++ = in[0]; } } } @@ -2083,7 +2084,10 @@ Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from) firstNonAscii > from ? firstNonAscii - 1 : from); // Strip prohibited output - stripProhibitedOutput(source, firstNonAscii); + if (containsProhibitedOuptut(source, firstNonAscii)) { + source->resize(from); + return; + } // Check for valid bidirectional characters bool containsLCat = false; diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index aed998f2e2..7413ef4d89 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -830,8 +830,8 @@ struct QMetaTypeId_ ## SMART_POINTER ## _QObjectStar<T, true> \ return id; \ const char * const cName = T::staticMetaObject.className(); \ QByteArray typeName; \ - typeName.reserve(sizeof(#SMART_POINTER) + 1 + strlen(cName) + 1); \ - typeName.append(#SMART_POINTER, sizeof(#SMART_POINTER) - 1) \ + typeName.reserve(int(sizeof(#SMART_POINTER) + 1 + strlen(cName) + 1)); \ + typeName.append(#SMART_POINTER, int(sizeof(#SMART_POINTER)) - 1) \ .append('<').append(cName).append('>'); \ const int newId = qRegisterNormalizedMetaType< SMART_POINTER<T> >( \ typeName, \ diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index 289fda7afc..61c9b40e83 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -121,6 +121,10 @@ void QFactoryLoader::update() d->loadedPaths << pluginDir; QString path = pluginDir + d->suffix; + + if (qt_debug_component()) + qDebug() << "QFactoryLoader::QFactoryLoader() checking directory path" << path << "..."; + if (!QDir(path).exists(QLatin1String("."))) continue; diff --git a/src/corelib/tools/qalgorithms.qdoc b/src/corelib/tools/qalgorithms.qdoc index cc544af868..ad6c3d913c 100644 --- a/src/corelib/tools/qalgorithms.qdoc +++ b/src/corelib/tools/qalgorithms.qdoc @@ -33,7 +33,7 @@ \brief The <QtAlgorithms> header includes the generic, template-based algorithms. Qt provides a number of global template functions in \c - <QtAlgorithms> that work on containers and perform well-know + <QtAlgorithms> that work on containers and perform well-known algorithms. You can use these algorithms with any \l {container class} that provides STL-style iterators, including Qt's QList, QLinkedList, QVector, QMap, and QHash classes. diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index 3cd8c51c07..c8a0825480 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -62,7 +62,7 @@ struct QPodArrayOps Q_ASSERT(newSize <= this->alloc); ::memset(this->end(), 0, (newSize - this->size) * sizeof(T)); - this->size = newSize; + this->size = int(newSize); } void copyAppend(const T *b, const T *e) @@ -84,7 +84,7 @@ struct QPodArrayOps const T *const end = iter + n; for (; iter != end; ++iter) ::memcpy(iter, &t, sizeof(T)); - this->size += n; + this->size += int(n); } void truncate(size_t newSize) @@ -92,7 +92,7 @@ struct QPodArrayOps Q_ASSERT(!this->ref.isShared()); Q_ASSERT(newSize < size_t(this->size)); - this->size = newSize; + this->size = int(newSize); } void destroyAll() // Call from destructors, ONLY! diff --git a/src/corelib/tools/qbitarray.cpp b/src/corelib/tools/qbitarray.cpp index 2b459b2b1b..b04c4f9c3d 100644 --- a/src/corelib/tools/qbitarray.cpp +++ b/src/corelib/tools/qbitarray.cpp @@ -122,7 +122,8 @@ QT_BEGIN_NAMESPACE */ QBitArray::QBitArray(int size, bool value) { - if (!size) { + Q_ASSERT_X(size >= 0, "QBitArray::QBitArray", "Size must be greater than or equal to 0."); + if (size <= 0) { d.resize(0); return; } diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp index e197fd9178..41b2b266ee 100644 --- a/src/corelib/tools/qrect.cpp +++ b/src/corelib/tools/qrect.cpp @@ -201,6 +201,12 @@ QT_BEGIN_NAMESPACE function to manipulate the rectangle's coordinates and dimensions in one go. + \section1 Constraints + + QRect is limited to the minimum and maximum values for the \c int type. + Operations on a QRect that could potentially result in values outside this + range will result in undefined behavior. + \sa QRectF, QRegion */ diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp index 97a64eb5bb..c81df7a6f2 100644 --- a/src/corelib/tools/qsimd.cpp +++ b/src/corelib/tools/qsimd.cpp @@ -240,14 +240,14 @@ inline quint64 _xgetbv(__int64) { return 0; } #endif static void xgetbv(uint in, uint &eax, uint &edx) { -#ifdef Q_OS_WIN - quint64 result = _xgetbv(in); - eax = result; - edx = result >> 32; -#elif defined(Q_CC_GNU) +#if defined(Q_CC_GNU) asm (".byte 0x0F, 0x01, 0xD0" // xgetbv instruction : "=a" (eax), "=d" (edx) : "c" (in)); +#elif defined(Q_OS_WIN) + quint64 result = _xgetbv(in); + eax = result; + edx = result >> 32; #endif } diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 3a2028057d..825e05ae1b 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -197,6 +197,8 @@ private: template <class T, int Prealloc> Q_INLINE_TEMPLATE QVarLengthArray<T, Prealloc>::QVarLengthArray(int asize) : s(asize) { + Q_STATIC_ASSERT_X(Prealloc > 0, "QVarLengthArray Prealloc must be greater than 0."); + Q_ASSERT_X(s >= 0, "QVarLengthArray::QVarLengthArray()", "Size must be greater than or equal to 0."); if (s > Prealloc) { ptr = reinterpret_cast<T *>(malloc(s * sizeof(T))); Q_CHECK_PTR(ptr); diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 816e1f15f6..489ee821b9 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -398,7 +398,8 @@ QVector<T> &QVector<T>::operator=(const QVector<T> &v) template <typename T> QVector<T>::QVector(int asize) { - if (Q_LIKELY(asize)) { + Q_ASSERT_X(asize >= 0, "QVector::QVector", "Size must be greater than or equal to 0."); + if (Q_LIKELY(asize > 0)) { d = Data::allocate(asize); d->size = asize; defaultConstruct(d->begin(), d->end()); @@ -410,7 +411,8 @@ QVector<T>::QVector(int asize) template <typename T> QVector<T>::QVector(int asize, const T &t) { - if (asize) { + Q_ASSERT_X(asize >= 0, "QVector::QVector", "Size must be greater than or equal to 0."); + if (asize > 0) { d = Data::allocate(asize); d->size = asize; T* i = d->end(); diff --git a/src/gui/opengl/qopengltextureglyphcache.cpp b/src/gui/opengl/qopengltextureglyphcache.cpp index 83f407575e..7d49c03f5b 100644 --- a/src/gui/opengl/qopengltextureglyphcache.cpp +++ b/src/gui/opengl/qopengltextureglyphcache.cpp @@ -147,6 +147,9 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height) return; } + GLint oldFbo; + glGetIntegerv(GL_FRAMEBUFFER_BINDING, &oldFbo); + int oldWidth = m_textureResource->m_width; int oldHeight = m_textureResource->m_height; @@ -265,7 +268,7 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height) glDeleteTextures(1, &tmp_texture); glDeleteTextures(1, &oldTexture); - funcs.glBindFramebuffer(GL_FRAMEBUFFER, ctx->d_func()->current_fbo); + funcs.glBindFramebuffer(GL_FRAMEBUFFER, (GLuint)oldFbo); if (pex != 0) { glViewport(0, 0, pex->width, pex->height); diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 5d9a743dac..345ebefea7 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -38,9 +38,13 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + +#include "qpdf_p.h" + +#ifndef QT_NO_PDF + #include "qplatformdefs.h" #include <qdebug.h> -#include "qpdf_p.h" #include <qfile.h> #include <qtemporaryfile.h> #include <private/qmath_p.h> @@ -2624,5 +2628,6 @@ void QPdfEnginePrivate::newPage() << "q q\n"; } - QT_END_NAMESPACE + +#endif // QT_NO_PDF diff --git a/src/gui/painting/qpdf_p.h b/src/gui/painting/qpdf_p.h index 44e1446fff..560621775b 100644 --- a/src/gui/painting/qpdf_p.h +++ b/src/gui/painting/qpdf_p.h @@ -52,6 +52,11 @@ // // We mean it. // + +#include <QtCore/qglobal.h> + +#ifndef QT_NO_PDF + #include "QtGui/qmatrix.h" #include "QtCore/qstring.h" #include "QtCore/qvector.h" @@ -328,5 +333,7 @@ void QPdfEngine::setResolution(int resolution) QT_END_NAMESPACE +#endif // QT_NO_PDF + #endif // QPDF_P_H diff --git a/src/gui/painting/qpdfwriter.cpp b/src/gui/painting/qpdfwriter.cpp index ad6b66ae09..136654cb5d 100644 --- a/src/gui/painting/qpdfwriter.cpp +++ b/src/gui/painting/qpdfwriter.cpp @@ -40,6 +40,9 @@ ****************************************************************************/ #include <qpdfwriter.h> + +#ifndef QT_NO_PDF + #include <QtCore/private/qobject_p.h> #include "private/qpdf_p.h" #include <QtCore/qfile.h> @@ -214,3 +217,5 @@ void QPdfWriter::setMargins(const Margins &m) } QT_END_NAMESPACE + +#endif // QT_NO_PDF diff --git a/src/gui/painting/qpdfwriter.h b/src/gui/painting/qpdfwriter.h index 45bb5ad4b4..f5c25de5e9 100644 --- a/src/gui/painting/qpdfwriter.h +++ b/src/gui/painting/qpdfwriter.h @@ -42,12 +42,15 @@ #ifndef QPDFWRITER_H #define QPDFWRITER_H +#include <QtCore/qglobal.h> + +#ifndef QT_NO_PDF + #include <QtCore/qobject.h> #include <QtGui/qpagedpaintdevice.h> QT_BEGIN_NAMESPACE - class QIODevice; class QPdfWriterPrivate; @@ -83,4 +86,6 @@ private: QT_END_NAMESPACE +#endif // QT_NO_PDF + #endif diff --git a/src/gui/text/qfontsubset.cpp b/src/gui/text/qfontsubset.cpp index 649c6ec36d..3c39272d11 100644 --- a/src/gui/text/qfontsubset.cpp +++ b/src/gui/text/qfontsubset.cpp @@ -91,6 +91,8 @@ static const unsigned short symbol_map[0x100] = { // ---------------------------- PS/PDF helper methods ----------------------------------- +#ifndef QT_NO_PDF + QByteArray QFontSubset::glyphName(unsigned short unicode, bool symbol) { if (symbol && unicode < 0x100) @@ -311,6 +313,7 @@ int QFontSubset::addGlyph(int index) return idx; } +#endif // QT_NO_PDF // ------------------------------ Truetype generation ---------------------------------------------- diff --git a/src/gui/text/qfontsubset_p.h b/src/gui/text/qfontsubset_p.h index 00054dfe39..df5e72ab7d 100644 --- a/src/gui/text/qfontsubset_p.h +++ b/src/gui/text/qfontsubset_p.h @@ -62,13 +62,19 @@ class QFontSubset public: explicit QFontSubset(QFontEngine *fe, int obj_id = 0) : object_id(obj_id), noEmbed(false), fontEngine(fe), downloaded_glyphs(0), standard_font(false) - { fontEngine->ref.ref(); addGlyph(0); } + { + fontEngine->ref.ref(); +#ifndef QT_NO_PDF + addGlyph(0); +#endif + } ~QFontSubset() { if (!fontEngine->ref.deref()) delete fontEngine; } QByteArray toTruetype() const; +#ifndef QT_NO_PDF QByteArray widthArray() const; QByteArray createToUnicodeMap() const; QVector<int> getReverseMap() const; @@ -77,6 +83,7 @@ public: static QByteArray glyphName(unsigned short unicode, bool symbol); int addGlyph(int index); +#endif const int object_id; bool noEmbed; QFontEngine *fontEngine; diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp index 4f74936ac7..933bebe2ad 100644 --- a/src/network/bearer/qnetworkconfigmanager.cpp +++ b/src/network/bearer/qnetworkconfigmanager.cpp @@ -62,6 +62,7 @@ static void connManager_cleanup() // this is not atomic or thread-safe! int shutdown = appShutdown.fetchAndStoreAcquire(1); Q_ASSERT(shutdown == 0); + Q_UNUSED(shutdown); QNetworkConfigurationManagerPrivate *cmp = connManager_ptr.fetchAndStoreAcquire(0); if (cmp) cmp->cleanup(); diff --git a/src/platformsupport/input/evdevtouch/qevdevtouch.cpp b/src/platformsupport/input/evdevtouch/qevdevtouch.cpp index 2c93da147e..5e493ac68c 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouch.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouch.cpp @@ -125,6 +125,7 @@ public: bool m_forceToActiveWindow; QTouchDevice *m_device; bool m_typeB; + QTransform m_rotate; }; QEvdevTouchScreenData::QEvdevTouchScreenData(QEvdevTouchScreenHandler *q_ptr, const QStringList &args) @@ -177,10 +178,24 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification, QStringList args = spec.split(QLatin1Char(':')); + int rotationAngle = 0; for (int i = 0; i < args.count(); ++i) { - if (args.at(i).startsWith(QLatin1String("/dev/"))) { + if (args.at(i).startsWith(QLatin1String("/dev/")) && dev.isEmpty()) { dev = args.at(i); - break; + } else if (args.at(i).startsWith(QLatin1String("rotate"))) { + QString rotateArg = args.at(i).section(QLatin1Char('='), 1, 1); + bool ok; + uint argValue = rotateArg.toUInt(&ok); + if (ok) { + switch (argValue) { + case 90: + case 180: + case 270: + rotationAngle = argValue; + default: + break; + } + } } } @@ -265,6 +280,9 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &specification, #endif qDebug("Protocol type %c %s", d->m_typeB ? 'B' : 'A', mtdevStr); + if (rotationAngle) + d->m_rotate = QTransform::fromTranslate(0.5, 0.5).rotate(rotationAngle).translate(-0.5, -0.5); + d->registerDevice(); } @@ -421,6 +439,11 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data) tp.normalPosition = QPointF((contact.x - hw_range_x_min) / qreal(hw_range_x_max - hw_range_x_min), (contact.y - hw_range_y_min) / qreal(hw_range_y_max - hw_range_y_min)); + if (!m_rotate.isIdentity()) + tp.normalPosition = m_rotate.map(tp.normalPosition); + + tp.rawPositions.append(QPointF(contact.x, contact.y)); + m_touchPoints.append(tp); if (contact.state == Qt::TouchPointReleased) @@ -513,9 +536,10 @@ void QEvdevTouchScreenData::reportPoints() QWindowSystemInterface::TouchPoint &tp(m_touchPoints[i]); // Generate a screen position that is always inside the active window - // or the primary screen. - const qreal wx = winRect.left() + tp.normalPosition.x() * winRect.width(); - const qreal wy = winRect.top() + tp.normalPosition.y() * winRect.height(); + // or the primary screen. Even though we report this as a QRectF, internally + // Qt uses QRect/QPoint so we need to bound the size to winRect.size() - QSize(1, 1) + const qreal wx = winRect.left() + tp.normalPosition.x() * (winRect.width() - 1); + const qreal wy = winRect.top() + tp.normalPosition.y() * (winRect.height() - 1); const qreal sizeRatio = (winRect.width() + winRect.height()) / qreal(hw_w + hw_h); if (tp.area.width() == -1) // touch major was not provided tp.area = QRectF(0, 0, 8, 8); diff --git a/src/plugins/bearer/connman/qconnmanservice_linux.cpp b/src/plugins/bearer/connman/qconnmanservice_linux.cpp index 4efecc5464..380cf92a24 100644 --- a/src/plugins/bearer/connman/qconnmanservice_linux.cpp +++ b/src/plugins/bearer/connman/qconnmanservice_linux.cpp @@ -74,7 +74,6 @@ const QDBusArgument &operator>>(const QDBusArgument &argument, ConnmanMap &map) return argument; } -static QDBusConnection dbusConnection = QDBusConnection::systemBus(); QConnmanManagerInterface::QConnmanManagerInterface( QObject *parent) : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), QLatin1String(CONNMAN_MANAGER_PATH), @@ -98,7 +97,7 @@ void QConnmanManagerInterface::connectNotify(const QMetaMethod &signal) QLatin1String(CONNMAN_MANAGER_INTERFACE), QLatin1String("PropertyChanged"), this,SIGNAL(propertyChanged(QString,QDBusVariant)))) { - qWarning() << "PropertyCHanged not connected"; + qWarning() << "PropertyChanged not connected"; } } @@ -118,7 +117,7 @@ void QConnmanManagerInterface::connectNotify(const QMetaMethod &signal) QConnmanDBusHelper *helper; helper = new QConnmanDBusHelper(this); - dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + QDBusConnection::systemBus().connect(QLatin1String(CONNMAN_SERVICE), QLatin1String(CONNMAN_MANAGER_PATH), QLatin1String(CONNMAN_MANAGER_INTERFACE), QLatin1String("PropertyChanged"), @@ -379,7 +378,7 @@ void QConnmanProfileInterface::connectNotify(const QMetaMethod &signal) { static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QConnmanProfileInterface::propertyChanged); if (signal == propertyChangedSignal) { - dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + QDBusConnection::systemBus().connect(QLatin1String(CONNMAN_SERVICE), this->path(), QLatin1String(CONNMAN_PROFILE_INTERFACE), QLatin1String("PropertyChanged"), @@ -449,7 +448,7 @@ void QConnmanServiceInterface::connectNotify(const QMetaMethod &signal) { static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QConnmanServiceInterface::propertyChanged); if (signal == propertyChangedSignal) { - dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + QDBusConnection::systemBus().connect(QLatin1String(CONNMAN_SERVICE), this->path(), QLatin1String(CONNMAN_SERVICE_INTERFACE), QLatin1String("PropertyChanged"), @@ -460,7 +459,7 @@ void QConnmanServiceInterface::connectNotify(const QMetaMethod &signal) QConnmanDBusHelper *helper; helper = new QConnmanDBusHelper(this); - dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + QDBusConnection::systemBus().connect(QLatin1String(CONNMAN_SERVICE), this->path(), QLatin1String(CONNMAN_SERVICE_INTERFACE), QLatin1String("PropertyChanged"), @@ -514,9 +513,6 @@ void QConnmanServiceInterface::remove() QDBusReply<QVariantMap> reply = this->call(QLatin1String("Remove")); } -// void moveBefore(QDBusObjectPath &service); -// void moveAfter(QDBusObjectPath &service); - // properties QString QConnmanServiceInterface::getState() { @@ -779,7 +775,7 @@ void QConnmanTechnologyInterface::connectNotify(const QMetaMethod &signal) { static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QConnmanTechnologyInterface::propertyChanged); if (signal == propertyChangedSignal) { - dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + QDBusConnection::systemBus().connect(QLatin1String(CONNMAN_SERVICE), this->path(), QLatin1String(CONNMAN_TECHNOLOGY_INTERFACE), QLatin1String("PropertyChanged"), @@ -790,7 +786,7 @@ void QConnmanTechnologyInterface::connectNotify(const QMetaMethod &signal) QConnmanDBusHelper *helper; helper = new QConnmanDBusHelper(this); - dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + QDBusConnection::systemBus().connect(QLatin1String(CONNMAN_SERVICE), this->path(), QLatin1String(CONNMAN_TECHNOLOGY_INTERFACE), QLatin1String("PropertyChanged"), @@ -861,23 +857,11 @@ QConnmanAgentInterface::~QConnmanAgentInterface() void QConnmanAgentInterface::connectNotify(const QMetaMethod &signal) { Q_UNUSED(signal); -// static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QConnmanAgentInterface::propertyChanged); -// if (signal == propertyChangedSignal) { -// dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), -// this->path(), -// QLatin1String(CONNMAN_NETWORK_INTERFACE), -// QLatin1String("PropertyChanged"), -// this,SIGNAL(propertyChanged(QString,QVariant&))); -// } } void QConnmanAgentInterface::disconnectNotify(const QMetaMethod &signal) { Q_UNUSED(signal); -// static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QConnmanAgentInterface::propertyChanged); -// if (signal == propertyChangedSignal) { - -// } } @@ -889,10 +873,6 @@ void QConnmanAgentInterface::reportError(QDBusObjectPath &/*path*/, const QStrin { } -//dict QConnmanAgentInterface::requestInput(QDBusObjectPath &path, dict fields) -//{ -//} - void QConnmanAgentInterface::cancel() { } diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index f7c945c50d..55a23fda76 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -151,8 +151,7 @@ [kids addObject: element]; [element release]; } - // ### maybe we should use NSAccessibilityUnignoredChildren(kids); this needs more profiling - return kids; + return NSAccessibilityUnignoredChildren(kids); } else if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) { // Just check if the app thinks we're focused. @@ -272,8 +271,7 @@ // No child found, meaning we hit this element. if (!childInterface) { // qDebug() << "Hit test returns: " << id << iface; - return self; - //return NSAccessibilityUnignoredAncestor(self); + return NSAccessibilityUnignoredAncestor(self); } QAccessible::Id childId = QAccessible::uniqueId(childInterface); diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index 36d7a49746..9c10bc26dd 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -281,7 +281,7 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const sizes << 16 << 32 << 64 << 128; return QVariant::fromValue(sizes); } - case QPlatformTheme::PasswordMaskDelay: + case QPlatformTheme::PasswordMaskCharacter: return QVariant(QChar(kBulletUnicode)); default: break; diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index 85f72a4dbb..c7c6c20473 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -113,6 +113,7 @@ QT_END_NAMESPACE - (void)handleKeyEvent:(NSEvent *)theEvent eventType:(int)eventType; - (void)keyDown:(NSEvent *)theEvent; - (void)keyUp:(NSEvent *)theEvent; +- (BOOL)performKeyEquivalent:(NSEvent *)theEvent; - (void)registerDragTypes; - (NSDragOperation)handleDrag:(id <NSDraggingInfo>)sender; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 5c5da830ac..d43b3d36d2 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -113,6 +113,8 @@ static QTouchDevice *touchDevice = 0; name:NSViewGlobalFrameDidChangeNotification object:self]; } + delete currentCustomDragTypes; + [super dealloc]; } @@ -963,6 +965,23 @@ static QTouchDevice *touchDevice = 0; [self handleKeyEvent:nsevent eventType:int(QEvent::KeyRelease)]; } +- (BOOL)performKeyEquivalent:(NSEvent *)nsevent +{ + NSString *chars = [nsevent charactersIgnoringModifiers]; + + if ([nsevent type] == NSKeyDown && [chars length] > 0) { + QChar ch = [chars characterAtIndex:0]; + Qt::Key qtKey = qt_mac_cocoaKey2QtKey(ch); + // check for Command + Key_Period + if ([nsevent modifierFlags] & NSCommandKeyMask + && qtKey == Qt::Key_Period) { + [self handleKeyEvent:nsevent eventType:int(QEvent::KeyPress)]; + return YES; + } + } + return [super performKeyEquivalent:nsevent]; +} + - (void)flagsChanged:(NSEvent *)nsevent { ulong timestamp = [nsevent timestamp] * 1000; diff --git a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm index 6ebb1f6ba8..331a66417d 100644 --- a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm +++ b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm @@ -88,7 +88,7 @@ [element release]; } - return kids; + return NSAccessibilityUnignoredChildren(kids); } else { return [super accessibilityAttributeValue:attribute]; } diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp index 9523685f70..4c95950a7e 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxwindow.cpp @@ -77,7 +77,7 @@ QQnxWindow::QQnxWindow(QWindow *window, screen_context_t context) #endif m_screen(0), m_parentWindow(0), - m_visible(true), + m_visible(false), m_windowState(Qt::WindowNoState), m_requestedBufferSize(window->geometry().size()) { @@ -153,7 +153,6 @@ QQnxWindow::QQnxWindow(QWindow *window, screen_context_t context) if (window->parent() && window->parent()->handle()) setParent(window->parent()->handle()); setGeometryHelper(window->geometry()); - setVisible(window->isVisible()); } QQnxWindow::~QQnxWindow() @@ -272,6 +271,9 @@ void QQnxWindow::setVisible(bool visible) { qWindowDebug() << Q_FUNC_INFO << "window =" << window() << "visible =" << visible; + if (m_visible == visible) + return; + m_visible = visible; QQnxWindow *root = this; @@ -282,13 +284,13 @@ void QQnxWindow::setVisible(bool visible) window()->requestActivate(); - if (window()->isTopLevel()) { - QWindowSystemInterface::handleExposeEvent(window(), window()->geometry()); + QWindowSystemInterface::handleExposeEvent(window(), window()->geometry()); - if (!visible) { - // Flush the context, otherwise it won't disappear immediately - screen_flush_context(m_screenContext, 0); - } + if (visible) { + applyWindowState(); + } else { + // Flush the context, otherwise it won't disappear immediately + screen_flush_context(m_screenContext, 0); } } @@ -625,35 +627,10 @@ void QQnxWindow::setWindowState(Qt::WindowState state) if (m_windowState == state) return; - switch (state) { - - // WindowActive is not an accepted parameter according to the docs - case Qt::WindowActive: - return; - - case Qt::WindowMinimized: - minimize(); - - if (m_unmaximizedGeometry.isValid()) - setGeometry(m_unmaximizedGeometry); - else - setGeometry(m_screen->geometry()); - - break; - - case Qt::WindowMaximized: - case Qt::WindowFullScreen: - m_unmaximizedGeometry = geometry(); - setGeometry(state == Qt::WindowMaximized ? m_screen->availableGeometry() : m_screen->geometry()); - break; - - case Qt::WindowNoState: - if (m_unmaximizedGeometry.isValid()) - setGeometry(m_unmaximizedGeometry); - break; - } - m_windowState = state; + + if (m_visible) + applyWindowState(); } void QQnxWindow::gainedFocus() @@ -734,6 +711,37 @@ void QQnxWindow::updateZorder(int &topZorder) childWindow->updateZorder(topZorder); } +void QQnxWindow::applyWindowState() +{ + switch (m_windowState) { + + // WindowActive is not an accepted parameter according to the docs + case Qt::WindowActive: + return; + + case Qt::WindowMinimized: + minimize(); + + if (m_unmaximizedGeometry.isValid()) + setGeometry(m_unmaximizedGeometry); + else + setGeometry(m_screen->geometry()); + + break; + + case Qt::WindowMaximized: + case Qt::WindowFullScreen: + m_unmaximizedGeometry = geometry(); + setGeometry(m_windowState == Qt::WindowMaximized ? m_screen->availableGeometry() : m_screen->geometry()); + break; + + case Qt::WindowNoState: + if (m_unmaximizedGeometry.isValid()) + setGeometry(m_unmaximizedGeometry); + break; + } +} + void QQnxWindow::blitHelper(QQnxBuffer &source, QQnxBuffer &target, const QPoint &sourceOffset, const QPoint &targetOffset, const QRegion ®ion, bool flush) { diff --git a/src/plugins/platforms/qnx/qqnxwindow.h b/src/plugins/platforms/qnx/qqnxwindow.h index 4a327fd54b..63d5dc0979 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.h +++ b/src/plugins/platforms/qnx/qqnxwindow.h @@ -124,6 +124,7 @@ private: void setOffset(const QPoint &setOffset); void updateVisibility(bool parentVisible); void updateZorder(int &topZorder); + void applyWindowState(); void fetchBuffers(); diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 924d604641..f6163ed8c7 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -793,7 +793,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms // A multi-character key or a Input method character // not found by our look-ahead if (msgType == WM_CHAR || msgType == WM_IME_CHAR) { - sendExtendedPressRelease(receiver, 0, Qt::KeyboardModifier(state), scancode, vk_key, nModifiers, messageKeyText(msg), false, 0); + sendExtendedPressRelease(receiver, 0, Qt::KeyboardModifier(state), scancode, vk_key, nModifiers, messageKeyText(msg), false); return true; } @@ -822,13 +822,13 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms if (dirStatus == VK_LSHIFT && ((msg.wParam == VK_SHIFT && GetKeyState(VK_LCONTROL)) || (msg.wParam == VK_CONTROL && GetKeyState(VK_LSHIFT)))) { - sendExtendedPressRelease(receiver, Qt::Key_Direction_L, 0, scancode, msg.wParam, nModifiers, QString(), false, 0); + sendExtendedPressRelease(receiver, Qt::Key_Direction_L, 0, scancode, msg.wParam, nModifiers, QString(), false); result = true; dirStatus = 0; } else if (dirStatus == VK_RSHIFT && ( (msg.wParam == VK_SHIFT && GetKeyState(VK_RCONTROL)) || (msg.wParam == VK_CONTROL && GetKeyState(VK_RSHIFT)))) { - sendExtendedPressRelease(receiver, Qt::Key_Direction_R, 0, scancode, msg.wParam, nModifiers, QString(), false, 0); + sendExtendedPressRelease(receiver, Qt::Key_Direction_R, 0, scancode, msg.wParam, nModifiers, QString(), false); result = true; dirStatus = 0; } else { @@ -1020,9 +1020,9 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms if (rec) { if (code < Qt::Key_Shift || code > Qt::Key_ScrollLock) { QWindowSystemInterface::handleExtendedKeyEvent(receiver, QEvent::KeyRelease, code, - Qt::KeyboardModifier(state), scancode, msg.wParam, nModifiers, rec->text, true, 0); + Qt::KeyboardModifier(state), scancode, msg.wParam, nModifiers, rec->text, true); QWindowSystemInterface::handleExtendedKeyEvent(receiver, QEvent::KeyPress, code, - Qt::KeyboardModifier(state), scancode, msg.wParam, nModifiers, rec->text, true, 0); + Qt::KeyboardModifier(state), scancode, msg.wParam, nModifiers, rec->text, true); result = true; } } @@ -1033,7 +1033,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms const char a = uch.row() ? 0 : uch.cell(); key_recorder.storeKey(msg.wParam, a, state, text); QWindowSystemInterface::handleExtendedKeyEvent(receiver, QEvent::KeyPress, code, - Qt::KeyboardModifier(state), scancode, msg.wParam, nModifiers, text, false, 0); + Qt::KeyboardModifier(state), scancode, msg.wParam, nModifiers, text, false); result =true; bool store = true; #ifndef Q_OS_WINCE @@ -1077,7 +1077,7 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms code = Qt::Key_Backtab; QWindowSystemInterface::handleExtendedKeyEvent(receiver, QEvent::KeyRelease, code, Qt::KeyboardModifier(state), scancode, msg.wParam, nModifiers, - (rec ? rec->text : QString()), false, 0); + (rec ? rec->text : QString()), false); result = true; #ifndef Q_OS_WINCE // don't pass Alt to Windows unless we are embedded in a non-Qt window diff --git a/src/plugins/platforms/xcb/qxcbxsettings.cpp b/src/plugins/platforms/xcb/qxcbxsettings.cpp index 7ffd3e105f..c106bd00f8 100644 --- a/src/plugins/platforms/xcb/qxcbxsettings.cpp +++ b/src/plugins/platforms/xcb/qxcbxsettings.cpp @@ -214,23 +214,37 @@ QXcbXSettings::QXcbXSettings(QXcbScreen *screen) QByteArray settings_atom_for_screen("_XSETTINGS_S"); settings_atom_for_screen.append(QByteArray::number(screen->screenNumber())); xcb_intern_atom_cookie_t atom_cookie = xcb_intern_atom(screen->xcb_connection(), - false, + true, settings_atom_for_screen.length(), settings_atom_for_screen.constData()); - xcb_intern_atom_reply_t *atom_reply = xcb_intern_atom_reply(screen->xcb_connection(),atom_cookie,NULL); + xcb_generic_error_t *error = 0; + xcb_intern_atom_reply_t *atom_reply = xcb_intern_atom_reply(screen->xcb_connection(),atom_cookie,&error); + if (error) { + qWarning() << Q_FUNC_INFO << "Failed to find XSETTINGS_S atom"; + return; + } xcb_atom_t selection_owner_atom = atom_reply->atom; free(atom_reply); xcb_get_selection_owner_cookie_t selection_cookie = xcb_get_selection_owner(screen->xcb_connection(), selection_owner_atom); + xcb_get_selection_owner_reply_t *selection_result = - xcb_get_selection_owner_reply(screen->xcb_connection(), selection_cookie, NULL); + xcb_get_selection_owner_reply(screen->xcb_connection(), selection_cookie, &error); + if (error) { + qWarning() << Q_FUNC_INFO << "Failed to get selection owner for XSETTINGS_S atom"; + return; + } d_ptr->x_settings_window = selection_result->owner; + if (!d_ptr->x_settings_window) { + return; + } free(selection_result); + const uint32_t event = XCB_CW_EVENT_MASK; const uint32_t event_mask[] = { XCB_EVENT_MASK_STRUCTURE_NOTIFY|XCB_EVENT_MASK_PROPERTY_CHANGE }; - xcb_change_window_attributes(screen->xcb_connection(),d_ptr->x_settings_window,XCB_CW_EVENT_MASK,event_mask); + xcb_change_window_attributes(screen->xcb_connection(),d_ptr->x_settings_window,event,event_mask); d_ptr->populateSettings(d_ptr->getSettings()); } diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index 653a9170b2..f72abd20ab 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -1677,8 +1677,8 @@ void QTreeWidgetItemPrivate::propagateDisabled(QTreeWidgetItem *item) the item can be checked, edited, and selected. The default value for flags is - Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled. - If the item was constructed with a parent, flags will in addition contain Qt::ItemIsDropEnabled. + Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | + Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled. \sa setFlags() */ diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index abef6e8832..6d648f1126 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -132,7 +132,8 @@ void QLineEdit::initStyleOption(QStyleOptionFrame *option) const A line edit allows the user to enter and edit a single line of plain text with a useful collection of editing functions, - including undo and redo, cut and paste, and drag and drop. + including undo and redo, cut and paste, and drag and drop (see + \l setDragEnabled()). By changing the echoMode() of a line edit, it can also be used as a "write-only" field, for inputs such as passwords. diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index cca4655f58..42dca7fc66 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -1193,6 +1193,13 @@ void tst_QFile::permissions() if (qt_ntfs_permission_lookup) QEXPECT_FAIL("readonly", "QTBUG-25630", Abort); #endif +#ifdef Q_OS_UNIX + if (strcmp(QTest::currentDataTag(), "readonly") == 0) { + // in case accidentally run as root + if (::getuid() == 0) + QSKIP("Running this test as root doesn't make sense"); + } +#endif QCOMPARE((memberResult == QFile::Permissions(perms)), expected); QCOMPARE((staticResult == QFile::Permissions(perms)), expected); } diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 898aefffd3..2a79a6963e 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -1937,6 +1937,21 @@ void tst_QUrl::strictParser_data() QTest::newRow("invalid-ipvfuture-3") << "http://[v789]" << "Invalid IPvFuture address"; QTest::newRow("unbalanced-brackets") << "http://[ff02::1" << "Expected ']' to match '[' in hostname"; + // invalid IDN hostnames happen in TolerantMode too + QTest::newRow("idn-prohibited-char-space") << "http:// " << "Invalid hostname (contains invalid characters)"; + QTest::newRow("idn-prohibited-char-nbsp") << "http://\xc2\xa0" << "Invalid hostname (contains invalid characters)"; + QTest::newRow("idn-prohibited-char-control-1f") << "http://\x1f" << "Invalid hostname (contains invalid characters)"; + QTest::newRow("idn-prohibited-char-control-7f") << "http://\x7f" << "Invalid hostname (contains invalid characters)"; + QTest::newRow("idn-prohibited-char-control-80") << "http://\xc2\x80" << "Invalid hostname (contains invalid characters)"; + QTest::newRow("idn-prohibited-char-private-bmp") << "http://\xee\x80\x80" << "Invalid hostname (contains invalid characters)"; + QTest::newRow("idn-prohibited-char-private-plane15") << "http://\xf3\xb0\x80\x80" << "Invalid hostname (contains invalid characters)"; + QTest::newRow("idn-prohibited-char-private-plane16") << "http://\xf4\x80\x80\x80" << "Invalid hostname (contains invalid characters)"; + QTest::newRow("idn-prohibited-char-ffff") << "http://\xef\xbf\xbf" << "Invalid hostname (contains invalid characters)"; + QTest::newRow("idn-prohibited-char-surrogate-1") << "http://" + QString(QChar(0xD800)) << "Invalid hostname (contains invalid characters)"; + QTest::newRow("idn-prohibited-char-surrogate-2") << "http://" + QString(QChar(0xDC00)) << "Invalid hostname (contains invalid characters)"; + QTest::newRow("idn-prohibited-char-surrogate-3") << "http://" + QString(QChar(0xD800)) + "a" << "Invalid hostname (contains invalid characters)"; + // FIXME: add some tests for prohibited BiDi (RFC 3454 section 6) + // port errors happen in TolerantMode too QTest::newRow("empty-port-1") << "http://example.com:" << "Port field was empty"; QTest::newRow("empty-port-2") << "http://example.com:/" << "Port field was empty"; diff --git a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp index fa3dec620a..2014045171 100644 --- a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp +++ b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp @@ -351,7 +351,7 @@ void tst_QUrlInternal::nameprep_testsuite_data() << QString() << 0 << 0; QTest::newRow("Non-ASCII multibyte space character U+1680") - << QString::fromUtf8("\xE1\x9A\x80") + << QString::fromUtf8("x\xE1\x9A\x80x") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; @@ -375,13 +375,18 @@ void tst_QUrlInternal::nameprep_testsuite_data() << QString::fromUtf8("\x10\x7F") << QString() << 0 << 0; + QTest::newRow("Non-ASCII 8bit control character U+0080") + << QString::fromUtf8("x\xC2\x80x") + << QString() + << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; + QTest::newRow("Non-ASCII 8bit control character U+0085") - << QString::fromUtf8("\xC2\x85") + << QString::fromUtf8("x\xC2\x85x") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Non-ASCII multibyte control character U+180E") - << QString::fromUtf8("\xE1\xA0\x8E") + << QString::fromUtf8("x\xE1\xA0\x8Ex") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; @@ -391,47 +396,47 @@ void tst_QUrlInternal::nameprep_testsuite_data() << QString() << 0 << 0; QTest::newRow("Non-ASCII control character U+1D175") - << QString::fromUtf8("\xF0\x9D\x85\xB5") + << QString::fromUtf8("x\xF0\x9D\x85\xB5x") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Plane 0 private use character U+F123") - << QString::fromUtf8("\xEF\x84\xA3") + << QString::fromUtf8("x\xEF\x84\xA3x") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Plane 15 private use character U+F1234") - << QString::fromUtf8("\xF3\xB1\x88\xB4") + << QString::fromUtf8("x\xF3\xB1\x88\xB4x") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Plane 16 private use character U+10F234") - << QString::fromUtf8("\xF4\x8F\x88\xB4") + << QString::fromUtf8("x\xF4\x8F\x88\xB4x") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Non-character code point U+8FFFE") - << QString::fromUtf8("\xF2\x8F\xBF\xBE") + << QString::fromUtf8("x\xF2\x8F\xBF\xBEx") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Non-character code point U+10FFFF") - << QString::fromUtf8("\xF4\x8F\xBF\xBF") + << QString::fromUtf8("x\xF4\x8F\xBF\xBFx") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Surrogate code U+DF42") - << QString::fromUtf8("\xED\xBD\x82") + << QString::fromUtf8("x\xED\xBD\x82x") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Non-plain text character U+FFFD") - << QString::fromUtf8("\xEF\xBF\xBD") + << QString::fromUtf8("x\xEF\xBF\xBDx") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Ideographic description character U+2FF5") - << QString::fromUtf8("\xE2\xBF\xB5") + << QString::fromUtf8("x\xE2\xBF\xB5x") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; @@ -441,22 +446,22 @@ void tst_QUrlInternal::nameprep_testsuite_data() << QString() << 0 << 0; QTest::newRow("Left-to-right mark U+200E") - << QString::fromUtf8("\xE2\x80\x8E") - << QString::fromUtf8("\xCC\x81") + << QString::fromUtf8("x\xE2\x80\x8Ex") + << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Deprecated U+202A") - << QString::fromUtf8("\xE2\x80\xAA") - << QString::fromUtf8("\xCC\x81") + << QString::fromUtf8("x\xE2\x80\xAA") + << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Language tagging character U+E0001") - << QString::fromUtf8("\xF3\xA0\x80\x81") - << QString::fromUtf8("\xCC\x81") + << QString::fromUtf8("x\xF3\xA0\x80\x81x") + << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; QTest::newRow("Language tagging character U+E0042") - << QString::fromUtf8("\xF3\xA0\x81\x82") + << QString::fromUtf8("x\xF3\xA0\x81\x82x") << QString() << QString("Nameprep") << 0 << STRINGPREP_CONTAINS_PROHIBITED; @@ -512,12 +517,6 @@ void tst_QUrlInternal::nameprep_testsuite() QFETCH(QString, out); QFETCH(QString, profile); - QEXPECT_FAIL("Left-to-right mark U+200E", - "Investigate further", Continue); - QEXPECT_FAIL("Deprecated U+202A", - "Investigate further", Continue); - QEXPECT_FAIL("Language tagging character U+E0001", - "Investigate further", Continue); qt_nameprep(&in, 0); QCOMPARE(in, out); } @@ -549,9 +548,9 @@ void tst_QUrlInternal::nameprep_highcodes_data() << QString() << 0 << 0; } { - QChar st[] = { 'D', 0xdb40, 0xdc20, 'o', 0xd834, 0xdd7a, '\'', 0x2060, 'h' }; + QChar st[] = { 'D', 'o', '\'', 0x2060, 'h' }; QChar se[] = { 'd', 'o', '\'', 'h' }; - QTest::newRow("highcodes (D, U+E0020, o, U+1D17A, ', U+2060, h)") + QTest::newRow("highcodes (D, o, ', U+2060, h)") << QString(st, sizeof(st)/sizeof(st[0])) << QString(se, sizeof(se)/sizeof(se[0])) << QString() << 0 << 0; diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index c19a42e4a6..6f5cda5307 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -252,18 +252,18 @@ void tst_QtJson::testNumbers() 0, -1, 1, - (1UL<<54), - (1UL<<55), - (1UL<<56), - -(1UL<<54), - -(1UL<<55), - -(1UL<<56), - (1UL<<54) - 1, - (1UL<<55) - 1, - (1UL<<56) - 1, - -((1UL<<54) - 1), - -((1UL<<55) - 1), - -((1UL<<56) - 1) + (1ll<<54), + (1ll<<55), + (1ll<<56), + -(1ll<<54), + -(1ll<<55), + -(1ll<<56), + (1ll<<54) - 1, + (1ll<<55) - 1, + (1ll<<56) - 1, + -((1ll<<54) - 1), + -((1ll<<55) - 1), + -((1ll<<56) - 1) }; int n = sizeof(numbers)/sizeof(qint64); @@ -289,18 +289,18 @@ void tst_QtJson::testNumbers() 0, -1, 1, - (1UL<<54), - (1UL<<55), - (1UL<<56), - -(1UL<<54), - -(1UL<<55), - -(1UL<<56), - (1UL<<54) - 1, - (1UL<<55) - 1, - (1UL<<56) - 1, - -((1UL<<54) - 1), - -((1UL<<55) - 1), - -((1UL<<56) - 1), + double(1ll<<54), + double(1ll<<55), + double(1ll<<56), + double(-(1ll<<54)), + double(-(1ll<<55)), + double(-(1ll<<56)), + double((1ll<<54) - 1), + double((1ll<<55) - 1), + double((1ll<<56) - 1), + double(-((1ll<<54) - 1)), + double(-((1ll<<55) - 1)), + double(-((1ll<<56) - 1)), 1.1, 0.1, -0.1, diff --git a/tests/auto/corelib/tools/qmessageauthenticationcode/tst_qmessageauthenticationcode.cpp b/tests/auto/corelib/tools/qmessageauthenticationcode/tst_qmessageauthenticationcode.cpp index 0e243988e2..1ac3645349 100644 --- a/tests/auto/corelib/tools/qmessageauthenticationcode/tst_qmessageauthenticationcode.cpp +++ b/tests/auto/corelib/tools/qmessageauthenticationcode/tst_qmessageauthenticationcode.cpp @@ -101,7 +101,7 @@ void tst_QMessageAuthenticationCode::result_data() << QByteArray::fromHex("750c783e6ab0b503eaa86e310a5db738"); QTest::newRow("rfc-md5-3") << QCryptographicHash::Md5 << QByteArray::fromHex("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") - << QByteArray(50, 0xdd) + << QByteArray(50, char(0xdd)) << QByteArray::fromHex("56be34521d144c88dbb8c733f0e8b3f6"); } diff --git a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp index 4856f52c55..75aed3bf8b 100644 --- a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp +++ b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp @@ -451,8 +451,8 @@ void tst_QGuiVariant::vector2D() QVariant variant; QVector2D vector = qvariant_cast<QVector2D>(variant); QVERIFY(vector.isNull()); - variant.setValue(QVector2D(0.1, 0.2)); - QCOMPARE(QVector2D(0.1, 0.2), qvariant_cast<QVector2D>(variant)); + variant.setValue(QVector2D(0.1f, 0.2f)); + QCOMPARE(QVector2D(0.1f, 0.2f), qvariant_cast<QVector2D>(variant)); void *pvector = QMetaType::create(QVariant::Vector2D, 0); QVERIFY(pvector); diff --git a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp index 9135c57420..17be5e4c43 100644 --- a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp +++ b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp @@ -61,6 +61,7 @@ class tst_QDnsLookup: public QObject QString domainName(const QString &input); QString domainNameList(const QString &input); + QStringList domainNameListAlternatives(const QString &input); public slots: void initTestCase(); @@ -74,8 +75,8 @@ private slots: void tst_QDnsLookup::initTestCase() { QTest::addColumn<QString>("tld"); - QTest::newRow("normal") << ".test.macieira.org"; - QTest::newRow("idn") << ".alqualond\xc3\xab.test.macieira.org"; + QTest::newRow("normal") << ".test.qt-project.org"; + QTest::newRow("idn") << ".alqualond\xc3\xab.test.qt-project.org"; } QString tst_QDnsLookup::domainName(const QString &input) @@ -105,6 +106,14 @@ QString tst_QDnsLookup::domainNameList(const QString &input) return result; } +QStringList tst_QDnsLookup::domainNameListAlternatives(const QString &input) +{ + QStringList alternatives = input.split('|'); + for (int i = 0; i < alternatives.length(); ++i) + alternatives[i] = domainNameList(alternatives[i]); + return alternatives; +} + void tst_QDnsLookup::lookup_data() { QTest::addColumn<int>("type"); @@ -116,46 +125,57 @@ void tst_QDnsLookup::lookup_data() QTest::addColumn<QString>("ns"); QTest::addColumn<QString>("ptr"); QTest::addColumn<QString>("srv"); - QTest::addColumn<QByteArray>("txt"); - - QTest::newRow("a-empty") << int(QDnsLookup::A) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << ""<< "" << QByteArray(); - QTest::newRow("a-notfound") << int(QDnsLookup::A) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("a-single") << int(QDnsLookup::A) << "a-single" << int(QDnsLookup::NoError) << "" << "192.0.2.1" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("a-multi") << int(QDnsLookup::A) << "a-multi" << int(QDnsLookup::NoError) << "" << "192.0.2.1;192.0.2.2;192.0.2.3" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("aaaa-empty") << int(QDnsLookup::AAAA) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("aaaa-notfound") << int(QDnsLookup::AAAA) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("aaaa-single") << int(QDnsLookup::AAAA) << "aaaa-single" << int(QDnsLookup::NoError) << "" << "2001:db8::1" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("aaaa-multi") << int(QDnsLookup::AAAA) << "aaaa-multi" << int(QDnsLookup::NoError) << "" << "2001:db8::1;2001:db8::2;2001:db8::3" << "" << "" << "" << "" << QByteArray(); - - QTest::newRow("any-empty") << int(QDnsLookup::ANY) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("any-notfound") << int(QDnsLookup::ANY) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("any-a-single") << int(QDnsLookup::ANY) << "a-single" << int(QDnsLookup::NoError) << "" << "192.0.2.1" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("any-a-plus-aaaa") << int(QDnsLookup::ANY) << "a-plus-aaaa" << int(QDnsLookup::NoError) << "" << "198.51.100.1;2001:db8::1:1" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("any-multi") << int(QDnsLookup::ANY) << "multi" << int(QDnsLookup::NoError) << "" << "198.51.100.1;198.51.100.2;198.51.100.3;2001:db8::1:1;2001:db8::1:2" << "" << "" << "" << "" << QByteArray(); - - QTest::newRow("mx-empty") << int(QDnsLookup::MX) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("mx-notfound") << int(QDnsLookup::MX) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("mx-single") << int(QDnsLookup::MX) << "mx-single" << int(QDnsLookup::NoError) << "" << "" << "10 multi" << "" << "" << "" << QByteArray(); - QTest::newRow("mx-single-cname") << int(QDnsLookup::MX) << "mx-single-cname" << int(QDnsLookup::NoError) << "" << "" << "10 cname" << "" << "" << "" << QByteArray(); - QTest::newRow("mx-multi") << int(QDnsLookup::MX) << "mx-multi" << int(QDnsLookup::NoError) << "" << "" << "10 multi;20 a-single" << "" << "" << "" << QByteArray(); - - QTest::newRow("ns-empty") << int(QDnsLookup::NS) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("ns-notfound") << int(QDnsLookup::NS) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("ns-single") << int(QDnsLookup::NS) << "ns-single" << int(QDnsLookup::NoError) << "" << "" << "" << "ns3.macieira.info." << "" << "" << QByteArray(); - QTest::newRow("ns-multi") << int(QDnsLookup::NS) << "ns-multi" << int(QDnsLookup::NoError) << "" << "" << "" << "gondolin.macieira.info.;ns3.macieira.info." << "" << "" << QByteArray(); - - QTest::newRow("ptr-empty") << int(QDnsLookup::PTR) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("ptr-notfound") << int(QDnsLookup::PTR) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("ptr-single") << int(QDnsLookup::PTR) << "ptr-single" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "a-single" << "" << QByteArray(); - - QTest::newRow("srv-empty") << int(QDnsLookup::SRV) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("srv-notfound") << int(QDnsLookup::SRV) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("srv-single") << int(QDnsLookup::SRV) << "_echo._tcp.srv-single" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" << "5 0 7 multi" << QByteArray(); - QTest::newRow("srv-prio") << int(QDnsLookup::SRV) << "_echo._tcp.srv-prio" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" << "1 0 7 multi;2 0 7 a-plus-aaaa" << QByteArray(); - - QTest::newRow("txt-empty") << int(QDnsLookup::TXT) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("txt-notfound") << int(QDnsLookup::TXT) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << QByteArray(); - QTest::newRow("txt-single") << int(QDnsLookup::TXT) << "txt-single" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" << "" << QByteArray("Hello"); + QTest::addColumn<QString>("txt"); + + QTest::newRow("a-empty") << int(QDnsLookup::A) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << ""<< "" << ""; + QTest::newRow("a-notfound") << int(QDnsLookup::A) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("a-single") << int(QDnsLookup::A) << "a-single" << int(QDnsLookup::NoError) << "" << "192.0.2.1" << "" << "" << "" << "" << ""; + QTest::newRow("a-multi") << int(QDnsLookup::A) << "a-multi" << int(QDnsLookup::NoError) << "" << "192.0.2.1;192.0.2.2;192.0.2.3" << "" << "" << "" << "" << ""; + QTest::newRow("aaaa-empty") << int(QDnsLookup::AAAA) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("aaaa-notfound") << int(QDnsLookup::AAAA) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("aaaa-single") << int(QDnsLookup::AAAA) << "aaaa-single" << int(QDnsLookup::NoError) << "" << "2001:db8::1" << "" << "" << "" << "" << ""; + QTest::newRow("aaaa-multi") << int(QDnsLookup::AAAA) << "aaaa-multi" << int(QDnsLookup::NoError) << "" << "2001:db8::1;2001:db8::2;2001:db8::3" << "" << "" << "" << "" << ""; + + QTest::newRow("any-empty") << int(QDnsLookup::ANY) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("any-notfound") << int(QDnsLookup::ANY) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("any-a-single") << int(QDnsLookup::ANY) << "a-single" << int(QDnsLookup::NoError) << "" << "192.0.2.1" << "" << "" << "" << "" << ""; + QTest::newRow("any-a-plus-aaaa") << int(QDnsLookup::ANY) << "a-plus-aaaa" << int(QDnsLookup::NoError) << "" << "198.51.100.1;2001:db8::1:1" << "" << "" << "" << "" << ""; + QTest::newRow("any-multi") << int(QDnsLookup::ANY) << "multi" << int(QDnsLookup::NoError) << "" << "198.51.100.1;198.51.100.2;198.51.100.3;2001:db8::1:1;2001:db8::1:2" << "" << "" << "" << "" << ""; + + QTest::newRow("mx-empty") << int(QDnsLookup::MX) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("mx-notfound") << int(QDnsLookup::MX) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("mx-single") << int(QDnsLookup::MX) << "mx-single" << int(QDnsLookup::NoError) << "" << "" << "10 multi" << "" << "" << "" << ""; + QTest::newRow("mx-single-cname") << int(QDnsLookup::MX) << "mx-single-cname" << int(QDnsLookup::NoError) << "" << "" << "10 cname" << "" << "" << "" << ""; + QTest::newRow("mx-multi") << int(QDnsLookup::MX) << "mx-multi" << int(QDnsLookup::NoError) << "" << "" << "10 multi;20 a-single" << "" << "" << "" << ""; + QTest::newRow("mx-multi-sameprio") << int(QDnsLookup::MX) << "mx-multi-sameprio" << int(QDnsLookup::NoError) << "" << "" + << "10 multi;10 a-single|" + "10 a-single;10 multi" << "" << "" << "" << ""; + + QTest::newRow("ns-empty") << int(QDnsLookup::NS) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("ns-notfound") << int(QDnsLookup::NS) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("ns-single") << int(QDnsLookup::NS) << "ns-single" << int(QDnsLookup::NoError) << "" << "" << "" << "ns-foo.linpro.net." << "" << "" << ""; + QTest::newRow("ns-multi") << int(QDnsLookup::NS) << "ns-multi" << int(QDnsLookup::NoError) << "" << "" << "" << "ns-bar.linpro.net.;ns-foo.linpro.net." << "" << "" << ""; + + QTest::newRow("ptr-empty") << int(QDnsLookup::PTR) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("ptr-notfound") << int(QDnsLookup::PTR) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("ptr-single") << int(QDnsLookup::PTR) << "ptr-single" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "a-single" << "" << ""; + + QTest::newRow("srv-empty") << int(QDnsLookup::SRV) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("srv-notfound") << int(QDnsLookup::SRV) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("srv-single") << int(QDnsLookup::SRV) << "_echo._tcp.srv-single" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" << "5 0 7 multi" << ""; + QTest::newRow("srv-prio") << int(QDnsLookup::SRV) << "_echo._tcp.srv-prio" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" << "1 0 7 multi;2 0 7 a-plus-aaaa" << ""; + QTest::newRow("srv-weighted") << int(QDnsLookup::SRV) << "_echo._tcp.srv-weighted" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" + << "5 75 7 multi;5 25 7 a-plus-aaaa|" + "5 25 7 a-plus-aaaa;5 75 7 multi" << ""; + QTest::newRow("srv-multi") << int(QDnsLookup::SRV) << "_echo._tcp.srv-multi" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" + << "1 50 7 multi;2 50 7 a-single;2 50 7 aaaa-single;3 50 7 a-multi|" + "1 50 7 multi;2 50 7 aaaa-single;2 50 7 a-single;3 50 7 a-multi" << ""; + + QTest::newRow("txt-empty") << int(QDnsLookup::TXT) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("txt-notfound") << int(QDnsLookup::TXT) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << ""; + QTest::newRow("txt-single") << int(QDnsLookup::TXT) << "txt-single" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" << "" << "Hello"; + QTest::newRow("txt-multi-onerr") << int(QDnsLookup::TXT) << "txt-multi-onerr" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" << "" << "Hello World"; + QTest::newRow("txt-multi-multirr") << int(QDnsLookup::TXT) << "txt-multi-multirr" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" << "" << "Hello;World"; } void tst_QDnsLookup::lookup() @@ -169,15 +189,18 @@ void tst_QDnsLookup::lookup() QFETCH(QString, ns); QFETCH(QString, ptr); QFETCH(QString, srv); - QFETCH(QByteArray, txt); + QFETCH(QString, txt); // transform the inputs domain = domainName(domain); cname = domainName(cname); - mx = domainNameList(mx); ns = domainNameList(ns); ptr = domainNameList(ptr); - srv = domainNameList(srv); + + // SRV and MX have reply entries that can change order + // and we can't sort + QStringList mx_alternatives = domainNameListAlternatives(mx); + QStringList srv_alternatives = domainNameListAlternatives(srv); QDnsLookup lookup; lookup.setType(static_cast<QDnsLookup::Type>(type)); @@ -218,7 +241,8 @@ void tst_QDnsLookup::lookup() QCOMPARE(record.name(), domain); mailExchanges << QString("%1 %2").arg(QString::number(record.preference()), record.exchange()); } - QCOMPARE(mailExchanges.join(';'), mx); + QVERIFY2(mx_alternatives.contains(mailExchanges.join(';')), + qPrintable("Actual: " + mailExchanges.join(';') + "\nExpected one of:\n" + mx_alternatives.join('\n'))); // name servers QStringList nameServers; @@ -250,18 +274,23 @@ void tst_QDnsLookup::lookup() QString::number(record.port()), record.target()); } - QCOMPARE(services.join(';'), srv); + QVERIFY2(srv_alternatives.contains(services.join(';')), + qPrintable("Actual: " + services.join(';') + "\nExpected one of:\n" + srv_alternatives.join('\n'))); // text - if (!txt.isEmpty()) { - QVERIFY(!lookup.textRecords().isEmpty()); - const QDnsTextRecord firstRecord = lookup.textRecords().first(); - QCOMPARE(firstRecord.name(), domain); - QCOMPARE(firstRecord.values().size(), 1); - QCOMPARE(firstRecord.values().first(), txt); - } else { - QVERIFY(lookup.textRecords().isEmpty()); + QStringList texts; + foreach (const QDnsTextRecord &record, lookup.textRecords()) { + QCOMPARE(record.name(), domain); + QString text; + foreach (const QByteArray &ba, record.values()) { + if (!text.isEmpty()) + text += ' '; + text += QString::fromLatin1(ba); + } + texts << text; } + texts.sort(); + QCOMPARE(texts.join(';'), txt); } void tst_QDnsLookup::lookupReuse() diff --git a/tests/auto/network/kernel/qdnslookup_appless/tst_qdnslookup_appless.cpp b/tests/auto/network/kernel/qdnslookup_appless/tst_qdnslookup_appless.cpp index 84b63c7148..91b5d9292d 100644 --- a/tests/auto/network/kernel/qdnslookup_appless/tst_qdnslookup_appless.cpp +++ b/tests/auto/network/kernel/qdnslookup_appless/tst_qdnslookup_appless.cpp @@ -56,7 +56,7 @@ private slots: void tst_QDnsLookup_Appless::noApplication() { QTest::ignoreMessage(QtWarningMsg, "QDnsLookup requires a QCoreApplication"); - QDnsLookup dns(QDnsLookup::A, "a-single.test.macieira.org"); + QDnsLookup dns(QDnsLookup::A, "a-single.test.qt-project.org"); dns.lookup(); } @@ -66,7 +66,7 @@ void tst_QDnsLookup_Appless::recreateApplication() char **argv = 0; for (int i = 0; i < 10; ++i) { QCoreApplication app(argc, argv); - QDnsLookup dns(QDnsLookup::A, "a-single.test.macieira.org"); + QDnsLookup dns(QDnsLookup::A, "a-single.test.qt-project.org"); dns.lookup(); if (!dns.isFinished()) { QObject::connect(&dns, SIGNAL(finished()), diff --git a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp index ee6ea546f3..e81c7f71db 100644 --- a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp @@ -93,7 +93,7 @@ #include "../../../network-settings.h" -#define TEST_DOMAIN ".test.macieira.org" +#define TEST_DOMAIN ".test.qt-project.org" class tst_QHostInfo : public QObject diff --git a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp index e06285dc67..dd24f6757e 100644 --- a/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp +++ b/tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp @@ -389,6 +389,11 @@ void tst_QNetworkProxyFactory::genericSystemProxy() QCOMPARE(systemProxy.first().port(), static_cast<quint16>(port)); qunsetenv(envVar); #else + Q_UNUSED(envVar) + Q_UNUSED(url) + Q_UNUSED(proxyType) + Q_UNUSED(hostName) + Q_UNUSED(port) QSKIP("Generic system proxy not available on this platform."); #endif } diff --git a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp index b6b534b1da..c74edab9a2 100644 --- a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp +++ b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp @@ -334,12 +334,13 @@ static inline float qrandom() { return (rand() % 100) / 100.f; } void renderAScene(int w, int h) { #ifdef QT_OPENGL_ES_2 + Q_UNUSED(w) + Q_UNUSED(h) QGLShaderProgram program; program.addShaderFromSourceCode(QGLShader::Vertex, "attribute highp vec2 pos; void main() { gl_Position = vec4(pos.xy, 1.0, 1.0); }"); program.addShaderFromSourceCode(QGLShader::Fragment, "uniform lowp vec4 color; void main() { gl_FragColor = color; }"); program.bindAttributeLocation("pos", 0); program.bind(); - int colorId = program.uniformLocation("color"); glEnableVertexAttribArray(0); diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro index 1f7582243e..1d57206a73 100644 --- a/tests/auto/other/other.pro +++ b/tests/auto/other/other.pro @@ -41,6 +41,7 @@ SUBDIRS=\ windowsmobile \ qaccessibility \ qaccessibilitylinux \ + qaccessibilitymac \ !qtHaveModule(network): SUBDIRS -= \ baselineexample \ @@ -63,7 +64,8 @@ wince*|!contains(QT_CONFIG, accessibility): SUBDIRS -= qaccessibility !mac: SUBDIRS -= \ macgui \ macnativeevents \ - macplist + macplist \ + qaccessibilitymac !embedded|wince*: SUBDIRS -= \ qdirectpainter diff --git a/tests/auto/other/qaccessibilitymac/qaccessibilitymac.pro b/tests/auto/other/qaccessibilitymac/qaccessibilitymac.pro new file mode 100644 index 0000000000..5d81567f45 --- /dev/null +++ b/tests/auto/other/qaccessibilitymac/qaccessibilitymac.pro @@ -0,0 +1,16 @@ +CONFIG += testcase +TARGET = tst_qaccessibilitymac +# LIBS += -framework Carbon +QT += widgets testlib + +HEADERS += tst_qaccessibilitymac_helpers.h +SOURCES += tst_qaccessibilitymac.cpp + +mac { + LIBS += -framework Security -framework AppKit -framework ApplicationServices + OBJECTIVE_SOURCES += tst_qaccessibilitymac_helpers.mm +} + + +requires(mac) +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp new file mode 100644 index 0000000000..25dd0d39dd --- /dev/null +++ b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QApplication> +#include <QtWidgets> +#include <QtTest/QtTest> +#include <QtCore/qcoreapplication.h> + +#include "tst_qaccessibilitymac_helpers.h" + +QT_USE_NAMESPACE + + +class AccessibleTestWindow : public QWidget +{ + Q_OBJECT +public: + AccessibleTestWindow() + { + new QHBoxLayout(this); + } + + void addWidget(QWidget* widget) + { + layout()->addWidget(widget); + widget->show(); + QTest::qWaitForWindowExposed(widget); + } + + void clearChildren() + { + qDeleteAll(children()); + new QHBoxLayout(this); + } +}; + +class tst_QAccessibilityMac : public QObject +{ +Q_OBJECT +private slots: + void init(); + void cleanup(); + + void lineEditTest(); + void hierarchyTest(); +private: + AccessibleTestWindow *m_window; +}; + + +void tst_QAccessibilityMac::init() +{ + m_window = new AccessibleTestWindow(); + m_window->setWindowTitle("Test window"); + m_window->show(); + m_window->resize(400, 400); + + QTest::qWaitForWindowExposed(m_window); +} + +void tst_QAccessibilityMac::cleanup() +{ + delete m_window; +} + + +void tst_QAccessibilityMac::lineEditTest() +{ + if (!macNativeAccessibilityEnabled()) + return; + + QLineEdit *lineEdit = new QLineEdit(m_window); + lineEdit->setText("a11y test QLineEdit"); + m_window->addWidget(lineEdit); + QVERIFY(QTest::qWaitForWindowExposed(m_window)); + QCoreApplication::processEvents(); + QVERIFY(testLineEdit()); +} + +void tst_QAccessibilityMac::hierarchyTest() +{ + if (!macNativeAccessibilityEnabled()) + return; + + QWidget *w = new QWidget(m_window); + m_window->addWidget(w); + QPushButton *b = new QPushButton(w); + w->setLayout(new QVBoxLayout()); + w->layout()->addWidget(b); + b->setText("I am a button"); + + QVERIFY(QTest::qWaitForWindowExposed(m_window)); + QCoreApplication::processEvents(); + QVERIFY(testHierarchy()); +} + +QTEST_MAIN(tst_QAccessibilityMac) +#include "tst_qaccessibilitymac.moc" diff --git a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.h b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.h new file mode 100644 index 0000000000..ec5beab125 --- /dev/null +++ b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.h @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <QtCore/QString> +#include <QtCore/QPair> +#include <QtWidgets/QWidget> + + +#pragma once // Yeah, it's deprecated in general, but it's standard practice for Mac OS X. + +bool macNativeAccessibilityEnabled(); +bool trusted(); +bool testLineEdit(); +bool testHierarchy(); diff --git a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm new file mode 100644 index 0000000000..8620b7dd2f --- /dev/null +++ b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm @@ -0,0 +1,213 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Digia gives you certain additional +** rights. These rights are described in the Digia 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. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// some versions of CALayer.h use 'slots' as an identifier +#define QT_NO_KEYWORDS + +#include "tst_qaccessibilitymac_helpers.h" +#include <QApplication> +#include <QDebug> +#include <unistd.h> + +#import <Cocoa/Cocoa.h> +#import <ApplicationServices/ApplicationServices.h> + +bool macNativeAccessibilityEnabled() +{ + bool enabled = AXAPIEnabled(); + if (!enabled) + qWarning() << "Accessibility is disabled (check System Preferences) skipping test."; + return enabled; +} + +bool trusted() +{ + return AXIsProcessTrusted(); +} + + +#define EXPECT(cond) \ + if (!(cond)) { \ + qWarning("Failure in %s, line: %d", __FILE__ , __LINE__); \ + return false; \ + } \ + + +@interface TestAXObject : NSObject +{ + AXUIElementRef reference; +} + @property (readonly) NSString *role; + @property (readonly) NSString *description; + @property (readonly) NSString *value; + @property (readonly) CGRect rect; +@end + +@implementation TestAXObject +- (id) initWithAXUIElementRef: (AXUIElementRef) ref { + if ( self = [super init] ) { + reference = ref; + AXUIElementCopyAttributeValue(ref, kAXRoleAttribute, (CFTypeRef*)&_role); + AXUIElementCopyAttributeValue(ref, kAXDescriptionAttribute, (CFTypeRef*)&_description); + AXUIElementCopyAttributeValue(ref, kAXValueAttribute, (CFTypeRef*)&_value); + AXValueRef sizeValue; + AXUIElementCopyAttributeValue(ref, kAXSizeAttribute, (CFTypeRef*)&sizeValue); + AXValueGetValue(sizeValue, kAXValueCGSizeType, &_rect.size); + AXValueRef positionValue; + AXUIElementCopyAttributeValue(ref, kAXPositionAttribute, (CFTypeRef*)&positionValue); + AXValueGetValue(positionValue, kAXValueCGPointType, &_rect.origin); + } + return self; +} + +- (AXUIElementRef) ref { return reference; } +- (void) print { + NSLog(@"Accessible Object role: '%@', description: '%@', value: '%@', rect: '%@'", self.role, self.description, self.value, NSStringFromRect(self.rect)); + NSLog(@" Children: %ld", [self.childList count]); +} + +- (NSArray*) windowList +{ + NSArray *list; + AXUIElementCopyAttributeValues( + reference, + kAXWindowsAttribute, + 0, 100, /*min, max*/ + (CFArrayRef *) &list); + return list; +} + +- (NSArray*) childList +{ + NSArray *list; + AXUIElementCopyAttributeValues( + reference, + kAXChildrenAttribute, + 0, 100, /*min, max*/ + (CFArrayRef *) &list); + return list; +} + +- (AXUIElementRef) findDirectChildByRole: (CFStringRef) role +{ + AXUIElementRef result = nil; + NSArray *childList = [self childList]; + for (id child in childList) { + CFStringRef typeString; + AXUIElementCopyAttributeValue((AXUIElementRef)child, kAXRoleAttribute, (CFTypeRef*)&typeString); + if (CFStringCompare(typeString, role, 0) == 0) { + result = (AXUIElementRef) child; + break; + } + } + return result; +} + +- (AXUIElementRef) parent +{ + AXUIElementRef p = nil; + AXUIElementCopyAttributeValue(reference, kAXParentAttribute, (CFTypeRef*)&p); + return p; +} + +@end + + +bool testLineEdit() +{ +// not sure if this is needed. on my machine the calls succeed. +// NSString *path = @"/Users/frederik/qt5/qtbase/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.app/Contents/MacOS/tst_qaccessibilitymac"; +// NSString *path = @"/Users/frederik/qt5/qtbase/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.app"; +// AXError e = AXMakeProcessTrusted((CFStringRef) path); +// NSLog(@"error: %i", e); + + pid_t pid = getpid(); + AXUIElementRef app = AXUIElementCreateApplication(pid); + EXPECT(app != nil); + TestAXObject *appObject = [[TestAXObject alloc] initWithAXUIElementRef: app]; + + NSArray *windowList = [appObject windowList]; + // one window + EXPECT([windowList count] == 1); + AXUIElementRef windowRef = (AXUIElementRef) [windowList objectAtIndex: 0]; + EXPECT(windowRef != nil); + TestAXObject *window = [[TestAXObject alloc] initWithAXUIElementRef: windowRef]; + + EXPECT([window rect].size.width == 400); + // height of window includes title bar + EXPECT([window rect].size.height >= 400); + + // children of window: + AXUIElementRef lineEdit = [window findDirectChildByRole: kAXTextFieldRole]; + EXPECT(lineEdit != nil); + + TestAXObject *le = [[TestAXObject alloc] initWithAXUIElementRef: lineEdit]; + EXPECT([[le value] isEqualToString:@"a11y test QLineEdit"]); + return true; +} + +bool testHierarchy() +{ + pid_t pid = getpid(); + AXUIElementRef app = AXUIElementCreateApplication(pid); + EXPECT(app != nil); + TestAXObject *appObject = [[TestAXObject alloc] initWithAXUIElementRef: app]; + + NSArray *windowList = [appObject windowList]; + // one window + EXPECT([windowList count] == 1); + AXUIElementRef windowRef = (AXUIElementRef) [windowList objectAtIndex: 0]; + EXPECT(windowRef != nil); + TestAXObject *window = [[TestAXObject alloc] initWithAXUIElementRef: windowRef]; + + // Because the plain widget is filtered out of the hierarchy, we expect the button + // to be a direct child of the window + AXUIElementRef buttonRef = [window findDirectChildByRole: kAXButtonRole]; + EXPECT(buttonRef != nil); + + TestAXObject *buttonObject = [[TestAXObject alloc] initWithAXUIElementRef: buttonRef]; + TestAXObject *parentObject = [[TestAXObject alloc] initWithAXUIElementRef: [buttonObject parent]]; + + // check that the parent is a window + EXPECT([[parentObject role] isEqualToString: (NSString *)kAXWindowRole]); + + return true; +} diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index e36eaa5af2..0fe7c8ab75 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -1033,6 +1033,14 @@ void tst_QFileSystemModel::roleNames() QVERIFY(values.contains(roleName)); } +static inline QByteArray permissionRowName(bool readOnly, int permission) +{ + QByteArray result = readOnly ? QByteArrayLiteral("ro") : QByteArrayLiteral("rw"); + result += QByteArrayLiteral("-0"); + result += QByteArray::number(permission, 16); + return result; +} + void tst_QFileSystemModel::permissions_data() { QTest::addColumn<int>("permissions"); @@ -1043,11 +1051,10 @@ void tst_QFileSystemModel::permissions_data() QFile::ReadOwner, QFile::WriteOwner|QFile::ReadOwner, }; -#define ROW_NAME(i) qPrintable(QString().sprintf("%s-0%04x", readOnly ? "ro" : "rw", permissions[i])) - for (int readOnly = false ; readOnly <= true; ++readOnly) - for (size_t i = 0; i < sizeof permissions / sizeof *permissions; ++i) - QTest::newRow(ROW_NAME(i)) << permissions[i] << bool(readOnly); -#undef ROW_NAME + for (size_t i = 0; i < sizeof permissions / sizeof *permissions; ++i) { + QTest::newRow(permissionRowName(false, permissions[i]).constData()) << permissions[i] << false; + QTest::newRow(permissionRowName(true, permissions[i]).constData()) << permissions[i] << true; + } } void tst_QFileSystemModel::permissions() // checks QTBUG-20503 diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget_mac_helpers.h b/tests/auto/widgets/kernel/qwidget/tst_qwidget_mac_helpers.h index fe9e71e650..920fa5e023 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget_mac_helpers.h +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget_mac_helpers.h @@ -42,7 +42,7 @@ #include <QtCore/QPair> #include <QtWidgets/QWidget> -#pragma once // Yeah, it's deprecated in general, but it's standard practive for Mac OS X. +#pragma once // Yeah, it's deprecated in general, but it's standard practice for Mac OS X. QString nativeWindowTitle(QWidget *widget, Qt::WindowState state); bool nativeWindowModified(QWidget *widget); diff --git a/tests/auto/widgets/styles/qstyle/qstyle.pro b/tests/auto/widgets/styles/qstyle/qstyle.pro index 2b9268f35d..4d18971cc6 100644 --- a/tests/auto/widgets/styles/qstyle/qstyle.pro +++ b/tests/auto/widgets/styles/qstyle/qstyle.pro @@ -6,10 +6,7 @@ QT += widgets testlib SOURCES += tst_qstyle.cpp wince* { - DEFINES += SRCDIR=\\\".\\\" addPixmap.files = task_25863.png addPixmap.path = . DEPLOYMENT += addPixmap -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" } diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp index fc94f95f8e..94d2d22d96 100644 --- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp +++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp @@ -250,9 +250,12 @@ void tst_QStyle::testProxyStyle() void tst_QStyle::drawItemPixmap() { testWidget->resize(300, 300); - testWidget->show(); + testWidget->showNormal(); - QPixmap p(QString(SRCDIR) + "/task_25863.png", "PNG"); + const QString imageFileName = QFINDTESTDATA("task_25863.png"); + QVERIFY(!imageFileName.isEmpty()); + + QPixmap p(imageFileName, "PNG"); const QPixmap actualPix = testWidget->grab(); QCOMPARE(actualPix, p); diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 36b83eefda..0bfd4baa0c 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -2044,10 +2044,11 @@ void tst_QComboBox::itemListPosition() //we test QFontComboBox because it has the specific behaviour to set a fixed size //to the list view QWidget topLevel; - topLevel.resize(200, 200); - topLevel.move(100, 100); + QHBoxLayout *layout = new QHBoxLayout(&topLevel); + QFontComboBox combo(&topLevel); + layout->addWidget(&combo); //the code to get the available screen space is copied from QComboBox code const int scrNumber = QApplication::desktop()->screenNumber(&combo); @@ -2058,11 +2059,12 @@ void tst_QComboBox::itemListPosition() QApplication::desktop()->screenGeometry(scrNumber) : QApplication::desktop()->availableGeometry(scrNumber); - combo.move(screen.width()-combo.sizeHint().width(), 0); //puts the combo to the top-right corner + topLevel.move(screen.width() - topLevel.sizeHint().width() - 10, 0); //puts the combo to the top-right corner topLevel.show(); + //wait because the window manager can move the window if there is a right panel - QTRY_VERIFY(combo.isVisible()); + QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); combo.showPopup(); QTRY_VERIFY(combo.view()); QTRY_VERIFY(combo.view()->isVisible()); diff --git a/tests/auto/xml/dom/qdom/tst_qdom.cpp b/tests/auto/xml/dom/qdom/tst_qdom.cpp index 6b4bc3cd35..26f49a3fed 100644 --- a/tests/auto/xml/dom/qdom/tst_qdom.cpp +++ b/tests/auto/xml/dom/qdom/tst_qdom.cpp @@ -1705,8 +1705,8 @@ void tst_QDom::germanUmlautToByteArray() const QByteArray baseline("<a"); /* http://www.fileformat.info/info/unicode/char/00FC/index.htm */ - baseline += 0xC3; - baseline += 0xBC; + baseline += char(0xC3); + baseline += char(0xBC); baseline += "b/>\n"; QCOMPARE(data, baseline); |