diff options
125 files changed, 1222 insertions, 646 deletions
diff --git a/config.tests/x11/glxfbconfig/glxfbconfig.cpp b/config.tests/qpa/glx/glx.cpp index 77bedb41c8..03af3f6131 100644 --- a/config.tests/x11/glxfbconfig/glxfbconfig.cpp +++ b/config.tests/qpa/glx/glx.cpp @@ -44,6 +44,7 @@ int main(int, char **) { + //We require glxfbconfig, ie. glx 1.3 GLXFBConfig config; config = 0; diff --git a/config.tests/x11/glxfbconfig/glxfbconfig.pro b/config.tests/qpa/glx/glx.pro index 65f855a5f2..da51a6d231 100644 --- a/config.tests/x11/glxfbconfig/glxfbconfig.pro +++ b/config.tests/qpa/glx/glx.pro @@ -1,4 +1,4 @@ -SOURCES = glxfbconfig.cpp +SOURCES = glx.cpp CONFIG += x11 INCLUDEPATH += $$QMAKE_INCDIR_OPENGL @@ -611,6 +611,7 @@ CFG_OPENVG_LC_INCLUDES=no CFG_OPENVG_SHIVA=auto CFG_OPENVG_ON_OPENGL=auto CFG_EGL=auto +CFG_GLX=auto CFG_SSE=auto CFG_FONTCONFIG=auto CFG_FREETYPE=auto @@ -647,6 +648,7 @@ CFG_XINPUT=runtime CFG_XKB=auto CFG_XKBCOMMON=auto CFG_XCB=auto +CFG_XCB_XLIB=auto CFG_XCB_GLX=no CFG_EGLFS=auto CFG_DIRECTFB=auto @@ -776,6 +778,14 @@ QT_LIBS_GLIB= # default qpa platform QT_QPA_DEFAULT_PLATFORM= +# Android vars +CFG_DEFAULT_ANDROID_NDK_ROOT=$ANDROID_NDK_ROOT +CFG_DEFAULT_ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT +CFG_DEFAULT_ANDROID_PLATFORM=android-9 +CFG_DEFAULT_ANDROID_TARGET_ARCH=armeabi-v7a +CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION=4.8 +CFG_DEFAULT_ANDROID_NDK_HOST=$ANDROID_NDK_HOST + #------------------------------------------------------------------------------- # check SQL drivers available in this package #------------------------------------------------------------------------------- @@ -786,15 +796,6 @@ CFG_SQL_oci=no CFG_SQL_db2=no CFG_SQL_AVAILABLE= - -# Android vars -CFG_DEFAULT_ANDROID_NDK_ROOT=$ANDROID_NDK_ROOT -CFG_DEFAULT_ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT -CFG_DEFAULT_ANDROID_PLATFORM=android-9 -CFG_DEFAULT_ANDROID_TARGET_ARCH=armeabi-v7a -CFG_DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION=4.8 -CFG_DEFAULT_ANDROID_NDK_HOST=$ANDROID_NDK_HOST - if [ -d "$relpath/src/plugins/sqldrivers" ]; then for a in "$relpath/src/plugins/sqldrivers/"*; do if [ -d "$a" ]; then @@ -1480,6 +1481,13 @@ while [ "$#" -gt 0 ]; do UNKNOWN_OPT=yes fi ;; + glx) + if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then + CFG_GLX="$VAL" + else + UNKNOWN_OPT=yes + fi + ;; pch) if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then CFG_PRECOMPILE="$VAL" @@ -1691,6 +1699,13 @@ while [ "$#" -gt 0 ]; do UNKNOWN_OPT=yes fi ;; + xcb-xlib) + if [ "$VAL" = "yes" ] || [ "$VAL" = "no" ]; then + CFG_XCB_XLIB="$VAL" + else + UNKNOWN_OPT=yes + fi + ;; wayland) CFG_OBSOLETE_WAYLAND=yes ;; @@ -2336,6 +2351,9 @@ Third Party Libraries: -no-xinput2 ........ Do not compile XInput2 support. * -xinput2 ........... Compile XInput2 support. + -no-xcb-xlib........ Do not compile Xcb-Xlib support. + * -xcb-xlib........... Compile Xcb-Xlib support. + -no-glib ........... Do not compile Glib support. + -glib .............. Compile Glib support. @@ -2419,7 +2437,7 @@ Additional options: * -xcb ............... Compile Xcb support. -no-eglfs .......... Do not compile EGLFS (EGL Full Screen/Single Surface) support. - * -eglfs ............. Compile EGLFS support (Requires OpenGL ES 2 support). + * -eglfs ............. Compile EGLFS support. -no-directfb ....... Do not compile DirectFB support. * -directfb .......... Compile DirectFB support. @@ -2428,7 +2446,7 @@ Additional options: * -linuxfb ........... Compile Linux Framebuffer support. -no-kms ............ Do not compile KMS support. - * -kms ............... Compile KMS support (Requires EGL and OpenGL ES 2 support). + * -kms ............... Compile KMS support (Requires EGL). -qpa <name> ......... Sets the default QPA platform (e.g xcb, cocoa, windows). @@ -2679,8 +2697,10 @@ fi [ -z "$XPLATFORM" ] && XPLATFORM="$PLATFORM" -case `basename "$XPLATFORM"` in win32-g++*) XPLATFORM_MINGW=yes;; esac case "$XPLATFORM" in + *win32-g++*) + XPLATFORM_MINGW=yes + ;; *-maemo*) XPLATFORM_MAEMO=yes ;; @@ -4423,11 +4443,6 @@ if [ "$CFG_EGLFS" = "yes" ]; then echo "The EGLFS plugin requires EGL support and cannot be built" exit 101 fi - if [ "$CFG_OPENGL" != "es2" ]; then - echo "The EGLFS plugin requires OpenGL ES 2 support and cannot be built" - exit 101 - fi - CFG_OPENGL="es2" CFG_EGL=yes fi @@ -4436,10 +4451,6 @@ if [ "$CFG_KMS" = "yes" ]; then echo "The KMS plugin requires EGL support and cannot be built" exit 101 fi - if [ "$CFG_OPENGL" != "es2" ]; then - echo "The KMS plugin requires OpenGL ES 2 support and cannot be built" - exit 101 - fi fi # auto-detect SQL-modules support @@ -4899,19 +4910,6 @@ if [ "$XPLATFORM_MINGW" = "yes" ]; then fi CFG_OPENGL=no fi - case "$PLATFORM" in - hpux*) - # HP-UX have buggy glx headers; check if we really need to define the GLXFBConfig struct. - if [ "$CFG_OPENGL" = "desktop" ]; then - compileTest x11/glxfbconfig "OpenGL" - if [ $? != "0" ]; then - QMakeVar add DEFINES QT_DEFINE_GLXFBCONFIG_STRUCT - fi - fi - ;; - *) - ;; - esac elif [ "$CFG_OPENGL" = "es2" ]; then #OpenGL ES 2.x compileTest unix/opengles2 "OpenGL ES 2.x" @@ -4932,17 +4930,6 @@ if [ "$XPLATFORM_MINGW" = "yes" ]; then echo " ${XQMAKESPEC}." exit 1 fi - case "$PLATFORM" in - hpux*) - # HP-UX have buggy glx headers; check if we really need to define the GLXFBConfig struct. - compileTest x11/glxfbconfig "OpenGL" - if [ $? != "0" ]; then - QMakeVar add DEFINES QT_DEFINE_GLXFBCONFIG_STRUCT - fi - ;; - *) - ;; - esac fi fi # X11/MINGW OpenGL @@ -5136,8 +5123,10 @@ if [ "$CFG_XCB" != "no" ]; then exit 1 fi - if compileTest qpa/xcb-xlib "xcb-xlib" $QMAKE_CFLAGS_XCB $QMAKE_LIBS_XCB; then - QT_CONFIG="$QT_CONFIG xcb-xlib" + if [ "$CFG_XCB_XLIB" != "no" ]; then + if compileTest qpa/xcb-xlib "xcb-xlib" $QMAKE_CFLAGS_XCB $QMAKE_LIBS_XCB; then + QT_CONFIG="$QT_CONFIG xcb-xlib" + fi fi if [ "$CFG_SM" != "no" ] && [ -n "$PKG_CONFIG" ]; then @@ -5275,18 +5264,13 @@ elif [ "$CFG_XKBCOMMON" = "no" ]; then fi # EGL Support -if [ "$CFG_OPENGL" != "es2" ]; then - if [ "$CFG_EGL" = "yes" ] && [ "$CFG_OPENGL" = "desktop" ]; then - echo "EGL support was requested but Qt is being configured for desktop OpenGL." - echo "Either disable EGL support or enable OpenGL ES support." - exit 101 - elif [ "$CFG_EGL" = "yes" ] && [ "$CFG_OPENGL" = "no" ]; then - echo "EGL support was requested but OpenGL ES support is disabled." - echo "Either disable EGL support or enable OpenGL ES support." +if [ "$CFG_EGL" != "no" ]; then + if [ "$CFG_EGL" = "yes" ] && [ "$CFG_OPENGL" = "no" ]; then + echo "EGL support was requested but OpenGL support is disabled." + echo "Either disable EGL support or enable OpenGL support." exit 101 fi - CFG_EGL=no -elif [ "$CFG_EGL" != "no" ]; then + if [ -n "$PKG_CONFIG" ] && $PKG_CONFIG --exists egl 2>/dev/null; then QMAKE_INCDIR_EGL=`$PKG_CONFIG --cflags-only-I egl 2>/dev/null | sed -e 's,^-I,,g' -e 's, -I, ,g'` QMAKE_LIBS_EGL=`$PKG_CONFIG --libs egl 2>/dev/null` @@ -5307,8 +5291,26 @@ elif [ "$CFG_EGL" != "no" ]; then fi fi +# GLX Support +if [ "$CFG_GLX" != "no" ]; then + if [ "$CFG_GLX" = "yes" ] && [ "$CFG_OPENGL" = "no" ]; then + echo "GLX support was requested but OpenGL support is disabled." + echo "Either disable GLX support or enable OpenGL support." + exit 101 + fi + if compileTest qpa/glx "GLX"; then + CFG_GLX=yes + elif [ "$CFG_GLX" = "yes" ]; then + echo " The GLX functionality test failed; GLX is required by the xcb plugin to manage contexts & surfaces." + exit 1 + else + CFG_GLX=no + fi +fi + + if [ "$CFG_EGLFS" != "no" ]; then - if [ "$CFG_OPENGL" = "es2" ] && [ "$XPLATFORM_QNX" = "no" ]; then + if [ "$XPLATFORM_QNX" = "no" ]; then CFG_EGLFS="$CFG_EGL" else CFG_EGLFS="no" @@ -5316,7 +5318,7 @@ if [ "$CFG_EGLFS" != "no" ]; then fi if [ "$CFG_KMS" = "yes" ]; then - if [ "$CFG_OPENGL" = "es2" ] && [ "$CFG_EGL" = "yes" ]; then + if [ "$CFG_EGL" = "yes" ]; then CFG_KMS="yes" else CFG_KMS="no" @@ -5668,6 +5670,13 @@ else QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_EGL" fi +# enable glx +if [ "$CFG_GLX" = "yes" ]; then + QT_CONFIG="$QT_CONFIG glx" +else + QCONFIG_FLAGS="$QCONFIG_FLAGS QT_NO_GLX" +fi + # enable eglfs if [ "$CFG_EGLFS" = "yes" ]; then QT_CONFIG="$QT_CONFIG eglfs" @@ -5700,11 +5709,7 @@ else fi if [ "$CFG_OPENGL" = "es2" ]; then - QCONFIG_FLAGS="$QCONFIG_FLAGS QT_OPENGL_ES" -fi - -if [ "$CFG_OPENGL" = "es2" ]; then - QCONFIG_FLAGS="$QCONFIG_FLAGS QT_OPENGL_ES_2" + QCONFIG_FLAGS="$QCONFIG_FLAGS QT_OPENGL_ES QT_OPENGL_ES_2" QT_CONFIG="$QT_CONFIG opengles2" fi @@ -6703,6 +6708,8 @@ else report_support " pkg-config ............. no" fi report_support " PulseAudio ............." "$CFG_PULSEAUDIO" +report_support " EGL ...................." "$CFG_EGL" +report_support " GLX ...................." "$CFG_GLX" report_support " QPA backends:" report_support " DirectFB ............." "$CFG_DIRECTFB" report_support " EGLFS ................" "$CFG_EGLFS" @@ -6711,6 +6718,7 @@ report_support " LinuxFB .............." "$CFG_LINUXFB" report_support " XCB .................." "$CFG_XCB" system "system library" qt "bundled copy" if [ "$CFG_XCB" != "no" ]; then report_support " MIT-SHM ............" "$CFG_MITSHM" + report_support " Xcb-Xlib ..........." "$CFG_XCB_XLIB" report_support " Xcursor ............" "$CFG_XCURSOR" runtime "loaded at runtime" report_support " Xfixes ............." "$CFG_XFIXES" runtime "loaded at runtime" report_support " Xi ................." "$CFG_XINPUT" runtime "loaded at runtime" diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp index 5ea1ff14b9..2674f31d03 100644 --- a/qmake/generators/mac/pbuilder_pbx.cpp +++ b/qmake/generators/mac/pbuilder_pbx.cpp @@ -463,12 +463,12 @@ ProjectBuilderSources::files(QMakeProject *project) const { QStringList ret = project->values(ProKey(key)).toQStringList(); if(key == "QMAKE_INTERNAL_INCLUDED_FILES") { + QStringList newret; for(int i = 0; i < ret.size(); ++i) { - QStringList newret; if(!ret.at(i).endsWith(Option::prf_ext)) newret.append(ret.at(i)); - ret = newret; } + ret = newret; } if(key == "SOURCES" && project->first("TEMPLATE") == "app" && !project->isEmpty("ICON")) ret.append(project->first("ICON").toQString()); diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp index c02f65d77c..35639a33bf 100644 --- a/qmake/generators/unix/unixmake2.cpp +++ b/qmake/generators/unix/unixmake2.cpp @@ -920,7 +920,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) t << "\t-$(DEL_FILE) " << destdir << "$(TARGET0) " << destdir << "$(TARGET1) " << destdir << "$(TARGET2) $(TARGETA)\n"; } else { - t << "\t-$(DEL_FILE) $(TARGET) \n"; + t << "\t-$(DEL_FILE) " << destdir << "$(TARGET) \n"; } t << varGlue("QMAKE_DISTCLEAN","\t-$(DEL_FILE) "," ","\n"); { diff --git a/qtbase.pro b/qtbase.pro index 8da34c5023..9091fba4e0 100644 --- a/qtbase.pro +++ b/qtbase.pro @@ -179,7 +179,7 @@ write_file($$OUT_PWD/mkspecs/qfeatures.pri, FEATURES_PRI)|error("Aborting.") #mkspecs mkspecs.path = $$[QT_HOST_DATA]/mkspecs mkspecs.files = \ - $$OUT_PWD/mkspecs/qconfig.pri $$OUT_PWD/mkspecs/qmodule.pri $$OUT_PWD/mkspecs/qdevice.pri \ + $$OUT_PWD/mkspecs/qconfig.pri $$OUT_PWD/mkspecs/qmodule.pri $$OUT_PWD/mkspecs/qdevice.pri $$OUT_PWD/mkspecs/qfeatures.pri \ $$files($$PWD/mkspecs/*) mkspecs.files -= $$PWD/mkspecs/modules INSTALLS += mkspecs diff --git a/src/3rdparty/sha3/KeccakF-1600-opt64.c b/src/3rdparty/sha3/KeccakF-1600-opt64.c index 0432f1ab18..7bd442ef69 100755 --- a/src/3rdparty/sha3/KeccakF-1600-opt64.c +++ b/src/3rdparty/sha3/KeccakF-1600-opt64.c @@ -19,12 +19,16 @@ http://creativecommons.org/publicdomain/zero/1.0/ typedef unsigned char UINT8; typedef unsigned long long int UINT64; +#if defined(UseSSE) || defined(UseXOP) #if defined(__GNUC__) #define ALIGN __attribute__ ((aligned(32))) #elif defined(_MSC_VER) #define ALIGN __declspec(align(32)) -#else -#define ALIGN +#endif +#endif + +#ifndef ALIGN +# define ALIGN #endif #if defined(UseSSE) diff --git a/src/3rdparty/sha3/KeccakSponge.h b/src/3rdparty/sha3/KeccakSponge.h index a545cacb30..8bb11a8a1d 100755 --- a/src/3rdparty/sha3/KeccakSponge.h +++ b/src/3rdparty/sha3/KeccakSponge.h @@ -19,12 +19,16 @@ http://creativecommons.org/publicdomain/zero/1.0/ #define KeccakMaximumRate 1536 #define KeccakMaximumRateInBytes (KeccakMaximumRate/8) +#if defined(UseSSE) || defined(UseXOP) #if defined(__GNUC__) #define ALIGN __attribute__ ((aligned(32))) #elif defined(_MSC_VER) #define ALIGN __declspec(align(32)) -#else -#define ALIGN +#endif +#endif + +#ifndef ALIGN +# define ALIGN #endif ALIGN typedef struct spongeStateStruct { diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in index 1e00c74aa6..9bda70ec07 100644 --- a/src/corelib/Qt5CoreConfigExtras.cmake.in +++ b/src/corelib/Qt5CoreConfigExtras.cmake.in @@ -81,6 +81,12 @@ list(APPEND Qt5Core_COMPILE_DEFINITIONS QT_NAMESPACE=$$QT_NAMESPACE) set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS QT_NAMESPACE=$$QT_NAMESPACE) !!ENDIF +!!IF !isEmpty(CMAKE_DISABLED_FEATURES) +set(Qt5_DISABLED_FEATURES + $$CMAKE_DISABLED_FEATURES +) +!!ENDIF + set_property(TARGET Qt5::Core APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>) !!IF contains(QT_CONFIG, reduce_exports) diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index 2e4181efb1..b513149e7c 100644 --- a/src/corelib/corelib.pro +++ b/src/corelib/corelib.pro @@ -79,6 +79,9 @@ cmake_umbrella_config_version_file.input = $$PWD/../../mkspecs/features/data/cma cmake_umbrella_config_version_file.output = $$DESTDIR/cmake/Qt5/Qt5ConfigVersion.cmake load(cmake_functions) +load(qfeatures) + +CMAKE_DISABLED_FEATURES = $$join(QT_DISABLED_FEATURES, "$$escape_expand(\\n) ") CMAKE_HOST_DATA_DIR = $$cmakeRelativePath($$[QT_HOST_DATA/src], $$[QT_INSTALL_PREFIX]) contains(CMAKE_HOST_DATA_DIR, "^\\.\\./.*"):!isEmpty(CMAKE_HOST_DATA_DIR) { diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt index 3e9fc88eba..fb6e56ec7d 100644 --- a/src/corelib/global/qfeatures.txt +++ b/src/corelib/global/qfeatures.txt @@ -476,6 +476,12 @@ Section: Widgets Requires: GRAPHICSVIEW PRINTER MAINWINDOW Name: QPrintPreviewWidget +Feature: KEYSEQUENCEEDIT +Description: Provides a widget for editing QKeySequences +Section: Widgets +Requires: LINEEDIT SHORTCUT +Name: QKeySequenceEdit + # Dialogs Feature: MESSAGEBOX @@ -742,7 +748,7 @@ Name: QPdf Feature: PRINTER Description: Supports printing Section: Painting -Requires: PICTURE TEMPORARYFILE +Requires: PICTURE TEMPORARYFILE PDF Name: QPrinter Feature: CUPS diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 6d0500f08d..3c3d35e373 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.2.0" +#define QT_VERSION_STR "5.2.1" /* QT_VERSION is (major << 16) + (minor << 8) + patch. */ -#define QT_VERSION 0x050200 +#define QT_VERSION 0x050201 /* can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) */ diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp index f6b14c3027..23cff6af27 100644 --- a/src/corelib/io/qsettings_mac.cpp +++ b/src/corelib/io/qsettings_mac.cpp @@ -691,7 +691,8 @@ bool QConfFileSettingsPrivate::writePlistFile(const QString &fileName, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); - QCFType<CFDataRef> xmlData = CFPropertyListCreateXMLData(kCFAllocatorDefault, propertyList); + QCFType<CFDataRef> xmlData = CFPropertyListCreateData( + kCFAllocatorDefault, propertyList, kCFPropertyListXMLFormat_v1_0, 0, 0); SInt32 code; return CFURLWriteDataAndPropertiesToResource(urlFromFileName(fileName), xmlData, 0, &code); diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 43c64b7b2c..e77d6894d0 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -160,6 +160,8 @@ QString QCoreApplicationPrivate::appName() const } #endif +QString *QCoreApplicationPrivate::cachedApplicationFilePath = 0; + bool QCoreApplicationPrivate::checkInstance(const char *function) { bool b = (QCoreApplication::self != 0); @@ -425,6 +427,7 @@ QCoreApplicationPrivate::~QCoreApplicationPrivate() #ifdef Q_OS_WIN delete [] origArgv; #endif + QCoreApplicationPrivate::clearApplicationFilePath(); } #ifndef QT_NO_QOBJECT @@ -1884,6 +1887,20 @@ QString QCoreApplication::translate(const char *context, const char *sourceText, #endif //QT_NO_TRANSLATE +// Makes it possible to point QCoreApplication to a custom location to ensure +// the directory is added to the patch, and qt.conf and deployed plugins are +// found from there. This is for use cases in which QGuiApplication is +// instantiated by a library and not by an application executable, for example, +// Active X servers. + +void QCoreApplicationPrivate::setApplicationFilePath(const QString &path) +{ + if (QCoreApplicationPrivate::cachedApplicationFilePath) + *QCoreApplicationPrivate::cachedApplicationFilePath = path; + else + QCoreApplicationPrivate::cachedApplicationFilePath = new QString(path); +} + /*! Returns the directory that contains the application executable. @@ -1939,20 +1956,28 @@ QString QCoreApplication::applicationFilePath() } QCoreApplicationPrivate *d = self->d_func(); - if (!d->cachedApplicationFilePath.isNull()) - return d->cachedApplicationFilePath; + + static char *procName = d->argv[0]; + if (qstrcmp(procName, d->argv[0]) != 0) { + // clear the cache if the procname changes, so we reprocess it. + QCoreApplicationPrivate::clearApplicationFilePath(); + procName = d->argv[0]; + } + + if (QCoreApplicationPrivate::cachedApplicationFilePath) + return *QCoreApplicationPrivate::cachedApplicationFilePath; #if defined(Q_OS_WIN) - d->cachedApplicationFilePath = QFileInfo(qAppFileName()).filePath(); - return d->cachedApplicationFilePath; + QCoreApplicationPrivate::setApplicationFilePath(QFileInfo(qAppFileName()).filePath()); + return *QCoreApplicationPrivate::cachedApplicationFilePath; #elif defined(Q_OS_BLACKBERRY) if (!arguments().isEmpty()) { // args is never empty, but the navigator can change behaviour some day QFileInfo fileInfo(arguments().at(0)); const bool zygotized = fileInfo.exists(); if (zygotized) { // Handle the zygotized case: - d->cachedApplicationFilePath = QDir::cleanPath(fileInfo.absoluteFilePath()); - return d->cachedApplicationFilePath; + QCoreApplicationPrivate::setApplicationFilePath(QDir::cleanPath(fileInfo.absoluteFilePath())); + return *QCoreApplicationPrivate::cachedApplicationFilePath; } } @@ -1960,7 +1985,7 @@ QString QCoreApplication::applicationFilePath() const size_t maximum_path = static_cast<size_t>(pathconf("/",_PC_PATH_MAX)); char buff[maximum_path+1]; if (_cmdname(buff)) { - d->cachedApplicationFilePath = QDir::cleanPath(QString::fromLocal8Bit(buff)); + QCoreApplicationPrivate::setApplicationFilePath(QDir::cleanPath(QString::fromLocal8Bit(buff))); } else { qWarning("QCoreApplication::applicationFilePath: _cmdname() failed"); // _cmdname() won't fail, but just in case, fallback to the old method @@ -1968,18 +1993,19 @@ QString QCoreApplication::applicationFilePath() QStringList executables = dir.entryList(QDir::Executable | QDir::Files); if (!executables.empty()) { //We assume that there is only one executable in the folder - d->cachedApplicationFilePath = dir.absoluteFilePath(executables.first()); - } else { - d->cachedApplicationFilePath = QString(); + QCoreApplicationPrivate::setApplicationFilePath(dir.absoluteFilePath(executables.first())); } } - return d->cachedApplicationFilePath; + return *QCoreApplicationPrivate::cachedApplicationFilePath; #elif defined(Q_OS_MAC) QString qAppFileName_str = qAppFileName(); if(!qAppFileName_str.isEmpty()) { QFileInfo fi(qAppFileName_str); - d->cachedApplicationFilePath = fi.exists() ? fi.canonicalFilePath() : QString(); - return d->cachedApplicationFilePath; + if (fi.exists()) { + QCoreApplicationPrivate::setApplicationFilePath(fi.canonicalFilePath()); + return *QCoreApplicationPrivate::cachedApplicationFilePath; + } + return QString(); } #endif #if defined( Q_OS_UNIX ) @@ -1988,8 +2014,8 @@ QString QCoreApplication::applicationFilePath() // the absolute path of the executable QFileInfo pfi(QString::fromLatin1("/proc/%1/exe").arg(getpid())); if (pfi.exists() && pfi.isSymLink()) { - d->cachedApplicationFilePath = pfi.canonicalFilePath(); - return d->cachedApplicationFilePath; + QCoreApplicationPrivate::setApplicationFilePath(pfi.canonicalFilePath()); + return *QCoreApplicationPrivate::cachedApplicationFilePath; } # endif if (!arguments().isEmpty()) { @@ -2019,13 +2045,15 @@ QString QCoreApplication::applicationFilePath() absPath = QDir::cleanPath(absPath); QFileInfo fi(absPath); - d->cachedApplicationFilePath = fi.exists() ? fi.canonicalFilePath() : QString(); - } else { - d->cachedApplicationFilePath = QString(); + if (fi.exists()) { + QCoreApplicationPrivate::setApplicationFilePath(fi.canonicalFilePath()); + return *QCoreApplicationPrivate::cachedApplicationFilePath; + } } - return d->cachedApplicationFilePath; + return QString(); #endif + Q_UNREACHABLE(); } /*! diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index ad0449f02c..0c00f396b5 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -139,7 +139,9 @@ public: QCoreApplicationPrivate::Type application_type; QString cachedApplicationDirPath; - QString cachedApplicationFilePath; + static QString *cachedApplicationFilePath; + static void setApplicationFilePath(const QString &path); + static inline void clearApplicationFilePath() { delete cachedApplicationFilePath; cachedApplicationFilePath = 0; } #ifndef QT_NO_QOBJECT bool in_exec; diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index f8664ba3a2..7d2410a18a 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -4157,7 +4157,7 @@ QDebug operator<<(QDebug dbg, const QObject *o) { \macro Q_INVOKABLE \relates QObject - Apply this macro to definitions of member functions to allow them to + Apply this macro to declarations of member functions to allow them to be invoked via the meta-object system. The macro is written before the return type, as shown in the following example: @@ -4174,7 +4174,7 @@ QDebug operator<<(QDebug dbg, const QObject *o) { \macro Q_REVISION \relates QObject - Apply this macro to definitions of member functions to tag them with a + Apply this macro to declarations of member functions to tag them with a revision number in the meta-object system. The macro is written before the return type, as shown in the following example: diff --git a/src/corelib/kernel/qsystemsemaphore.cpp b/src/corelib/kernel/qsystemsemaphore.cpp index 6f0e5ee011..82e14e6f3f 100644 --- a/src/corelib/kernel/qsystemsemaphore.cpp +++ b/src/corelib/kernel/qsystemsemaphore.cpp @@ -229,8 +229,7 @@ void QSystemSemaphore::setKey(const QString &key, int initialValue, AccessMode m { if (key == d->key && mode == Open) return; - d->error = NoError; - d->errorString = QString(); + d->clearError(); #if !defined(Q_OS_WIN) // optimization to not destroy/create the file & semaphore if (key == d->key && mode == Create && d->createdSemaphore && d->createdFile) { diff --git a/src/corelib/kernel/qsystemsemaphore_p.h b/src/corelib/kernel/qsystemsemaphore_p.h index c809ba58c1..b34ec1b9a7 100644 --- a/src/corelib/kernel/qsystemsemaphore_p.h +++ b/src/corelib/kernel/qsystemsemaphore_p.h @@ -75,6 +75,11 @@ public: return QSharedMemoryPrivate::makePlatformSafeKey(key, QLatin1String("qipc_systemsem_")); } + inline void setError(QSystemSemaphore::SystemSemaphoreError e, const QString &message) + { error = e; errorString = message; } + inline void clearError() + { setError(QSystemSemaphore::NoError, QString()); } + #ifdef Q_OS_WIN Qt::HANDLE handle(QSystemSemaphore::AccessMode mode = QSystemSemaphore::Open); void setErrorString(const QString &function); diff --git a/src/corelib/kernel/qsystemsemaphore_unix.cpp b/src/corelib/kernel/qsystemsemaphore_unix.cpp index 073bd020ba..8f439c94a0 100644 --- a/src/corelib/kernel/qsystemsemaphore_unix.cpp +++ b/src/corelib/kernel/qsystemsemaphore_unix.cpp @@ -229,6 +229,7 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count) return false; } + clearError(); return true; } diff --git a/src/corelib/kernel/qsystemsemaphore_win.cpp b/src/corelib/kernel/qsystemsemaphore_win.cpp index 55df20b24e..edf90a31ac 100644 --- a/src/corelib/kernel/qsystemsemaphore_win.cpp +++ b/src/corelib/kernel/qsystemsemaphore_win.cpp @@ -136,6 +136,7 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count) } } + clearError(); return true; } diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp index d49a6a9a8e..9d90583a28 100644 --- a/src/corelib/thread/qthread_win.cpp +++ b/src/corelib/thread/qthread_win.cpp @@ -182,7 +182,7 @@ void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread) qt_adopted_thread_handles.prepend(qt_adopted_thread_wakeup); } - CreateThread(0, 0, qt_adopted_thread_watcher_function, 0, 0, &qt_adopted_thread_watcher_id); + CloseHandle(CreateThread(0, 0, qt_adopted_thread_watcher_function, 0, 0, &qt_adopted_thread_watcher_id)); } else { SetEvent(qt_adopted_thread_wakeup); } diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp index 8054542333..5463e4f0c1 100644 --- a/src/corelib/tools/qcommandlineparser.cpp +++ b/src/corelib/tools/qcommandlineparser.cpp @@ -845,11 +845,50 @@ static QString wrapText(const QString &names, int longestOptionNameString, const { const QLatin1Char nl('\n'); QString text = QStringLiteral(" ") + names.leftJustified(longestOptionNameString) + QLatin1Char(' '); - const int leftColumnWidth = text.length(); - const int rightColumnWidth = 79 - leftColumnWidth; - text += description.left(rightColumnWidth) + nl; - for (int n = rightColumnWidth; n < description.length(); n += rightColumnWidth) - text += QStringLiteral(" ").repeated(leftColumnWidth) + description.mid(n, rightColumnWidth) + nl; + const int indent = text.length(); + int lineStart = 0; + int lastBreakable = -1; + const int max = 79 - indent; + int x = 0; + const int len = description.length(); + + for (int i = 0; i < len; ++i) { + ++x; + const QChar c = description.at(i); + if (c.isSpace()) + lastBreakable = i; + + int breakAt = -1; + int nextLineStart = -1; + if (x > max && lastBreakable != -1) { + // time to break and we know where + breakAt = lastBreakable; + nextLineStart = lastBreakable + 1; + } else if ((x > max - 1 && lastBreakable == -1) || i == len - 1) { + // time to break but found nowhere [-> break here], or end of last line + breakAt = i + 1; + nextLineStart = breakAt; + } else if (c == nl) { + // forced break + breakAt = i; + nextLineStart = i + 1; + } + + if (breakAt != -1) { + const int numChars = breakAt - lineStart; + //qDebug() << "breakAt=" << description.at(breakAt) << "breakAtSpace=" << breakAtSpace << lineStart << "to" << breakAt << description.mid(lineStart, numChars); + if (lineStart > 0) + text += QString(indent, QLatin1Char(' ')); + text += description.midRef(lineStart, numChars) + nl; + x = 0; + lastBreakable = -1; + lineStart = nextLineStart; + if (lineStart < len && description.at(lineStart).isSpace()) + ++lineStart; // don't start a line with a space + i = lineStart; + } + } + return text; } diff --git a/src/corelib/tools/qlocale_blackberry.cpp b/src/corelib/tools/qlocale_blackberry.cpp index e2dfa6c801..48faa73070 100644 --- a/src/corelib/tools/qlocale_blackberry.cpp +++ b/src/corelib/tools/qlocale_blackberry.cpp @@ -68,17 +68,20 @@ QBBSystemLocaleData::QBBSystemLocaleData() , measurementNotifier(0) , hourNotifier(0) { + // Do not use qWarning to log warnings if qt_safe_open fails to open the pps file + // since the user code may install a message handler that invokes QLocale API again + // (i.e QDate, QDateTime, ...) which will cause a deadlock. if ((measurementFd = qt_safe_open(ppsUomPath, O_RDONLY)) == -1) - qWarning("Failed to open uom pps, errno=%d", errno); + fprintf(stderr, "Failed to open uom pps, errno=%d\n", errno); if ((regionFd = qt_safe_open(ppsRegionLocalePath, O_RDONLY)) == -1) - qWarning("Failed to open region pps, errno=%d", errno); + fprintf(stderr, "Failed to open region pps, errno=%d\n", errno); if ((languageFd = qt_safe_open(ppsLanguageLocalePath, O_RDONLY)) == -1) - qWarning("Failed to open language pps, errno=%d", errno); + fprintf(stderr, "Failed to open language pps, errno=%d\n", errno); if ((hourFd = qt_safe_open(ppsHourFormatPath, O_RDONLY)) == -1) - qWarning("Failed to open hour format pps, errno=%d", errno); + fprintf(stderr, "Failed to open hour format pps, errno=%d\n", errno); // we cannot call this directly, because by the time this constructor is // called, the event dispatcher has not yet been created, causing the @@ -186,8 +189,12 @@ QByteArray QBBSystemLocaleData::readPpsValue(const char *ppsObject, int ppsFd) char buffer[ppsBufferSize]; int bytes = qt_safe_read(ppsFd, buffer, ppsBufferSize - 1); + // This method is called in the ctor(), so do not use qWarning to log warnings + // if qt_safe_read fails to read the pps file + // since the user code may install a message handler that invokes QLocale API again + // (i.e QDate, QDateTime, ...) which will cause a deadlock. if (bytes == -1) { - qWarning("Failed to read Locale pps, errno=%d", errno); + fprintf(stderr, "Failed to read pps object:%s, errno=%d\n", ppsObject, errno); return result; } // ensure data is null terminated diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h index 4b4606ffab..581a12e0c7 100644 --- a/src/corelib/tools/qlocale_p.h +++ b/src/corelib/tools/qlocale_p.h @@ -360,10 +360,10 @@ inline char QLocalePrivate::digitToCLocale(QChar in) const if (in.unicode() >= '0' && in.unicode() <= '9') return in.toLatin1(); - if (in == plus()) + if (in == plus() || in == QLatin1Char('+')) return '+'; - if (in == minus()) + if (in == minus() || in == QLatin1Char('-') || in == QChar(0x2212)) return '-'; if (in == decimal()) diff --git a/src/gui/accessible/accessible.pri b/src/gui/accessible/accessible.pri index 9453ac20d0..615323dbec 100644 --- a/src/gui/accessible/accessible.pri +++ b/src/gui/accessible/accessible.pri @@ -4,7 +4,6 @@ contains(QT_CONFIG, accessibility) { HEADERS += \ accessible/qaccessible.h \ accessible/qaccessiblecache_p.h \ - accessible/qaccessible2_p.h \ accessible/qaccessibleobject.h \ accessible/qaccessibleplugin.h \ accessible/qplatformaccessibility.h diff --git a/src/gui/accessible/qaccessible2_p.h b/src/gui/accessible/qaccessible2_p.h deleted file mode 100644 index bb5ddf6edf..0000000000 --- a/src/gui/accessible/qaccessible2_p.h +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -** -** 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. -** -** $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$ -** -****************************************************************************/ - -#ifndef QACCESSIBLE2_H -#define QACCESSIBLE2_H - -#endif diff --git a/src/gui/kernel/qkeysequence_p.h b/src/gui/kernel/qkeysequence_p.h index eac0d4b0a6..3751660500 100644 --- a/src/gui/kernel/qkeysequence_p.h +++ b/src/gui/kernel/qkeysequence_p.h @@ -69,6 +69,7 @@ struct Q_AUTOTEST_EXPORT QKeyBinding class Q_AUTOTEST_EXPORT QKeySequencePrivate { public: + enum { MaxKeyCount = 4 }; // used in QKeySequenceEdit inline QKeySequencePrivate() : ref(1) { key[0] = key[1] = key[2] = key[3] = 0; diff --git a/src/gui/kernel/qoffscreensurface.cpp b/src/gui/kernel/qoffscreensurface.cpp index e2306050dd..ce913a98af 100644 --- a/src/gui/kernel/qoffscreensurface.cpp +++ b/src/gui/kernel/qoffscreensurface.cpp @@ -160,6 +160,8 @@ void QOffscreenSurface::create() d->platformOffscreenSurface = QGuiApplicationPrivate::platformIntegration()->createPlatformOffscreenSurface(this); // No platform offscreen surface, fallback to an invisible window if (!d->platformOffscreenSurface) { + if (QThread::currentThread() != qGuiApp->thread()) + qWarning("Attempting to create QWindow-based QOffscreenSurface outside the gui thread. Expect failures."); d->offscreenWindow = new QWindow(d->screen); d->offscreenWindow->setSurfaceType(QWindow::OpenGLSurface); d->offscreenWindow->setFormat(d->requestedFormat); diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp index 562df1c913..1844232efe 100644 --- a/src/gui/kernel/qplatformtheme.cpp +++ b/src/gui/kernel/qplatformtheme.cpp @@ -50,6 +50,7 @@ #include <qtextformat.h> #include <private/qiconloader_p.h> #include <private/qguiapplication_p.h> +#include <qpa/qplatformintegration.h> QT_BEGIN_NAMESPACE @@ -399,7 +400,32 @@ QPixmap QPlatformTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF & QVariant QPlatformTheme::themeHint(ThemeHint hint) const { - return QPlatformTheme::defaultThemeHint(hint); + // For theme hints which mirror platform integration style hints, query + // the platform integration. The base QPlatformIntegration::styleHint() + // function will in turn query QPlatformTheme::defaultThemeHint() if there + // is no custom value. + switch (hint) { + case QPlatformTheme::CursorFlashTime: + return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::CursorFlashTime); + case QPlatformTheme::KeyboardInputInterval: + return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::KeyboardInputInterval); + case QPlatformTheme::KeyboardAutoRepeatRate: + return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::KeyboardAutoRepeatRate); + case QPlatformTheme::MouseDoubleClickInterval: + return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::MouseDoubleClickInterval); + case QPlatformTheme::StartDragDistance: + return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::StartDragDistance); + case QPlatformTheme::StartDragTime: + return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::StartDragTime); + case QPlatformTheme::StartDragVelocity: + return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::StartDragVelocity); + case QPlatformTheme::PasswordMaskDelay: + return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::PasswordMaskDelay); + case QPlatformTheme::PasswordMaskCharacter: + return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::PasswordMaskCharacter); + default: + return QPlatformTheme::defaultThemeHint(hint); + } } QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint) diff --git a/src/gui/opengl/qopengltexturehelper.cpp b/src/gui/opengl/qopengltexturehelper.cpp index 7cd7ca54b2..676c0802de 100644 --- a/src/gui/opengl/qopengltexturehelper.cpp +++ b/src/gui/opengl/qopengltexturehelper.cpp @@ -148,7 +148,7 @@ QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context) } #endif -#if defined(Q_OS_WIN) +#if defined(Q_OS_WIN) && !defined(QT_OPENGL_ES_2) HMODULE handle = GetModuleHandleA("opengl32.dll"); // OpenGL 1.0 diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index a410004c06..49b5a9ba46 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -208,7 +208,7 @@ QFontEngine *QFontPrivate::engineForScript(int script) const QMutexLocker locker(qt_fontdatabase_mutex()); if (script <= QChar::Script_Latin) script = QChar::Script_Common; - if (engineData && engineData->fontCache != QFontCache::instance()) { + if (engineData && engineData->fontCacheId != QFontCache::instance()->id()) { // throw out engineData that came from a different thread if (!engineData->ref.deref()) delete engineData; @@ -317,7 +317,7 @@ void QFontPrivate::resolve(uint mask, const QFontPrivate *other) QFontEngineData::QFontEngineData() - : ref(0), fontCache(QFontCache::instance()) + : ref(0), fontCacheId(QFontCache::instance()->id()) { memset(engines, 0, QChar::ScriptCount * sizeof(QFontEngine *)); } @@ -2638,9 +2638,12 @@ void QFontCache::cleanup() } #endif // QT_NO_THREAD +QBasicAtomicInt font_cache_id = Q_BASIC_ATOMIC_INITIALIZER(1); + QFontCache::QFontCache() : QObject(), total_cost(0), max_cost(min_cost), - current_timestamp(0), fast(false), timer_id(-1) + current_timestamp(0), fast(false), timer_id(-1), + m_id(font_cache_id.fetchAndAddRelaxed(1)) { } diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h index 115e866f24..5b7f918e21 100644 --- a/src/gui/text/qfont_p.h +++ b/src/gui/text/qfont_p.h @@ -140,7 +140,7 @@ public: ~QFontEngineData(); QAtomicInt ref; - QFontCache *fontCache; + const int fontCacheId; QFontEngine *engines[QChar::ScriptCount]; @@ -206,6 +206,8 @@ public: QFontCache(); ~QFontCache(); + int id() const { return m_id; } + void clear(); struct Key { @@ -263,6 +265,7 @@ private: uint current_timestamp; bool fast; int timer_id; + const int m_id; }; Q_GUI_EXPORT int qt_defaultDpiX(); diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index ff050d1758..61c93dc2ac 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -499,6 +499,8 @@ static const int scriptForWritingSystem[] = { QChar::Script_Nko // Nko }; +Q_STATIC_ASSERT(sizeof(scriptForWritingSystem) / sizeof(scriptForWritingSystem[0]) == QFontDatabase::WritingSystemsCount); + int qt_script_for_writing_system(QFontDatabase::WritingSystem writingSystem) { return scriptForWritingSystem[writingSystem]; @@ -562,9 +564,9 @@ struct QtFontDesc int familyIndex; }; -static void match(int script, const QFontDef &request, - const QString &family_name, const QString &foundry_name, int force_encoding_id, - QtFontDesc *desc, const QList<int> &blacklistedFamilies = QList<int>()); +static int match(int script, const QFontDef &request, + const QString &family_name, const QString &foundry_name, int force_encoding_id, + QtFontDesc *desc, const QList<int> &blacklisted); static void initFontDef(const QtFontDesc &desc, const QFontDef &request, QFontDef *fontDef, bool multi) { @@ -846,11 +848,12 @@ static bool matchFamilyName(const QString &familyName, QtFontFamily *f) Tries to find the best match for a given request and family/foundry */ -static void match(int script, const QFontDef &request, - const QString &family_name, const QString &foundry_name, int force_encoding_id, - QtFontDesc *desc, const QList<int> &blacklistedFamilies) +static int match(int script, const QFontDef &request, + const QString &family_name, const QString &foundry_name, int force_encoding_id, + QtFontDesc *desc, const QList<int> &blacklistedFamilies) { Q_UNUSED(force_encoding_id); + int result = -1; QtFontStyle::Key styleKey; styleKey.style = request.style; @@ -881,6 +884,8 @@ static void match(int script, const QFontDef &request, load(family_name, script); + const size_t writingSystem = std::find(scriptForWritingSystem, scriptForWritingSystem + QFontDatabase::WritingSystemsCount, script) - scriptForWritingSystem; + QFontDatabasePrivate *db = privateDb(); for (int x = 0; x < db->count; ++x) { if (blacklistedFamilies.contains(x)) @@ -895,19 +900,9 @@ static void match(int script, const QFontDef &request, if (family_name.isEmpty()) load(test.family->name, script); - uint score_adjust = 0; - - bool supported = (script == QChar::Script_Common); - for (int ws = 1; !supported && ws < QFontDatabase::WritingSystemsCount; ++ws) { - if (scriptForWritingSystem[ws] != script) - continue; - if (test.family->writingSystems[ws] & QtFontFamily::Supported) - supported = true; - } - if (!supported) { - // family not supported in the script we want + // Check if family is supported in the script we want + if (script != QChar::Script_Common && !(test.family->writingSystems[writingSystem] & QtFontFamily::Supported)) continue; - } // as we know the script is supported, we can be sure // to find a matching font here. @@ -922,15 +917,16 @@ static void match(int script, const QFontDef &request, QString(), styleKey, request.pixelSize, pitch, &test, force_encoding_id); } - newscore += score_adjust; if (newscore < score) { + result = x; score = newscore; *desc = test; } if (newscore < 10) // xlfd instead of FT... just accept it break; } + return result; } static QString styleStringHelper(int weight, QFont::Style style) diff --git a/src/gui/text/qfontdatabase_qpa.cpp b/src/gui/text/qfontdatabase_qpa.cpp index 6c0be950dc..6f4971e267 100644 --- a/src/gui/text/qfontdatabase_qpa.cpp +++ b/src/gui/text/qfontdatabase_qpa.cpp @@ -305,9 +305,12 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp, } QtFontDesc desc; - match(script, request, family_name, foundry_name, force_encoding_id, &desc); - if (desc.family != 0 && desc.foundry != 0 && desc.style != 0) { + QList<int> blackListed; + int index = match(script, request, family_name, foundry_name, force_encoding_id, &desc, blackListed); + if (index >= 0) { engine = loadEngine(script, request, desc.family, desc.foundry, desc.style, desc.size); + if (!engine) + blackListed.append(index); } else { FM_DEBUG(" NO MATCH FOUND\n"); } @@ -331,6 +334,8 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp, QFont::Style(request.style), QFont::StyleHint(request.styleHint), QChar::Script(script)); + if (script > QChar::Script_Common) + fallbacks += QString(); // Find the first font matching the specified script. for (int i = 0; !engine && i < fallbacks.size(); i++) { QFontDef def = request; @@ -339,14 +344,19 @@ QFontDatabase::findFont(int script, const QFontPrivate *fp, engine = QFontCache::instance()->findEngine(key); if (!engine) { QtFontDesc desc; - match(script, def, def.family, QLatin1String(""), 0, &desc); - if (desc.family == 0 && desc.foundry == 0 && desc.style == 0) { - continue; - } - engine = loadEngine(script, def, desc.family, desc.foundry, desc.style, desc.size); - if (engine) { - initFontDef(desc, def, &engine->fontDef, engine->type() == QFontEngine::Multi); - } + do { + index = match(script, def, def.family, QLatin1String(""), 0, &desc, blackListed); + if (index >= 0) { + QFontDef loadDef = def; + if (loadDef.family.isEmpty()) + loadDef.family = desc.family->name; + engine = loadEngine(script, loadDef, desc.family, desc.foundry, desc.style, desc.size); + if (engine) + initFontDef(desc, loadDef, &engine->fontDef, engine->type() == QFontEngine::Multi); + else + blackListed.append(index); + } + } while (index >= 0 && !engine); } } } diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 5f53a36629..42cf15ee3b 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -112,7 +112,7 @@ QT_BEGIN_NAMESPACE #endif #define FLOOR(x) ((x) & -64) -#define CEIL(x) (((x)+63) & -64) +#define CEIL(x) (((x)+63) & -64) #define TRUNC(x) ((x) >> 6) #define ROUND(x) (((x)+32) & -64) @@ -124,11 +124,21 @@ public: QtFreetypeData() : library(0) { } + ~QtFreetypeData(); FT_Library library; QHash<QFontEngine::FaceId, QFreetypeFace *> faces; }; +QtFreetypeData::~QtFreetypeData() +{ + for (QHash<QFontEngine::FaceId, QFreetypeFace *>::ConstIterator iter = faces.begin(); iter != faces.end(); ++iter) + iter.value()->cleanup(); + faces.clear(); + FT_Done_FreeType(library); + library = 0; +} + #ifdef QT_NO_THREAD Q_GLOBAL_STATIC(QtFreetypeData, theFreetypeData) @@ -292,23 +302,35 @@ QFreetypeFace *QFreetypeFace::getFace(const QFontEngine::FaceId &face_id, return freetype; } +void QFreetypeFace::cleanup() +{ + if (hbFace && hbFace_destroy_func) { + hbFace_destroy_func(hbFace); + hbFace = 0; + } + FT_Done_Face(face); + face = 0; +} + void QFreetypeFace::release(const QFontEngine::FaceId &face_id) { - QtFreetypeData *freetypeData = qt_getFreetypeData(); if (!ref.deref()) { - if (hbFace && hbFace_destroy_func) { - hbFace_destroy_func(hbFace); - hbFace = 0; + if (face) { + QtFreetypeData *freetypeData = qt_getFreetypeData(); + + cleanup(); + + if (freetypeData->faces.contains(face_id)) + freetypeData->faces.take(face_id); + + if (freetypeData->faces.isEmpty()) { + FT_Done_FreeType(freetypeData->library); + freetypeData->library = 0; + } } - FT_Done_Face(face); - if(freetypeData->faces.contains(face_id)) - freetypeData->faces.take(face_id); + delete this; } - if (freetypeData->faces.isEmpty()) { - FT_Done_FreeType(freetypeData->library); - freetypeData->library = 0; - } } diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h index e64fec2f27..7df66b9678 100644 --- a/src/gui/text/qfontengine_ft_p.h +++ b/src/gui/text/qfontengine_ft_p.h @@ -114,9 +114,11 @@ public: private: friend class QFontEngineFT; + friend class QtFreetypeData; friend struct QScopedPointerDeleter<QFreetypeFace>; QFreetypeFace() : _lock(QMutex::Recursive) {} ~QFreetypeFace() {} + void cleanup(); QAtomicInt ref; QMutex _lock; QByteArray fontData; diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 30e0f32547..4a34f0d3c3 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -2491,7 +2491,7 @@ static bool isOrderedList(int style) || style == QTextListFormat::ListUpperAlpha || style == QTextListFormat::ListUpperRoman || style == QTextListFormat::ListLowerRoman - ; + ; } void QTextHtmlExporter::emitBlockAttributes(const QTextBlock &block) diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index f0910dd52d..4b6ce667fa 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -632,7 +632,7 @@ void QTextDocumentPrivate::move(int pos, int to, int length, QTextUndoCommand::O blockRevision); if (key+1 != blocks.position(b)) { -// qDebug("remove_string from %d length %d", key, X->size_array[0]); +// qDebug("remove_string from %d length %d", key, X->size_array[0]); Q_ASSERT(noBlockInString(text.mid(X->stringPosition, X->size_array[0]))); w = remove_string(key, X->size_array[0], op); @@ -641,7 +641,7 @@ void QTextDocumentPrivate::move(int pos, int to, int length, QTextUndoCommand::O dstKey += X->size_array[0]; } } else { -// qDebug("remove_block at %d", key); +// qDebug("remove_block at %d", key); Q_ASSERT(X->size_array[0] == 1 && isValidBlockSeparator(text.at(X->stringPosition))); b = blocks.previous(b); B = 0; @@ -779,7 +779,7 @@ void QTextDocumentPrivate::setCharFormat(int pos, int length, const QTextCharFor } void QTextDocumentPrivate::setBlockFormat(const QTextBlock &from, const QTextBlock &to, - const QTextBlockFormat &newFormat, FormatChangeMode mode) + const QTextBlockFormat &newFormat, FormatChangeMode mode) { beginEditBlock(); @@ -795,7 +795,7 @@ void QTextDocumentPrivate::setBlockFormat(const QTextBlock &from, const QTextBlo QTextBlock it = from; QTextBlock end = to; if (end.isValid()) - end = end.next(); + end = end.next(); for (; it != end; it = it.next()) { int oldFormat = block(it)->format; @@ -820,8 +820,8 @@ void QTextDocumentPrivate::setBlockFormat(const QTextBlock &from, const QTextBlo if (group) group->blockInserted(it); } else if (group) { - group->blockFormatChanged(it); - } + group->blockFormatChanged(it); + } } documentChange(from.position(), to.position() + to.length() - from.position()); @@ -892,14 +892,14 @@ int QTextDocumentPrivate::undoRedo(bool undo) QTextUndoCommand &c = undoStack[undoState]; int resetBlockRevision = c.pos; - switch(c.command) { + switch (c.command) { case QTextUndoCommand::Inserted: remove(c.pos, c.length, (QTextUndoCommand::Operation)c.operation); PMDEBUG(" erase: from %d, length %d", c.pos, c.length); c.command = QTextUndoCommand::Removed; editPos = c.pos; editLength = 0; - break; + break; case QTextUndoCommand::Removed: PMDEBUG(" insert: format %d (from %d, length %d, strpos=%d)", c.format, c.pos, c.length, c.strPos); insert_string(c.pos, c.strPos, c.length, c.format, (QTextUndoCommand::Operation)c.operation); @@ -908,33 +908,33 @@ int QTextDocumentPrivate::undoRedo(bool undo) editLength = 0; editPos = c.pos; editLength += c.length; - break; - case QTextUndoCommand::BlockInserted: - case QTextUndoCommand::BlockAdded: + break; + case QTextUndoCommand::BlockInserted: + case QTextUndoCommand::BlockAdded: remove_block(c.pos, &c.blockFormat, c.command, (QTextUndoCommand::Operation)c.operation); PMDEBUG(" blockremove: from %d", c.pos); - if (c.command == QTextUndoCommand::BlockInserted) - c.command = QTextUndoCommand::BlockRemoved; - else - c.command = QTextUndoCommand::BlockDeleted; + if (c.command == QTextUndoCommand::BlockInserted) + c.command = QTextUndoCommand::BlockRemoved; + else + c.command = QTextUndoCommand::BlockDeleted; editPos = c.pos; editLength = 0; - break; - case QTextUndoCommand::BlockRemoved: - case QTextUndoCommand::BlockDeleted: + break; + case QTextUndoCommand::BlockRemoved: + case QTextUndoCommand::BlockDeleted: PMDEBUG(" blockinsert: charformat %d blockformat %d (pos %d, strpos=%d)", c.format, c.blockFormat, c.pos, c.strPos); insert_block(c.pos, c.strPos, c.format, c.blockFormat, (QTextUndoCommand::Operation)c.operation, c.command); resetBlockRevision += 1; - if (c.command == QTextUndoCommand::BlockRemoved) - c.command = QTextUndoCommand::BlockInserted; - else - c.command = QTextUndoCommand::BlockAdded; + if (c.command == QTextUndoCommand::BlockRemoved) + c.command = QTextUndoCommand::BlockInserted; + else + c.command = QTextUndoCommand::BlockAdded; if (editPos != (int)c.pos) editLength = 0; editPos = c.pos; editLength += 1; - break; - case QTextUndoCommand::CharFormatChanged: { + break; + case QTextUndoCommand::CharFormatChanged: { resetBlockRevision = -1; // ## TODO PMDEBUG(" charFormat: format %d (from %d, length %d)", c.format, c.pos, c.length); FragmentIterator it = find(c.pos); @@ -947,9 +947,9 @@ int QTextDocumentPrivate::undoRedo(bool undo) editLength = 0; editPos = c.pos; editLength += c.length; - break; - } - case QTextUndoCommand::BlockFormatChanged: { + break; + } + case QTextUndoCommand::BlockFormatChanged: { resetBlockRevision = -1; // ## TODO PMDEBUG(" blockformat: format %d pos %d", c.format, c.pos); QTextBlock it = blocksFind(c.pos); @@ -970,9 +970,9 @@ int QTextDocumentPrivate::undoRedo(bool undo) } documentChange(it.position(), it.length()); editPos = -1; - break; - } - case QTextUndoCommand::GroupFormatChange: { + break; + } + case QTextUndoCommand::GroupFormatChange: { resetBlockRevision = -1; // ## TODO PMDEBUG(" group format change"); QTextObject *object = objectForIndex(c.objectIndex); @@ -980,22 +980,22 @@ int QTextDocumentPrivate::undoRedo(bool undo) changeObjectFormat(object, c.format); c.format = oldFormat; editPos = -1; - break; - } + break; + } case QTextUndoCommand::CursorMoved: editPos = c.pos; editLength = 0; break; - case QTextUndoCommand::Custom: + case QTextUndoCommand::Custom: resetBlockRevision = -1; // ## TODO if (undo) c.custom->undo(); else c.custom->redo(); editPos = -1; - break; - default: - Q_ASSERT(false); + break; + default: + Q_ASSERT(false); } if (resetBlockRevision >= 0) { @@ -1315,9 +1315,9 @@ void QTextDocumentPrivate::adjustDocumentChangesAndCursors(int from, int addedOr int removed = qMax(0, -addedOrRemoved); int diff = 0; - if(from + removed < docChangeFrom) + if (from + removed < docChangeFrom) diff = docChangeFrom - from - removed; - else if(from > docChangeFrom + docChangeLength) + else if (from > docChangeFrom + docChangeLength) diff = from - (docChangeFrom + docChangeLength); int overlap_start = qMax(from, docChangeFrom); diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h index 1394e88465..8d4cab30ae 100644 --- a/src/gui/text/qtextdocument_p.h +++ b/src/gui/text/qtextdocument_p.h @@ -194,7 +194,7 @@ public: void setCharFormat(int pos, int length, const QTextCharFormat &newFormat, FormatChangeMode mode = SetFormat); void setBlockFormat(const QTextBlock &from, const QTextBlock &to, - const QTextBlockFormat &newFormat, FormatChangeMode mode = SetFormat); + const QTextBlockFormat &newFormat, FormatChangeMode mode = SetFormat); void emitUndoAvailable(bool available); void emitRedoAvailable(bool available); diff --git a/src/gui/text/qtextlist.cpp b/src/gui/text/qtextlist.cpp index f969f66006..15c16f1ec0 100644 --- a/src/gui/text/qtextlist.cpp +++ b/src/gui/text/qtextlist.cpp @@ -265,8 +265,8 @@ QString QTextList::itemText(const QTextBlock &blockIt) const result = QLatin1String("?"); } - } - break; + } + break; default: Q_ASSERT(false); } diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp index d77cbf9671..045fe7f957 100644 --- a/src/gui/text/qtexttable.cpp +++ b/src/gui/text/qtexttable.cpp @@ -355,12 +355,12 @@ QTextTable *QTextTablePrivate::createTable(QTextDocumentPrivate *pieceTable, int for (int i = 1; i < rows*cols; ++i) { d->cells.append(pieceTable->insertBlock(QTextBeginningOfFrame, pos, cellIdx, charIdx)); -// qDebug(" addCell at %d", pos); +// qDebug(" addCell at %d", pos); ++pos; } d->fragment_end = pieceTable->insertBlock(QTextEndOfFrame, pos, cellIdx, charIdx); -// qDebug(" addEOR at %d", pos); +// qDebug(" addEOR at %d", pos); ++pos; d->blockFragmentUpdates = false; @@ -482,7 +482,7 @@ void QTextTablePrivate::update() const for (int jj = 0; jj < colspan; ++jj) { Q_ASSERT(grid[(r+ii)*nCols + c+jj] == 0); grid[(r+ii)*nCols + c+jj] = fragment; -// qDebug(" setting cell %d span=%d/%d at %d/%d", fragment, rowspan, colspan, r+ii, c+jj); +// qDebug(" setting cell %d span=%d/%d at %d/%d", fragment, rowspan, colspan, r+ii, c+jj); } } } @@ -654,7 +654,7 @@ void QTextTable::resize(int rows, int cols) int nCols = this->columns(); if (rows == nRows && cols == nCols) - return; + return; d->pieceTable->beginEditBlock(); @@ -682,7 +682,7 @@ void QTextTable::insertRows(int pos, int num) { Q_D(QTextTable); if (num <= 0) - return; + return; if (d->dirty) d->update(); @@ -744,7 +744,7 @@ void QTextTable::insertColumns(int pos, int num) { Q_D(QTextTable); if (num <= 0) - return; + return; if (d->dirty) d->update(); @@ -932,7 +932,7 @@ void QTextTable::removeColumns(int pos, int num) // qDebug() << "-------- removeCols" << pos << num; if (num <= 0 || pos < 0) - return; + return; if (d->dirty) d->update(); if (pos >= d->nCols) diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri index 59a6f346e2..2a0e4eff32 100644 --- a/src/gui/text/text.pri +++ b/src/gui/text/text.pri @@ -1,89 +1,89 @@ # Qt kernel module HEADERS += \ - text/qfont.h \ - text/qfontdatabase.h \ - text/qfontengine_p.h \ - text/qfontengineglyphcache_p.h \ - text/qfontinfo.h \ - text/qfontmetrics.h \ - text/qfont_p.h \ - text/qfontsubset_p.h \ - text/qtextengine_p.h \ - text/qtextlayout.h \ - text/qtextformat.h \ - text/qtextformat_p.h \ - text/qtextobject.h \ - text/qtextobject_p.h \ - text/qtextoption.h \ - text/qfragmentmap_p.h \ - text/qtextdocument.h \ - text/qtextdocument_p.h \ - text/qtexthtmlparser_p.h \ - text/qabstracttextdocumentlayout.h \ - text/qtextdocumentlayout_p.h \ - text/qtextcursor.h \ - text/qtextcursor_p.h \ - text/qtextdocumentfragment.h \ - text/qtextdocumentfragment_p.h \ - text/qtextimagehandler_p.h \ - text/qtexttable.h \ - text/qtextlist.h \ - text/qsyntaxhighlighter.h \ - text/qtextdocumentwriter.h \ - text/qcssparser_p.h \ - text/qtexttable_p.h \ - text/qzipreader_p.h \ - text/qzipwriter_p.h \ - text/qtextodfwriter_p.h \ - text/qstatictext_p.h \ - text/qstatictext.h \ - text/qrawfont.h \ - text/qrawfont_p.h \ + text/qfont.h \ + text/qfontdatabase.h \ + text/qfontengine_p.h \ + text/qfontengineglyphcache_p.h \ + text/qfontinfo.h \ + text/qfontmetrics.h \ + text/qfont_p.h \ + text/qfontsubset_p.h \ + text/qtextengine_p.h \ + text/qtextlayout.h \ + text/qtextformat.h \ + text/qtextformat_p.h \ + text/qtextobject.h \ + text/qtextobject_p.h \ + text/qtextoption.h \ + text/qfragmentmap_p.h \ + text/qtextdocument.h \ + text/qtextdocument_p.h \ + text/qtexthtmlparser_p.h \ + text/qabstracttextdocumentlayout.h \ + text/qtextdocumentlayout_p.h \ + text/qtextcursor.h \ + text/qtextcursor_p.h \ + text/qtextdocumentfragment.h \ + text/qtextdocumentfragment_p.h \ + text/qtextimagehandler_p.h \ + text/qtexttable.h \ + text/qtextlist.h \ + text/qsyntaxhighlighter.h \ + text/qtextdocumentwriter.h \ + text/qcssparser_p.h \ + text/qtexttable_p.h \ + text/qzipreader_p.h \ + text/qzipwriter_p.h \ + text/qtextodfwriter_p.h \ + text/qstatictext_p.h \ + text/qstatictext.h \ + text/qrawfont.h \ + text/qrawfont_p.h \ text/qglyphrun.h \ text/qglyphrun_p.h \ text/qdistancefield_p.h SOURCES += \ - text/qfont.cpp \ - text/qfontengine.cpp \ - text/qfontsubset.cpp \ - text/qfontmetrics.cpp \ - text/qfontdatabase.cpp \ - text/qtextengine.cpp \ - text/qtextlayout.cpp \ - text/qtextformat.cpp \ - text/qtextobject.cpp \ - text/qtextoption.cpp \ - text/qfragmentmap.cpp \ - text/qtextdocument.cpp \ - text/qtextdocument_p.cpp \ - text/qtexthtmlparser.cpp \ - text/qabstracttextdocumentlayout.cpp \ - text/qtextdocumentlayout.cpp \ - text/qtextcursor.cpp \ - text/qtextdocumentfragment.cpp \ - text/qtextimagehandler.cpp \ - text/qtexttable.cpp \ - text/qtextlist.cpp \ - text/qtextdocumentwriter.cpp \ - text/qsyntaxhighlighter.cpp \ - text/qcssparser.cpp \ - text/qzip.cpp \ - text/qtextodfwriter.cpp \ - text/qstatictext.cpp \ - text/qrawfont.cpp \ + text/qfont.cpp \ + text/qfontengine.cpp \ + text/qfontsubset.cpp \ + text/qfontmetrics.cpp \ + text/qfontdatabase.cpp \ + text/qtextengine.cpp \ + text/qtextlayout.cpp \ + text/qtextformat.cpp \ + text/qtextobject.cpp \ + text/qtextoption.cpp \ + text/qfragmentmap.cpp \ + text/qtextdocument.cpp \ + text/qtextdocument_p.cpp \ + text/qtexthtmlparser.cpp \ + text/qabstracttextdocumentlayout.cpp \ + text/qtextdocumentlayout.cpp \ + text/qtextcursor.cpp \ + text/qtextdocumentfragment.cpp \ + text/qtextimagehandler.cpp \ + text/qtexttable.cpp \ + text/qtextlist.cpp \ + text/qtextdocumentwriter.cpp \ + text/qsyntaxhighlighter.cpp \ + text/qcssparser.cpp \ + text/qzip.cpp \ + text/qtextodfwriter.cpp \ + text/qstatictext.cpp \ + text/qrawfont.cpp \ text/qglyphrun.cpp \ text/qdistancefield.cpp SOURCES += \ - text/qfont_qpa.cpp \ - text/qfontengine_qpa.cpp \ - text/qplatformfontdatabase.cpp \ - text/qrawfont_qpa.cpp + text/qfont_qpa.cpp \ + text/qfontengine_qpa.cpp \ + text/qplatformfontdatabase.cpp \ + text/qrawfont_qpa.cpp HEADERS += \ - text/qplatformfontdatabase.h + text/qplatformfontdatabase.h contains(QT_CONFIG, harfbuzz)|contains(QT_CONFIG, system-harfbuzz) { DEFINES += QT_ENABLE_HARFBUZZ_NG diff --git a/src/network/kernel/qnetworkinterface_unix.cpp b/src/network/kernel/qnetworkinterface_unix.cpp index 01c082059f..d3c830a66f 100644 --- a/src/network/kernel/qnetworkinterface_unix.cpp +++ b/src/network/kernel/qnetworkinterface_unix.cpp @@ -277,18 +277,18 @@ static QList<QNetworkInterfacePrivate *> interfaceListing() } } - // Get the interface netmask - if (qt_safe_ioctl(socket, SIOCGIFNETMASK, &req) >= 0) { - sockaddr *sa = &req.ifr_addr; - entry.setNetmask(addressFromSockaddr(sa)); - } - // Get the address of the interface if (qt_safe_ioctl(socket, SIOCGIFADDR, &req) >= 0) { sockaddr *sa = &req.ifr_addr; entry.setIp(addressFromSockaddr(sa)); } + // Get the interface netmask + if (qt_safe_ioctl(socket, SIOCGIFNETMASK, &req) >= 0) { + sockaddr *sa = &req.ifr_addr; + entry.setNetmask(addressFromSockaddr(sa)); + } + iface->addressEntries << entry; } diff --git a/src/platformsupport/eglconvenience/qeglconvenience.cpp b/src/platformsupport/eglconvenience/qeglconvenience.cpp index b711a2aebd..32f553a3f5 100644 --- a/src/platformsupport/eglconvenience/qeglconvenience.cpp +++ b/src/platformsupport/eglconvenience/qeglconvenience.cpp @@ -232,17 +232,28 @@ EGLConfig QEglConfigChooser::chooseConfig() configureAttributes.append(surfaceType()); configureAttributes.append(EGL_RENDERABLE_TYPE); - if (m_format.renderableType() == QSurfaceFormat::OpenVG) + switch (m_format.renderableType()) { + case QSurfaceFormat::OpenVG: configureAttributes.append(EGL_OPENVG_BIT); + break; #ifdef EGL_VERSION_1_4 - else if (m_format.renderableType() == QSurfaceFormat::OpenGL) +# if !defined(QT_OPENGL_ES_2) + case QSurfaceFormat::DefaultRenderableType: +# endif + case QSurfaceFormat::OpenGL: configureAttributes.append(EGL_OPENGL_BIT); + break; #endif - else if (m_format.majorVersion() == 1) - configureAttributes.append(EGL_OPENGL_ES_BIT); - else + case QSurfaceFormat::OpenGLES: + if (m_format.majorVersion() == 1) { + configureAttributes.append(EGL_OPENGL_ES_BIT); + break; + } + // fall through + default: configureAttributes.append(EGL_OPENGL_ES2_BIT); - + break; + } configureAttributes.append(EGL_NONE); EGLConfig cfg = 0; @@ -336,7 +347,11 @@ QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config, if (referenceFormat.renderableType() == QSurfaceFormat::OpenVG && (renderableType & EGL_OPENVG_BIT)) format.setRenderableType(QSurfaceFormat::OpenVG); #ifdef EGL_VERSION_1_4 - else if (referenceFormat.renderableType() == QSurfaceFormat::OpenGL && (renderableType & EGL_OPENGL_BIT)) + else if ((referenceFormat.renderableType() == QSurfaceFormat::OpenGL +# if !defined(QT_OPENGL_ES_2) + || referenceFormat.renderableType() == QSurfaceFormat::DefaultRenderableType +# endif + ) && (renderableType & EGL_OPENGL_BIT)) format.setRenderableType(QSurfaceFormat::OpenGL); #endif else diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp index 34ba21afdc..714ad8a17e 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp +++ b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp @@ -49,14 +49,23 @@ static inline void bindApi(const QSurfaceFormat &format) { - if (format.renderableType() == QSurfaceFormat::OpenVG) + switch (format.renderableType()) { + case QSurfaceFormat::OpenVG: eglBindAPI(EGL_OPENVG_API); + break; #ifdef EGL_VERSION_1_4 - else if (format.renderableType() == QSurfaceFormat::OpenGL) +# if !defined(QT_OPENGL_ES_2) + case QSurfaceFormat::DefaultRenderableType: +# endif + case QSurfaceFormat::OpenGL: eglBindAPI(EGL_OPENGL_API); + break; #endif - else + case QSurfaceFormat::OpenGLES: + default: eglBindAPI(EGL_OPENGL_ES_API); + break; + } } QEGLPlatformContext::QEGLPlatformContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display, diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp index b97923c4b6..0841544208 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp @@ -224,7 +224,7 @@ void QEvdevKeyboardHandler::processKeyEvent(int nativecode, int unicode, int qtc { QWindowSystemInterface::handleExtendedKeyEvent(0, (isPress ? QEvent::KeyPress : QEvent::KeyRelease), qtcode, modifiers, nativecode + 8, 0, int(modifiers), - QString(unicode), autoRepeat); + (unicode != 0xffff ) ? QString(unicode) : QString(), autoRepeat); } QEvdevKeyboardHandler::KeycodeAction QEvdevKeyboardHandler::processKeycode(quint16 keycode, bool pressed, bool autorepeat) diff --git a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp index b5e3aa741e..dad34e121b 100644 --- a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp +++ b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.cpp @@ -100,7 +100,6 @@ void TableGenerator::findComposeFile() qDebug() << "Using Compose file from: " << composeFile; #endif } - // check if user’s home directory has a file named .XCompose if (!found && cleanState()) { QString composeFile = qgetenv("HOME") + QStringLiteral("/.XCompose"); @@ -111,10 +110,12 @@ void TableGenerator::findComposeFile() qDebug() << "Using Compose file from: " << composeFile; #endif } - // check for the system provided compose files if (!found && cleanState()) { - QString table = readLocaleMappings(locale().toUpper().toUtf8()); + QByteArray loc = locale().toUpper().toUtf8(); + QString table = readLocaleMappings(loc); + if (table.isEmpty()) + table = readLocaleMappings(readLocaleAliases(loc)); if (cleanState()) { if (table.isEmpty()) @@ -177,8 +178,11 @@ QString TableGenerator::locale() const QString TableGenerator::readLocaleMappings(const QByteArray &locale) { - QFile mappings(systemComposeDir() + QLatin1String("/compose.dir")); QString file; + if (locale.isEmpty()) + return file; + + QFile mappings(systemComposeDir() + QLatin1String("/compose.dir")); if (mappings.open(QIODevice::ReadOnly)) { const int localeNameLength = locale.size(); const char * const localeData = locale.constData(); @@ -208,9 +212,8 @@ QString TableGenerator::readLocaleMappings(const QByteArray &locale) while (*line && *line != ' ' && *line != '\t' && *line != '\n') ++line; *line = '\0'; - if (localeNameLength == (line - lc) && !strncasecmp(lc, localeData, line - lc)) { - file = QString::fromUtf8(l, composeFileNameEnd - l); + file = QString::fromLocal8Bit(l, composeFileNameEnd - l); break; } } @@ -220,6 +223,47 @@ QString TableGenerator::readLocaleMappings(const QByteArray &locale) return file; } +QByteArray TableGenerator::readLocaleAliases(const QByteArray &locale) +{ + QFile aliases(systemComposeDir() + QLatin1String("/locale.alias")); + QByteArray fullLocaleName; + if (aliases.exists()) { + aliases.open(QIODevice::ReadOnly); + while (!aliases.atEnd()) { + char l[1024]; + int read = aliases.readLine(l, sizeof(l)); + char *line = l; + if (read && ((*line >= 'a' && *line <= 'z') || + (*line >= 'A' && *line <= 'Z'))) { + const char *alias = line; + while (*line && *line != ':' && *line != ' ' && *line != '\t') + ++line; + if (!*line) + continue; + *line = 0; + if (locale.size() == (line - alias) + && !strncasecmp(alias, locale.constData(), line - alias)) { + // found a match for alias, read the real locale name + ++line; + while (*line && (*line == ' ' || *line == '\t')) + ++line; + const char *fullName = line; + while (*line && *line != ' ' && *line != '\t' && *line != '\n') + ++line; + *line = 0; + fullLocaleName = fullName; +#ifdef DEBUG_GENERATOR + qDebug() << "Alias for: " << alias << "is: " << fullLocaleName; + break; +#endif + } + } + } + aliases.close(); + } + return fullLocaleName; +} + bool TableGenerator::processFile(QString composeFileName) { QFile composeFile(composeFileName); @@ -254,7 +298,7 @@ void TableGenerator::parseComposeFile(QFile *composeFile) if (*line == '<') parseKeySequence(line); else if (!strncmp(line, "include", 7)) - parseIncludeInstruction(QString::fromUtf8(line)); + parseIncludeInstruction(QString::fromLocal8Bit(line)); } composeFile->close(); @@ -308,7 +352,7 @@ ushort TableGenerator::keysymToUtf8(quint32 sym) qDebug() << QString("keysym - 0x%1 : utf8 - %2").arg(QString::number(sym, 16)) .arg(codec->toUnicode(chars)); #endif - return QString::fromUtf8(chars).at(0).unicode(); + return QString::fromLocal8Bit(chars).at(0).unicode(); } static inline int fromBase8(const char *s, const char *end) @@ -377,13 +421,13 @@ void TableGenerator::parseKeySequence(char *line) // handle direct text encoded in the locale if (*composeValue == '\\') ++composeValue; - elem.value = QString::fromUtf8(composeValue).at(0).unicode(); + elem.value = QString::fromLocal8Bit(composeValue).at(0).unicode(); ++composeValue; } #ifdef DEBUG_GENERATOR // find the comment - elem.comment = QString::fromUtf8(composeValueEnd + 1).trimmed(); + elem.comment = QString::fromLocal8Bit(composeValueEnd + 1).trimmed(); #endif // find the key sequence and convert to X11 keysym diff --git a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.h b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.h index aa65b7b895..248c09f3ea 100644 --- a/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.h +++ b/src/plugins/platforminputcontexts/compose/generator/qtablegenerator.h @@ -122,6 +122,7 @@ protected: ushort keysymToUtf8(quint32 sym); QString readLocaleMappings(const QByteArray &locale); + QByteArray readLocaleAliases(const QByteArray &locale); void initPossibleLocations(); bool cleanState() const { return ((m_state & NoErrors) == NoErrors); } QString locale() const; diff --git a/src/plugins/platforms/android/src/androidjniaccessibility.cpp b/src/plugins/platforms/android/src/androidjniaccessibility.cpp index a27d9f5aed..b987c49c9c 100644 --- a/src/plugins/platforms/android/src/androidjniaccessibility.cpp +++ b/src/plugins/platforms/android/src/androidjniaccessibility.cpp @@ -46,7 +46,7 @@ #include "qguiapplication.h" #include "qwindow.h" #include "qrect.h" -#include "private/qaccessible2_p.h" +#include "QtGui/qaccessible.h" #include "qdebug.h" diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm index f43beb1bb5..1371eb3658 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm @@ -40,8 +40,7 @@ ****************************************************************************/ #include "qcocoaaccessibility.h" #include "qcocoaaccessibilityelement.h" -#include <qaccessible.h> -#include <QtGui/private/qaccessible2_p.h> +#include <QtGui/qaccessible.h> #include <private/qcore_mac_p.h> QCocoaAccessibility::QCocoaAccessibility() diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index 7eae22f720..8e20a96a48 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -42,8 +42,7 @@ #include "qcocoaaccessibility.h" #include "qcocoahelpers.h" -#include <QAccessible> -#include <QtGui/private/qaccessible2_p.h> +#include <QtGui/qaccessible.h> #import <AppKit/NSAccessibility.h> diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h index 8a8b1d946c..16d1ffbe85 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.h @@ -82,6 +82,7 @@ public: private: void *mDelegate; + QUrl mDir; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index 1ad833ee44..08505d91a2 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -610,6 +610,8 @@ void QCocoaFileDialogHelper::setDirectory(const QUrl &directory) QNSOpenSavePanelDelegate *delegate = static_cast<QNSOpenSavePanelDelegate *>(mDelegate); if (delegate) [delegate->mSavePanel setDirectoryURL:[NSURL fileURLWithPath:QCFString::toNSString(directory.toLocalFile())]]; + else + mDir = directory; } QUrl QCocoaFileDialogHelper::directory() const @@ -619,7 +621,7 @@ QUrl QCocoaFileDialogHelper::directory() const QString path = QCFString::toQString([[delegate->mSavePanel directoryURL] path]).normalized(QString::NormalizationForm_C); return QUrl::fromLocalFile(path); } - return QUrl(); + return mDir; } void QCocoaFileDialogHelper::selectFile(const QUrl &filename) @@ -707,7 +709,7 @@ void QCocoaFileDialogHelper::createNSOpenSavePanelDelegate() QCocoaAutoReleasePool pool; const SharedPointerFileDialogOptions &opts = options(); const QList<QUrl> selectedFiles = opts->initiallySelectedFiles(); - const QUrl directory = opts->initialDirectory(); + const QUrl directory = mDir.isEmpty() ? opts->initialDirectory() : mDir; const bool selectDir = selectedFiles.isEmpty(); QString selection(selectDir ? directory.toLocalFile() : selectedFiles.front().toLocalFile()); QNSOpenSavePanelDelegate *delegate = [[QNSOpenSavePanelDelegate alloc] diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index 197a2058af..4a5696b35e 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -599,7 +599,17 @@ NSRect qt_mac_flipRect(const QRect &rect, QWindow *window) { QPlatformScreen *onScreen = QPlatformScreen::platformScreenForWindow(window); int flippedY = onScreen->geometry().height() - (rect.y() + rect.height()); - + QList<QScreen *> screens = QGuiApplication::screens(); + if (screens.size() > 1) { + int height = 0; + foreach (QScreen *scr, screens) + height = qMax(height, scr->size().height()); + int difference = height - onScreen->geometry().height(); + if (difference > 0) + flippedY += difference; + else + flippedY -= difference; + } // In case of automatic positioning, try to put as much of the window onscreen as possible. if (window->isTopLevel() && qt_window_private(const_cast<QWindow*>(window))->positionAutomatic && flippedY < 0) flippedY = onScreen->geometry().height() - onScreen->availableGeometry().height() - onScreen->availableGeometry().y(); diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 4da47f4f1f..b5b9cec2be 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -522,6 +522,20 @@ void QCocoaWindow::setWindowFlags(Qt::WindowFlags flags) if (!(styleMask & NSBorderlessWindowMask)) { setWindowTitle(window()->title()); } + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 + if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) { + Qt::WindowType type = window()->type(); + if ((type & Qt::Popup) != Qt::Popup && (type & Qt::Dialog) != Qt::Dialog) { + NSWindowCollectionBehavior behavior = [m_nsWindow collectionBehavior]; + if (flags & Qt::WindowFullscreenButtonHint) + behavior |= NSWindowCollectionBehaviorFullScreenPrimary; + else + behavior &= ~NSWindowCollectionBehaviorFullScreenPrimary; + [m_nsWindow setCollectionBehavior:behavior]; + } + } +#endif } m_windowFlags = flags; @@ -871,8 +885,6 @@ NSWindow * QCocoaWindow::createNSWindow() // before the window is shown and needs a proper window.). if ((type & Qt::Popup) == Qt::Popup) [window setHasShadow:YES]; - else - setWindowShadow(flags); [window setHidesOnDeactivate: NO]; #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 @@ -894,14 +906,6 @@ NSWindow * QCocoaWindow::createNSWindow() defer:NO]; // Deferring window creation breaks OpenGL (the GL context is set up // before the window is shown and needs a proper window.). window->m_cocoaPlatformWindow = this; - setWindowShadow(flags); - -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 - if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) { - if (flags & Qt::WindowFullscreenButtonHint) - [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; - } -#endif createdWindow = window; } diff --git a/src/plugins/platforms/cocoa/qmacclipboard.mm b/src/plugins/platforms/cocoa/qmacclipboard.mm index 95143fd8ea..b5c50d676f 100644 --- a/src/plugins/platforms/cocoa/qmacclipboard.mm +++ b/src/plugins/platforms/cocoa/qmacclipboard.mm @@ -105,7 +105,8 @@ QMacPasteboard::~QMacPasteboard() for (int i = 0; i < promises.count(); ++i) { const Promise &promise = promises.at(i); QCFString flavor = QCFString(promise.convertor->flavorFor(promise.mime)); - promiseKeeper(paste, (PasteboardItemID)promise.itemId, flavor, this); + NSInteger pbItemId = promise.itemId; + promiseKeeper(paste, reinterpret_cast<PasteboardItemID>(pbItemId), flavor, this); } if (paste) @@ -311,9 +312,9 @@ QMacPasteboard::setMimeData(QMimeData *mime_src) int numItems = c->count(mime_src); for (int item = 0; item < numItems; ++item) { - const int itemID = item+1; //id starts at 1 + const NSInteger itemID = item+1; //id starts at 1 promises.append(QMacPasteboard::Promise(itemID, c, mimeType, mimeData, item)); - PasteboardPutItemFlavor(paste, (PasteboardItemID)itemID, QCFString(flavor), 0, kPasteboardFlavorNoFlags); + PasteboardPutItemFlavor(paste, reinterpret_cast<PasteboardItemID>(itemID), QCFString(flavor), 0, kPasteboardFlavorNoFlags); #ifdef DEBUG_PASTEBOARD qDebug(" - adding %d %s [%s] <%s> [%d]", itemID, qPrintable(mimeType), qPrintable(flavor), qPrintable(c->convertorName()), item); diff --git a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm index 86e5066fbb..e8f26aa8c4 100644 --- a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm +++ b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm @@ -47,7 +47,7 @@ #include "qcocoaaccessibilityelement.h" #include <qpa/qplatformintegration.h> -#include <QtGui/private/qaccessible2_p.h> +#include <QtGui/qaccessible.h> #include <QtCore/QDebug> #import <AppKit/NSAccessibility.h> diff --git a/src/plugins/platforms/eglfs/qeglfsbackingstore.cpp b/src/plugins/platforms/eglfs/qeglfsbackingstore.cpp index 9de5960fdb..03531916cf 100644 --- a/src/plugins/platforms/eglfs/qeglfsbackingstore.cpp +++ b/src/plugins/platforms/eglfs/qeglfsbackingstore.cpp @@ -139,6 +139,7 @@ void QEglFSBackingStore::resize(const QSize &size, const QRegion &staticContents m_window->create(); rootWin->screen()->rootContext()->makeCurrent(rootWin->window()); + initializeOpenGLFunctions(); if (m_texture) glDeleteTextures(1, &m_texture); diff --git a/src/plugins/platforms/eglfs/qeglfsbackingstore.h b/src/plugins/platforms/eglfs/qeglfsbackingstore.h index 535428aac1..9af856e8e7 100644 --- a/src/plugins/platforms/eglfs/qeglfsbackingstore.h +++ b/src/plugins/platforms/eglfs/qeglfsbackingstore.h @@ -43,6 +43,7 @@ #define QEGLFSBACKINGSTORE_H #include <qpa/qplatformbackingstore.h> +#include <QtGui/QOpenGLFunctions> #include <QImage> #include <QRegion> @@ -52,7 +53,7 @@ QT_BEGIN_NAMESPACE class QOpenGLPaintDevice; class QEglFSWindow; -class QEglFSBackingStore : public QPlatformBackingStore +class QEglFSBackingStore : public QPlatformBackingStore, public QOpenGLFunctions { public: QEglFSBackingStore(QWindow *window); diff --git a/src/plugins/platforms/eglfs/qeglfscompositor.cpp b/src/plugins/platforms/eglfs/qeglfscompositor.cpp index 9db43a57a1..845bb5b3b5 100644 --- a/src/plugins/platforms/eglfs/qeglfscompositor.cpp +++ b/src/plugins/platforms/eglfs/qeglfscompositor.cpp @@ -53,7 +53,8 @@ static QEglFSCompositor *compositor = 0; QEglFSCompositor::QEglFSCompositor() : m_screen(0), - m_program(0) + m_program(0), + m_initialized(false) { Q_ASSERT(!compositor); m_updateTimer.setSingleShot(true); @@ -86,6 +87,10 @@ void QEglFSCompositor::renderAll() Q_ASSERT(context); context->makeCurrent(rootWin->window()); + if (!m_initialized) { + initializeOpenGLFunctions(); + m_initialized = true; + } ensureProgram(); m_program->bind(); diff --git a/src/plugins/platforms/eglfs/qeglfscompositor.h b/src/plugins/platforms/eglfs/qeglfscompositor.h index ade2e06031..0d5daafa2c 100644 --- a/src/plugins/platforms/eglfs/qeglfscompositor.h +++ b/src/plugins/platforms/eglfs/qeglfscompositor.h @@ -42,7 +42,8 @@ #ifndef QEGLFSCOMPOSITOR_H #define QEGLFSCOMPOSITOR_H -#include <QTimer> +#include <QtCore/QTimer> +#include <QtGui/QOpenGLFunctions> QT_BEGIN_NAMESPACE @@ -50,7 +51,7 @@ class QEglFSScreen; class QEglFSWindow; class QOpenGLShaderProgram; -class QEglFSCompositor : public QObject +class QEglFSCompositor : public QObject, public QOpenGLFunctions { Q_OBJECT @@ -76,6 +77,7 @@ private: int m_vertexCoordEntry; int m_textureCoordEntry; int m_isRasterEntry; + bool m_initialized; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/eglfs/qeglfscursor.cpp b/src/plugins/platforms/eglfs/qeglfscursor.cpp index c00e86de35..0066426769 100644 --- a/src/plugins/platforms/eglfs/qeglfscursor.cpp +++ b/src/plugins/platforms/eglfs/qeglfscursor.cpp @@ -79,7 +79,7 @@ void QEglFSCursor::resetResources() m_cursorAtlas.texture = 0; } -static GLuint createShader(GLenum shaderType, const char *program) +GLuint QEglFSCursor::createShader(GLenum shaderType, const char *program) { GLuint shader = glCreateShader(shaderType); glShaderSource(shader, 1 /* count */, &program, NULL /* lengths */); @@ -98,7 +98,7 @@ static GLuint createShader(GLenum shaderType, const char *program) return 0; } -static GLuint createProgram(GLuint vshader, GLuint fshader) +GLuint QEglFSCursor::createProgram(GLuint vshader, GLuint fshader) { GLuint program = glCreateProgram(); glAttachShader(program, vshader); @@ -286,6 +286,7 @@ void QEglFSCursor::draw(const QRectF &r) { if (!m_program) { // one time initialization + initializeOpenGLFunctions(); createShaderPrograms(); if (!m_cursorAtlas.texture) { diff --git a/src/plugins/platforms/eglfs/qeglfscursor.h b/src/plugins/platforms/eglfs/qeglfscursor.h index 51a34e041d..71ff73b8f3 100644 --- a/src/plugins/platforms/eglfs/qeglfscursor.h +++ b/src/plugins/platforms/eglfs/qeglfscursor.h @@ -43,15 +43,15 @@ #define QEGLFSCURSOR_H #include <qpa/qplatformcursor.h> +#include <QtGui/QOpenGLFunctions> #include "qeglfsscreen.h" -#include <GLES2/gl2.h> QT_BEGIN_NAMESPACE class QOpenGLShaderProgram; class QEglFSScreen; -class QEglFSCursor : public QPlatformCursor +class QEglFSCursor : public QPlatformCursor, public QOpenGLFunctions { public: QEglFSCursor(QEglFSScreen *screen); @@ -78,6 +78,9 @@ protected: void draw(const QRectF &rect); void update(const QRegion ®ion); + GLuint createShader(GLenum shaderType, const char *program); + GLuint createProgram(GLuint vshader, GLuint fshader); + QEglFSScreen *m_screen; // current cursor information diff --git a/src/plugins/platforms/kms/qkmsbackingstore.cpp b/src/plugins/platforms/kms/qkmsbackingstore.cpp index 29395f3b4f..fa4ef847cd 100644 --- a/src/plugins/platforms/kms/qkmsbackingstore.cpp +++ b/src/plugins/platforms/kms/qkmsbackingstore.cpp @@ -52,6 +52,7 @@ QKmsBackingStore::QKmsBackingStore(QWindow *window) , m_context(new QOpenGLContext) , m_texture(0) , m_program(0) + , m_initialized(false) { m_context->setFormat(window->requestedFormat()); m_context->setScreen(window->screen()); @@ -85,6 +86,11 @@ void QKmsBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoin m_context->makeCurrent(window); + if (!m_initialized) { + initializeOpenGLFunctions(); + m_initialized = true; + } + if (!m_program) { static const char *textureVertexProgram = "attribute highp vec2 vertexCoordEntry;\n" diff --git a/src/plugins/platforms/kms/qkmsbackingstore.h b/src/plugins/platforms/kms/qkmsbackingstore.h index 34ea49a346..c5f6c81d18 100644 --- a/src/plugins/platforms/kms/qkmsbackingstore.h +++ b/src/plugins/platforms/kms/qkmsbackingstore.h @@ -43,6 +43,7 @@ #define QBACKINGSTORE_KMS_H #include <qpa/qplatformbackingstore.h> +#include <QtGui/QOpenGLFunctions> #include <QImage> QT_BEGIN_NAMESPACE @@ -50,7 +51,7 @@ QT_BEGIN_NAMESPACE class QOpenGLContext; class QOpenGLShaderProgram; -class QKmsBackingStore : public QPlatformBackingStore +class QKmsBackingStore : public QPlatformBackingStore, public QOpenGLFunctions { public: QKmsBackingStore(QWindow *window); @@ -69,6 +70,7 @@ private: uint m_texture; QOpenGLShaderProgram *m_program; QRegion m_dirty; + bool m_initialized; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/kms/qkmsscreen.h b/src/plugins/platforms/kms/qkmsscreen.h index a90d6fa051..f0c49ad11c 100644 --- a/src/plugins/platforms/kms/qkmsscreen.h +++ b/src/plugins/platforms/kms/qkmsscreen.h @@ -55,8 +55,7 @@ extern "C" { #include <EGL/egl.h> #include <EGL/eglext.h> -#include <GLES2/gl2.h> -#include <GLES2/gl2ext.h> +#include <QtGui/qopengl.h> #include <qpa/qplatformscreen.h> diff --git a/src/plugins/platforms/qnx/qqnxglcontext.h b/src/plugins/platforms/qnx/qqnxglcontext.h index ff57861498..2b12657da9 100644 --- a/src/plugins/platforms/qnx/qqnxglcontext.h +++ b/src/plugins/platforms/qnx/qqnxglcontext.h @@ -75,6 +75,8 @@ public: static EGLDisplay getEglDisplay(); EGLConfig getEglConfig() const { return m_eglConfig;} + EGLContext getEglContext() const { return m_eglContext; } + private: //Can be static because different displays returne the same handle static EGLDisplay ms_eglDisplay; diff --git a/src/plugins/platforms/qnx/qqnxnativeinterface.cpp b/src/plugins/platforms/qnx/qqnxnativeinterface.cpp index 24af5c2683..e468b051cd 100644 --- a/src/plugins/platforms/qnx/qqnxnativeinterface.cpp +++ b/src/plugins/platforms/qnx/qqnxnativeinterface.cpp @@ -41,9 +41,11 @@ #include "qqnxnativeinterface.h" +#include "qqnxglcontext.h" #include "qqnxscreen.h" #include "qqnxwindow.h" +#include <QtGui/QOpenGLContext> #include <QtGui/QScreen> #include <QtGui/QWindow> @@ -73,6 +75,14 @@ void *QQnxNativeInterface::nativeResourceForScreen(const QByteArray &resource, Q return 0; } +void *QQnxNativeInterface::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) +{ + if (resource == "eglcontext" && context) + return static_cast<QQnxGLContext*>(context->handle())->getEglContext(); + + return 0; +} + void QQnxNativeInterface::setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value) { if (name == QStringLiteral("mmRendererWindowName")) { diff --git a/src/plugins/platforms/qnx/qqnxnativeinterface.h b/src/plugins/platforms/qnx/qqnxnativeinterface.h index b61f6a56cc..dfd386214e 100644 --- a/src/plugins/platforms/qnx/qqnxnativeinterface.h +++ b/src/plugins/platforms/qnx/qqnxnativeinterface.h @@ -51,6 +51,7 @@ class QQnxNativeInterface : public QPlatformNativeInterface public: void *nativeResourceForWindow(const QByteArray &resource, QWindow *window); void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen); + void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context); void setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value); }; diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.cpp b/src/plugins/platforms/windows/accessible/iaccessible2.cpp index 9170c774b4..66ed9d85dc 100644 --- a/src/plugins/platforms/windows/accessible/iaccessible2.cpp +++ b/src/plugins/platforms/windows/accessible/iaccessible2.cpp @@ -44,7 +44,7 @@ #include "iaccessible2.h" #include "qwindowsaccessibility.h" -#include <QtGui/private/qaccessible2_p.h> +#include <QtGui/qaccessible.h> #include <QtGui/qclipboard.h> #include <QtWidgets/qapplication.h> #include <QtCore/qdebug.h> diff --git a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp index 63b4370dc2..885bc37cff 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp +++ b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp @@ -51,7 +51,6 @@ #include <QtCore/qpointer.h> #include <QtCore/qsettings.h> #include <QtGui/qaccessible.h> -#include <QtGui/private/qaccessible2_p.h> #include <QtGui/private/qguiapplication_p.h> #include <qpa/qplatformnativeinterface.h> #include <qpa/qplatformintegration.h> diff --git a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp index 93592eb969..8bb7646258 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp +++ b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp @@ -54,7 +54,6 @@ #include <QtCore/qpair.h> #include <QtCore/qsettings.h> #include <QtGui/qaccessible.h> -#include <QtGui/private/qaccessible2_p.h> #include <QtGui/qguiapplication.h> #include <qpa/qplatformnativeinterface.h> #include <QtGui/qwindow.h> diff --git a/src/plugins/platforms/windows/qwindowsbackingstore.cpp b/src/plugins/platforms/windows/qwindowsbackingstore.cpp index 26205eb146..55e7b85d96 100644 --- a/src/plugins/platforms/windows/qwindowsbackingstore.cpp +++ b/src/plugins/platforms/windows/qwindowsbackingstore.cpp @@ -149,7 +149,23 @@ void QWindowsBackingStore::resize(const QSize &size, const QRegion ®ion) QImage::Format format = QWindowsNativeImage::systemFormat(); if (format == QImage::Format_RGB32 && rasterWindow()->window()->format().hasAlpha()) format = QImage::Format_ARGB32_Premultiplied; - m_image.reset(new QWindowsNativeImage(size.width(), size.height(), format)); + + QWindowsNativeImage *oldwni = m_image.data(); + QWindowsNativeImage *newwni = new QWindowsNativeImage(size.width(), size.height(), format); + + if (oldwni && !region.isEmpty()) { + const QImage &oldimg(oldwni->image()); + QImage &newimg(newwni->image()); + QRegion staticRegion(region); + staticRegion &= QRect(0, 0, oldimg.width(), oldimg.height()); + staticRegion &= QRect(0, 0, newimg.width(), newimg.height()); + QPainter painter(&newimg); + painter.setCompositionMode(QPainter::CompositionMode_Source); + foreach (const QRect &rect, staticRegion.rects()) + painter.drawImage(rect, oldimg, rect); + } + + m_image.reset(newwni); } } diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp index ac57a1b396..6c928119b3 100644 --- a/src/plugins/platforms/windows/qwindowsfontengine.cpp +++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp @@ -161,12 +161,18 @@ bool QWindowsFontEngine::hasCFFTable() const return GetFontData(hdc, MAKE_TAG('C', 'F', 'F', ' '), 0, 0, 0) != GDI_ERROR; } +bool QWindowsFontEngine::hasCMapTable() const +{ + HDC hdc = m_fontEngineData->hdc; + SelectObject(hdc, hfont); + return GetFontData(hdc, MAKE_TAG('c', 'm', 'a', 'p'), 0, 0, 0) != GDI_ERROR; +} + void QWindowsFontEngine::getCMap() { - ttf = (bool)(tm.tmPitchAndFamily & TMPF_TRUETYPE); + ttf = (bool)(tm.tmPitchAndFamily & TMPF_TRUETYPE) || hasCMapTable(); - // TMPF_TRUETYPE is not set for fonts with CFF tables - cffTable = !ttf && hasCFFTable(); + cffTable = hasCFFTable(); HDC hdc = m_fontEngineData->hdc; SelectObject(hdc, hfont); @@ -374,6 +380,7 @@ HGDIOBJ QWindowsFontEngine::selectDesignFont() const { LOGFONT f = m_logfont; f.lfHeight = unitsPerEm; + f.lfWidth = 0; HFONT designFont = CreateFontIndirect(&f); return SelectObject(m_fontEngineData->hdc, designFont); } diff --git a/src/plugins/platforms/windows/qwindowsfontengine.h b/src/plugins/platforms/windows/qwindowsfontengine.h index d783b6048c..acf84d270c 100644 --- a/src/plugins/platforms/windows/qwindowsfontengine.h +++ b/src/plugins/platforms/windows/qwindowsfontengine.h @@ -140,6 +140,7 @@ private: QWindowsNativeImage *drawGDIGlyph(HFONT font, glyph_t, int margin, const QTransform &xform, QImage::Format mask_format); bool hasCFFTable() const; + bool hasCMapTable() const; const QSharedPointer<QWindowsFontEngineData> m_fontEngineData; diff --git a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp index 7407d88f8b..d81848fcc7 100644 --- a/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp +++ b/src/plugins/platforms/windows/qwindowsfontenginedirectwrite.cpp @@ -276,7 +276,7 @@ bool QWindowsFontEngineDirectWrite::getSfntTableData(uint tag, uchar *buffer, ui UINT32 tableSize; void *tableContext = 0; BOOL exists; - HRESULT hr = m_directWriteFontFace->TryGetFontTable(qbswap<quint32>(tag) + HRESULT hr = m_directWriteFontFace->TryGetFontTable(qbswap<quint32>(tag), &tableData, &tableSize, &tableContext, &exists); if (SUCCEEDED(hr)) { diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp index d1ede39549..b7de368fa8 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp @@ -589,7 +589,7 @@ static HGLRC createContext(const QOpenGLStaticContext &staticContext, if (requestedVersion >= 0x0300) { attributes[attribIndex++] = WGL_CONTEXT_FLAGS_ARB; attributes[attribIndex] = 0; - if (format.testOption(QSurfaceFormat::DeprecatedFunctions)) + if (!format.testOption(QSurfaceFormat::DeprecatedFunctions)) attributes[attribIndex] |= WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB; if (format.testOption(QSurfaceFormat::DebugContext)) attributes[attribIndex] |= WGL_CONTEXT_DEBUG_BIT_ARB; diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index d2fb481824..58047124a1 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1500,6 +1500,8 @@ void QWindowsWindow::handleWindowStateChange(Qt::WindowState state) handleHidden(); QWindowSystemInterface::flushWindowSystemEvents(); // Tell QQuickWindow to stop rendering now. break; + case Qt::WindowMaximized: + case Qt::WindowFullScreen: case Qt::WindowNoState: { // QTBUG-17548: We send expose events when receiving WM_Paint, but for // layered windows and transient children, we won't receive any WM_Paint. diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index aeda1e11d1..7d69564c57 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -76,7 +76,7 @@ static int resourceType(const QByteArray &key) static const QByteArray names[] = { // match QXcbNativeInterface::ResourceType QByteArrayLiteral("display"), QByteArrayLiteral("egldisplay"), QByteArrayLiteral("connection"), QByteArrayLiteral("screen"), - QByteArrayLiteral("graphicsdevice"), QByteArrayLiteral("eglcontext"), + QByteArrayLiteral("eglcontext"), QByteArrayLiteral("glxcontext"), QByteArrayLiteral("apptime"), QByteArrayLiteral("appusertime"), QByteArrayLiteral("hintstyle"), QByteArrayLiteral("startupid"), QByteArrayLiteral("traywindow"), @@ -212,7 +212,7 @@ void *QXcbNativeInterface::nativeResourceForWindow(const QByteArray &resourceStr result = connectionForWindow(window); break; case Screen: - result = qPlatformScreenForWindow(window); + result = screenForWindow(window); break; default: break; diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h index aec78087f5..9c4fa44d3b 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.h +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h @@ -62,7 +62,6 @@ public: EglDisplay, Connection, Screen, - GraphicsDevice, EglContext, GLXContext, AppTime, @@ -90,7 +89,6 @@ public: void *eglDisplayForWindow(QWindow *window); void *connectionForWindow(QWindow *window); void *screenForWindow(QWindow *window); - void *graphicsDeviceForWindow(QWindow *window); void *appTime(const QXcbScreen *screen); void *appUserTime(const QXcbScreen *screen); void *getTimestamp(const QXcbScreen *screen); diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index dd404d044d..e2c6932992 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -154,7 +154,7 @@ enum QX11EmbedMessageType { XEMBED_ACTIVATE_ACCELERATOR = 14 }; -const long XEMBED_VERSION = 0; +const quint32 XEMBED_VERSION = 0; // Returns \c true if we should set WM_TRANSIENT_FOR on \a w static inline bool isTransient(const QWindow *w) @@ -403,7 +403,7 @@ void QXcbWindow::create() } // set the PID to let the WM kill the application if unresponsive - long pid = getpid(); + quint32 pid = getpid(); Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::_NET_WM_PID), XCB_ATOM_CARDINAL, 32, 1, &pid)); @@ -422,7 +422,7 @@ void QXcbWindow::create() 1, &leader)); /* Add XEMBED info; this operation doesn't initiate the embedding. */ - long data[] = { XEMBED_VERSION, XEMBED_MAPPED }; + quint32 data[] = { XEMBED_VERSION, XEMBED_MAPPED }; Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::_XEMBED_INFO), atom(QXcbAtom::_XEMBED_INFO), @@ -1824,7 +1824,7 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev xcb_get_property_reply(xcb_connection(), get_cookie, NULL); if (reply && reply->format == 32 && reply->type == wmStateAtom) { - const long *data = (const long *)xcb_get_property_value(reply); + const quint32 *data = (const quint32 *)xcb_get_property_value(reply); if (reply->length != 0 && XCB_WM_STATE_ICONIC == data[0]) newState = Qt::WindowMinimized; } @@ -1995,8 +1995,8 @@ bool QXcbWindow::startSystemResize(const QPoint &pos, Qt::Corner corner) } // Sends an XEmbed message. -void QXcbWindow::sendXEmbedMessage(xcb_window_t window, long message, - long detail, long data1, long data2) +void QXcbWindow::sendXEmbedMessage(xcb_window_t window, quint32 message, + quint32 detail, quint32 data1, quint32 data2) { xcb_client_message_event_t event; diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 5601a115e9..45d44b213f 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -169,8 +169,8 @@ private: void updateDoesNotAcceptFocus(bool doesNotAcceptFocus); QRect windowToWmGeometry(QRect r) const; - void sendXEmbedMessage(xcb_window_t window, long message, - long detail = 0, long data1 = 0, long data2 = 0); + void sendXEmbedMessage(xcb_window_t window, quint32 message, + quint32 detail = 0, quint32 data1 = 0, quint32 data2 = 0); void handleXEmbedMessage(const xcb_client_message_event_t *event); void create(); diff --git a/src/plugins/platforms/xcb/xcb-plugin.pro b/src/plugins/platforms/xcb/xcb-plugin.pro index 4f69ca8aab..49a1c1b320 100644 --- a/src/plugins/platforms/xcb/xcb-plugin.pro +++ b/src/plugins/platforms/xcb/xcb-plugin.pro @@ -81,15 +81,7 @@ contains(QT_CONFIG, xcb-sm) { } contains(QT_CONFIG, opengl) { - contains(QT_CONFIG, opengles2) { - DEFINES += XCB_USE_EGL - CONFIG += egl - HEADERS += qxcbeglsurface.h - - # EGL on MeeGo 1.2 Harmattan needs this macro to map EGLNativeDisplayType - # and other types to the correct X11 types - DEFINES += SUPPORT_X11 - } else:contains(QT_CONFIG, xcb-xlib) { + contains(QT_CONFIG, xcb-xlib):contains(QT_CONFIG, glx) { DEFINES += XCB_USE_GLX HEADERS += qglxintegration.h SOURCES += qglxintegration.cpp @@ -98,6 +90,14 @@ contains(QT_CONFIG, opengl) { DEFINES += XCB_HAS_XCB_GLX LIBS += -lxcb-glx } + } else:contains(QT_CONFIG, egl) { + DEFINES += XCB_USE_EGL + CONFIG += egl + HEADERS += qxcbeglsurface.h + + # EGL on MeeGo 1.2 Harmattan needs this macro to map EGLNativeDisplayType + # and other types to the correct X11 types + DEFINES += SUPPORT_X11 } } diff --git a/src/printsupport/dialogs/qprintdialog_win.cpp b/src/printsupport/dialogs/qprintdialog_win.cpp index 96a201ae45..6f96a499e5 100644 --- a/src/printsupport/dialogs/qprintdialog_win.cpp +++ b/src/printsupport/dialogs/qprintdialog_win.cpp @@ -187,7 +187,7 @@ QPrintDialog::QPrintDialog(QPrinter *printer, QWidget *parent) Q_D(QPrintDialog); if (!warnIfNotNative(d->printer)) return; - d->ep = static_cast<QWin32PrintEngine *>(d->printer->paintEngine())->d_func(); + d->ep = static_cast<QWin32PrintEngine *>(d->printer->printEngine())->d_func(); setAttribute(Qt::WA_DontShowOnScreen); } @@ -197,7 +197,7 @@ QPrintDialog::QPrintDialog(QWidget *parent) Q_D(QPrintDialog); if (!warnIfNotNative(d->printer)) return; - d->ep = static_cast<QWin32PrintEngine *>(d->printer->paintEngine())->d_func(); + d->ep = static_cast<QWin32PrintEngine *>(d->printer->printEngine())->d_func(); setAttribute(Qt::WA_DontShowOnScreen); } diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp index 0905cbb59f..819f9343f7 100644 --- a/src/printsupport/kernel/qprinter.cpp +++ b/src/printsupport/kernel/qprinter.cpp @@ -55,10 +55,7 @@ #include <private/qpagedpaintdevice_p.h> - -#ifndef QT_NO_PDF #include "qprintengine_pdf_p.h" -#endif #include <qpicture.h> #include <private/qpaintengine_preview_p.h> @@ -618,8 +615,6 @@ QPrinter::~QPrinter() */ void QPrinter::setOutputFormat(OutputFormat format) { - -#ifndef QT_NO_PDF Q_D(QPrinter); if (d->validPrinter && d->outputFormat == format) return; @@ -651,9 +646,6 @@ void QPrinter::setOutputFormat(OutputFormat format) if (d->outputFormat == QPrinter::PdfFormat) d->validPrinter = true; -#else - Q_UNUSED(format); -#endif } /*! diff --git a/src/printsupport/kernel/qprinterinfo.cpp b/src/printsupport/kernel/qprinterinfo.cpp index f863b23e34..e02617fe93 100644 --- a/src/printsupport/kernel/qprinterinfo.cpp +++ b/src/printsupport/kernel/qprinterinfo.cpp @@ -35,8 +35,17 @@ QT_BEGIN_NAMESPACE -QPrinterInfoPrivate QPrinterInfoPrivate::shared_null; +Q_GLOBAL_STATIC(QPrinterInfoPrivate, shared_null); +class QPrinterInfoPrivateDeleter +{ +public: + static inline void cleanup(QPrinterInfoPrivate *d) + { + if (d != shared_null) + delete d; + } +}; /*! \class QPrinterInfo @@ -83,7 +92,7 @@ QPrinterInfoPrivate QPrinterInfoPrivate::shared_null; \sa isNull() */ QPrinterInfo::QPrinterInfo() - : d_ptr(&QPrinterInfoPrivate::shared_null) + : d_ptr(shared_null) { } @@ -91,7 +100,7 @@ QPrinterInfo::QPrinterInfo() Constructs a copy of \a other. */ QPrinterInfo::QPrinterInfo(const QPrinterInfo &other) - : d_ptr(new QPrinterInfoPrivate(*other.d_ptr)) + : d_ptr((other.d_ptr.data() == shared_null) ? shared_null : new QPrinterInfoPrivate(*other.d_ptr)) { } @@ -99,12 +108,15 @@ QPrinterInfo::QPrinterInfo(const QPrinterInfo &other) Constructs a QPrinterInfo object from \a printer. */ QPrinterInfo::QPrinterInfo(const QPrinter &printer) - : d_ptr(&QPrinterInfoPrivate::shared_null) + : d_ptr(shared_null) { QPlatformPrinterSupport *ps = QPlatformPrinterSupportPlugin::get(); if (ps) { QPrinterInfo pi = ps->printerInfo(printer.printerName()); - d_ptr.reset(new QPrinterInfoPrivate(*pi.d_ptr)); + if (pi.d_ptr.data() == shared_null) + d_ptr.reset(shared_null); + else + d_ptr.reset(new QPrinterInfoPrivate(*pi.d_ptr)); } } @@ -130,7 +142,10 @@ QPrinterInfo::~QPrinterInfo() QPrinterInfo &QPrinterInfo::operator=(const QPrinterInfo &other) { Q_ASSERT(d_ptr); - d_ptr.reset(new QPrinterInfoPrivate(*other.d_ptr)); + if (other.d_ptr.data() == shared_null) + d_ptr.reset(shared_null); + else + d_ptr.reset(new QPrinterInfoPrivate(*other.d_ptr)); return *this; } @@ -191,7 +206,7 @@ QString QPrinterInfo::makeAndModel() const bool QPrinterInfo::isNull() const { Q_D(const QPrinterInfo); - return d == &QPrinterInfoPrivate::shared_null; + return d == shared_null || d->name.isEmpty(); } /*! diff --git a/src/printsupport/kernel/qprinterinfo_p.h b/src/printsupport/kernel/qprinterinfo_p.h index d4bb08f1f5..6ae64b5653 100644 --- a/src/printsupport/kernel/qprinterinfo_p.h +++ b/src/printsupport/kernel/qprinterinfo_p.h @@ -72,8 +72,6 @@ public: ~QPrinterInfoPrivate() {} - static QPrinterInfoPrivate shared_null; - QString name; QString description; QString location; @@ -87,17 +85,6 @@ public: mutable QList<QPair<QString, QSizeF> > paperNames; }; - -class QPrinterInfoPrivateDeleter -{ -public: - static inline void cleanup(QPrinterInfoPrivate *d) - { - if (d != &QPrinterInfoPrivate::shared_null) - delete d; - } -}; - QT_END_NAMESPACE #endif // QT_NO_PRINTER diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp index 0e20cf539e..1b1cb2ac91 100644 --- a/src/sql/drivers/mysql/qsql_mysql.cpp +++ b/src/sql/drivers/mysql/qsql_mysql.cpp @@ -857,7 +857,7 @@ static MYSQL_TIME *toMySqlDate(QDate date, QTime time, QVariant::Type type) myTime->hour = time.hour(); myTime->minute = time.minute(); myTime->second = time.second(); - myTime->second_part = time.msec(); + myTime->second_part = time.msec() * 1000; } if (type == QVariant::Date || type == QVariant::DateTime) { myTime->year = date.year(); diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/sqlite/qsql_sqlite.cpp index 0a8b71aa8a..27bc80e63f 100644 --- a/src/sql/drivers/sqlite/qsql_sqlite.cpp +++ b/src/sql/drivers/sqlite/qsql_sqlite.cpp @@ -42,6 +42,7 @@ #include "qsql_sqlite_p.h" #include <qcoreapplication.h> +#include <qdatetime.h> #include <qvariant.h> #include <qsqlerror.h> #include <qsqlfield.h> @@ -447,6 +448,20 @@ bool QSQLiteResult::exec() case QVariant::LongLong: res = sqlite3_bind_int64(d->stmt, i + 1, value.toLongLong()); break; + case QVariant::DateTime: { + const QDateTime dateTime = value.toDateTime(); + const QString str = dateTime.toString(QStringLiteral("yyyy-MM-ddThh:mm:ss.zzz")); + res = sqlite3_bind_text16(d->stmt, i + 1, str.utf16(), + str.size() * sizeof(ushort), SQLITE_TRANSIENT); + break; + } + case QVariant::Time: { + const QTime time = value.toTime(); + const QString str = time.toString(QStringLiteral("hh:mm:ss.zzz")); + res = sqlite3_bind_text16(d->stmt, i + 1, str.utf16(), + str.size() * sizeof(ushort), SQLITE_TRANSIENT); + break; + } case QVariant::String: { // lifetime of string == lifetime of its qvariant const QString *str = static_cast<const QString*>(value.constData()); diff --git a/src/widgets/doc/snippets/code/src_gui_widgets_qlabel.cpp b/src/widgets/doc/snippets/code/src_gui_widgets_qlabel.cpp index 7263a72302..c7dd00407d 100644 --- a/src/widgets/doc/snippets/code/src_gui_widgets_qlabel.cpp +++ b/src/widgets/doc/snippets/code/src_gui_widgets_qlabel.cpp @@ -47,18 +47,18 @@ label->setAlignment(Qt::AlignBottom | Qt::AlignRight); //! [1] -QLineEdit* phoneEdit = new QLineEdit(this); -QLabel* phoneLabel = new QLabel("&Phone:", this); +QLineEdit *phoneEdit = new QLineEdit(this); +QLabel *phoneLabel = new QLabel("&Phone:", this); phoneLabel->setBuddy(phoneEdit); //! [1] //! [2] -QLineEdit *nameEd = new QLineEdit(this); -QLabel *nameLb = new QLabel("&Name:", this); -nameLb->setBuddy(nameEd); -QLineEdit *phoneEd = new QLineEdit(this); -QLabel *phoneLb = new QLabel("&Phone:", this); -phoneLb->setBuddy(phoneEd); +QLineEdit *nameEdit = new QLineEdit(this); +QLabel *nameLabel = new QLabel("&Name:", this); +nameLabel->setBuddy(nameEdit); +QLineEdit *phoneEdit = new QLineEdit(this); +QLabel *phoneLabel = new QLabel("&Phone:", this); +phoneLabel->setBuddy(phoneEdit); // (layout setup not shown) //! [2] diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index fffc805637..04047d8d0a 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -10310,7 +10310,9 @@ void QGraphicsTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) QVariant QGraphicsTextItem::inputMethodQuery(Qt::InputMethodQuery query) const { QVariant v; - if (dd->control) + if (query == Qt::ImHints) + v = int(inputMethodHints()); + else if (dd->control) v = dd->control->inputMethodQuery(query); if (v.type() == QVariant::RectF) v = v.toRectF().translated(-dd->controlOffset()); diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index ad7a82518e..41d4fc925a 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -4147,8 +4147,9 @@ void QGraphicsScene::wheelEvent(QGraphicsSceneWheelEvent *wheelEvent) wheelEvent->widget())); wheelEvent->accept(); bool isPanel = item->isPanel(); - d->sendEvent(item, wheelEvent); - if (isPanel || wheelEvent->isAccepted()) + bool ret = d->sendEvent(item, wheelEvent); + + if (ret && (isPanel || wheelEvent->isAccepted())) break; } } diff --git a/src/widgets/graphicsview/qgraphicswidget_p.cpp b/src/widgets/graphicsview/qgraphicswidget_p.cpp index 14cd7007ba..e1dd23f177 100644 --- a/src/widgets/graphicsview/qgraphicswidget_p.cpp +++ b/src/widgets/graphicsview/qgraphicswidget_p.cpp @@ -90,11 +90,6 @@ qreal QGraphicsWidgetPrivate::titleBarHeight(const QStyleOptionTitleBar &options { Q_Q(const QGraphicsWidget); int height = q->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options); -#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC) - if (qobject_cast<QMacStyle*>(q->style())) { - height -=4; - } -#endif return (qreal)height; } diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index c2bcc1585f..75a513fb67 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -1599,7 +1599,7 @@ int QHeaderView::minimumSectionSize() const void QHeaderView::setMinimumSectionSize(int size) { Q_D(QHeaderView); - if (size < 0 || size > maxSizeSection) + if (size < -1 || size > maxSizeSection) return; d->minimumSectionSize = size; if (d->minimumSectionSize > maximumSectionSize()) diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 4e3ecf144a..9056ffe461 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3761,6 +3761,16 @@ void QApplicationPrivate::giveFocusAccordingToFocusPolicy(QWidget *widget, QEven } if (focusWidget->isWindow()) break; + + // find out whether this widget (or its proxy) already has focus + QWidget *f = focusWidget; + if (focusWidget->d_func()->extra && focusWidget->d_func()->extra->focus_proxy) + f = focusWidget->d_func()->extra->focus_proxy; + // if it has, stop here. + // otherwise a click on the focused widget would remove its focus if ClickFocus isn't set + if (f->hasFocus()) + break; + localPos += focusWidget->pos(); focusWidget = focusWidget->parentWidget(); } diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index e1376c754f..c1d3e95e7a 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -641,7 +641,7 @@ static inline int spacingHelper(QWidget* parent, QStyle *style, int userVSpacing spacing = qMax(spacing, prevItem2->geometry().top() - wid->geometry().top() ); } } - return spacing; + return qMax(spacing, 0); } static inline void initLayoutStruct(QLayoutStruct& sl, QFormLayoutItem* item) diff --git a/src/widgets/kernel/qwidgetbackingstore_p.h b/src/widgets/kernel/qwidgetbackingstore_p.h index 39583c8caa..b6c3e13cb0 100644 --- a/src/widgets/kernel/qwidgetbackingstore_p.h +++ b/src/widgets/kernel/qwidgetbackingstore_p.h @@ -240,7 +240,13 @@ private: } inline bool hasStaticContents() const - { return !staticWidgets.isEmpty() && false; } + { +#if defined(Q_OS_WIN) + return !staticWidgets.isEmpty(); +#else + return !staticWidgets.isEmpty() && false; +#endif + } friend QRegion qt_dirtyRegion(QWidget *); friend class QWidgetPrivate; diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index e977ab3d6f..2e96247873 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -251,7 +251,9 @@ bool QWidgetWindow::event(QEvent *event) case QEvent::Show: case QEvent::Hide: return QWindow::event(event); - + case QEvent::WindowBlocked: + qt_button_down = 0; + break; default: break; } diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp index 7c319c5095..399f089e0f 100644 --- a/src/widgets/kernel/qwindowcontainer.cpp +++ b/src/widgets/kernel/qwindowcontainer.cpp @@ -222,6 +222,11 @@ void QWindowContainer::focusWindowChanged(QWindow *focusWindow) { Q_D(QWindowContainer); d->oldFocusWindow = focusWindow; + if (focusWindow == d->window) { + QWidget *widget = QApplication::focusWidget(); + if (widget) + widget->clearFocus(); + } } /*! diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 0b860450d1..5db4801c37 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -2191,7 +2191,6 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW HIRect rect; ptrHIShapeGetBounds(region, &rect); ret = int(rect.size.height); - ret += 4; } break; case PM_TabBarTabVSpace: @@ -3791,7 +3790,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter } else if (!(tabOpt->state & State_Enabled)) { tdi.style = kThemeTabNonFrontInactive; } else if (tabOpt->state & State_Sunken) { - tdi.style = kThemeTabFrontInactive; // (should be kThemeTabNonFrontPressed) + tdi.style = kThemeTabNonFrontPressed; } if (tabOpt->state & State_HasFocus) tdi.adornment = kHIThemeTabAdornmentFocus; @@ -3866,8 +3865,9 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter ThemeTabDirection ttd = getTabDirection(myTab.shape); bool verticalTabs = ttd == kThemeTabWest || ttd == kThemeTabEast; bool selected = (myTab.state & QStyle::State_Selected); + bool usingModernOSX = QSysInfo::MacintoshVersion > QSysInfo::MV_10_6; - if (selected && !myTab.documentMode) + if (usingModernOSX && selected && !myTab.documentMode) myTab.palette.setColor(QPalette::WindowText, QColor(Qt::white)); // Check to see if we use have the same as the system font @@ -3875,7 +3875,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter // outside world, unless they read the source, in which case, it's // their own fault). bool nonDefaultFont = p->font() != qt_app_fonts_hash()->value("QComboMenuItem"); - if (selected || verticalTabs || nonDefaultFont || !tab->icon.isNull() + if ((usingModernOSX && selected) || verticalTabs || nonDefaultFont || !tab->icon.isNull() || !myTab.leftButtonSize.isNull() || !myTab.rightButtonSize.isNull()) { int heightOffset = 0; if (verticalTabs) { @@ -3886,7 +3886,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter } myTab.rect.setHeight(myTab.rect.height() + heightOffset); - if (myTab.documentMode || selected) { + if (myTab.documentMode || (usingModernOSX && selected)) { p->save(); rotateTabPainter(p, myTab.shape, myTab.rect); diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp index 8b151e65bd..46929397a0 100644 --- a/src/widgets/widgets/qdockwidget.cpp +++ b/src/widgets/widgets/qdockwidget.cpp @@ -455,14 +455,6 @@ int QDockWidgetLayout::titleHeight() const perp(verticalTitleBar, floatSize)); QFontMetrics titleFontMetrics = q->fontMetrics(); -#ifdef Q_WS_MAC - if (qobject_cast<QMacStyle *>(q->style())) { - //### this breaks on proxy styles. (But is this code still called?) - QFont font = qt_app_fonts_hash()->value("QToolButton", q->font()); - titleFontMetrics = QFontMetrics(font); - } -#endif - int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q); return qMax(buttonHeight + 2, titleFontMetrics.height() + 2*mw); diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp index db39ceb08a..c056967cf7 100644 --- a/src/widgets/widgets/qkeysequenceedit.cpp +++ b/src/widgets/widgets/qkeysequenceedit.cpp @@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_KEYSEQUENCEEDIT +Q_STATIC_ASSERT(QKeySequencePrivate::MaxKeyCount == 4); // assumed by the code around here + void QKeySequenceEditPrivate::init() { Q_Q(QKeySequenceEdit); @@ -222,15 +224,7 @@ void QKeySequenceEdit::setKeySequence(const QKeySequence &keySequence) */ void QKeySequenceEdit::clear() { - Q_D(QKeySequenceEdit); - - d->resetState(); - - d->lineEdit->clear(); - d->keySequence = QKeySequence(); - d->keyNum = d->key[0] = d->key[1] = d->key[2] = d->key[3] = 0; - d->prevKey = -1; - emit keySequenceChanged(d->keySequence); + setKeySequence(QKeySequence()); } /*! @@ -280,7 +274,7 @@ void QKeySequenceEdit::keyPressEvent(QKeyEvent *e) return; } - if (d->keyNum >= QKeySequenceEditPrivate::MaxKeyCount) + if (d->keyNum >= QKeySequencePrivate::MaxKeyCount) return; nextKey |= d->translateModifiers(e->modifiers(), e->text()); @@ -291,7 +285,7 @@ void QKeySequenceEdit::keyPressEvent(QKeyEvent *e) QKeySequence key(d->key[0], d->key[1], d->key[2], d->key[3]); d->keySequence = key; QString text = key.toString(QKeySequence::NativeText); - if (d->keyNum < QKeySequenceEditPrivate::MaxKeyCount) { + if (d->keyNum < QKeySequencePrivate::MaxKeyCount) { //: This text is an "unfinished" shortcut, expands like "Ctrl+A, ..." text = tr("%1, ...").arg(text); } @@ -307,7 +301,7 @@ void QKeySequenceEdit::keyReleaseEvent(QKeyEvent *e) Q_D(QKeySequenceEdit); if (d->prevKey == e->key()) { - if (d->keyNum < QKeySequenceEditPrivate::MaxKeyCount) + if (d->keyNum < QKeySequencePrivate::MaxKeyCount) d->releaseTimer = startTimer(1000); else d->finishEditing(); diff --git a/src/widgets/widgets/qkeysequenceedit_p.h b/src/widgets/widgets/qkeysequenceedit_p.h index 58c9699059..f74433bb71 100644 --- a/src/widgets/widgets/qkeysequenceedit_p.h +++ b/src/widgets/widgets/qkeysequenceedit_p.h @@ -46,6 +46,7 @@ #include "qkeysequenceedit.h" #include <private/qwidget_p.h> +#include <private/qkeysequence_p.h> QT_BEGIN_NAMESPACE @@ -57,8 +58,6 @@ class QKeySequenceEditPrivate : public QWidgetPrivate { Q_DECLARE_PUBLIC(QKeySequenceEdit) public: - enum { MaxKeyCount = 4 }; - void init(); int translateModifiers(Qt::KeyboardModifiers state, const QString &text); void resetState(); @@ -67,7 +66,7 @@ public: QLineEdit *lineEdit; QKeySequence keySequence; int keyNum; - int key[MaxKeyCount]; + int key[QKeySequencePrivate::MaxKeyCount]; int prevKey; int releaseTimer; }; diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index 5c1d7a6c05..349d8c3423 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -354,11 +354,6 @@ void SimpleCascader::rearrange(QList<QWidget *> &widgets, const QRect &domain) c QStyleOptionTitleBar options; options.initFrom(widgets.at(0)); int titleBarHeight = widgets.at(0)->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options, widgets.at(0)); -#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC) - // ### Remove this after the mac style has been fixed - if (qobject_cast<QMacStyle *>(widgets.at(0)->style())) - titleBarHeight -= 4; -#endif const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QMdiSubWindowTitleBar")); const int dy = qMax(titleBarHeight - (titleBarHeight - fontMetrics.height()) / 2, 1); diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index b80eb069e2..8e1dcbee18 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -1710,11 +1710,6 @@ int QMdiSubWindowPrivate::titleBarHeight(const QStyleOptionTitleBar &options) co } int height = q->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options, q); -#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) - // ### Fix mac style, the +4 pixels hack is not necessary anymore - if (qobject_cast<QMacStyle *>(q->style())) - height -= 4; -#endif if (hasBorder(options)) height += q->isMinimized() ? 8 : 4; return height; diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index dc83cf2fc4..c5a9b421ee 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -507,32 +507,26 @@ void tst_QSettings::ctor() QCOMPARE(settings1.value("%General/%General").toInt(), 11); /* - Test that the organization and product parameters is - case-insensitive on Windows and Mac, case-sensitive on - Unix. + Test that the organization and product parameters are + case-insensitive on case-insensitive file systems. */ QSettings settings5(format, QSettings::UserScope, "SoftWare.ORG", "killerApp"); + + bool caseSensitive = true; +#if defined(Q_OS_MAC) if (format == QSettings::NativeFormat) { -#if defined(Q_OS_WIN) || defined(Q_OS_DARWIN) -# ifdef Q_OS_OSX - if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_8) - QEXPECT_FAIL("native", "See QTBUG-32655", Continue); -# endif // Q_OS_OSX - QCOMPARE(settings5.value("key 1").toString(), QString("gurgle")); -#else - QVERIFY(!settings5.contains("key 1")); -#endif + // more details in QMacSettingsPrivate::QMacSettingsPrivate(), organization was comify()-ed + caseSensitive = settings5.fileName().contains("SoftWare.ORG");; } else { -#if defined(Q_OS_WIN) || defined(Q_OS_DARWIN) -# ifdef Q_OS_OSX - if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_8) - QEXPECT_FAIL("", "See QTBUG-32655", Continue); -# endif // Q_OS_OSX - QCOMPARE(settings5.value("key 1").toString(), QString("gurgle")); -#else - QVERIFY(!settings5.contains("key 1")); -#endif + caseSensitive = pathconf(QDir::currentPath().toLatin1().constData(), _PC_CASE_SENSITIVE); } +#elif defined(Q_OS_WIN32) + caseSensitive = false; +#endif + if (caseSensitive) + QVERIFY(!settings5.contains("key 1")); + else + QVERIFY(settings5.contains("key 1")); } { @@ -3168,6 +3162,11 @@ void tst_QSettings::rainersSyncBugOnMac() { QFETCH(QSettings::Format, format); +#ifdef Q_OS_OSX + if (format == QSettings::NativeFormat) + QSKIP("OSX does not support direct reads from and writes to .plist files, due to caching and background syncing. See QTBUG-34899."); +#endif + QString fileName; { @@ -3183,10 +3182,6 @@ void tst_QSettings::rainersSyncBugOnMac() { QSettings s3(format, QSettings::UserScope, "software.org", "KillerAPP"); -#ifdef Q_OS_OSX - if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_8) - QEXPECT_FAIL("native", "See QTBUG-32655", Continue); -#endif QCOMPARE(s3.value("key1", 30).toInt(), 25); } } diff --git a/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp b/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp index d2b6848dab..9e33f56a34 100644 --- a/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp +++ b/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp @@ -65,6 +65,7 @@ private slots: void basicacquire(); void complexacquire(); + void release(); #ifndef QT_NO_PROCESS void basicProcesses(); @@ -145,12 +146,37 @@ void tst_QSystemSemaphore::complexacquire() { QSystemSemaphore sem("QSystemSemaphore_complexacquire", 2, QSystemSemaphore::Create); QVERIFY(sem.acquire()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); QVERIFY(sem.release()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); QVERIFY(sem.acquire()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); QVERIFY(sem.release()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); QVERIFY(sem.acquire()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); QVERIFY(sem.acquire()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); QVERIFY(sem.release()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); + QVERIFY(sem.release()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); + QCOMPARE(sem.errorString(), QString()); +} + +void tst_QSystemSemaphore::release() +{ + QSystemSemaphore sem("QSystemSemaphore_release", 0, QSystemSemaphore::Create); + QVERIFY(sem.release()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); + QVERIFY(sem.release()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); + QVERIFY(sem.acquire()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); + QVERIFY(sem.acquire()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); + QVERIFY(sem.release()); + QCOMPARE(sem.error(), QSystemSemaphore::NoError); QVERIFY(sem.release()); QCOMPARE(sem.error(), QSystemSemaphore::NoError); QCOMPARE(sem.errorString(), QString()); diff --git a/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp b/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp index 7d041e69cb..ac8d433f96 100644 --- a/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp +++ b/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp @@ -49,9 +49,13 @@ #ifdef Q_OS_UNIX #include <unistd.h> #endif -#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) -#include <windows.h> -#define sleep(X) Sleep(X) +#if defined(Q_OS_WIN) +# include <qt_windows.h> +# ifndef Q_OS_WINRT +# define sleep(X) Sleep(X) +# else +# define sleep(X) WaitForSingleObjectEx(GetCurrentThread(), X, FALSE); +# endif #endif //on solaris, threads that loop on the release bool variable diff --git a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp index 07f8ddfc8e..2b30b0486b 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp @@ -69,9 +69,18 @@ int main(int argc, char *argv[]) // An option with a longer description, to test wrapping QCommandLineOption noImplicitIncludesOption(QStringList() << QStringLiteral("n") << QStringLiteral("no-implicit-includes")); - noImplicitIncludesOption.setDescription(QStringLiteral("Disable automatic generation of implicit #include-directives.")); + noImplicitIncludesOption.setDescription(QStringLiteral("Disable magic generation of implicit #include-directives.")); parser.addOption(noImplicitIncludesOption); + QCommandLineOption newlineOption(QStringList() << QStringLiteral("newline")); + newlineOption.setDescription(QString::fromLatin1("This is an option with a rather long\n" + "description using explicit newline characters " + "(but testing automatic wrapping too). In addition, " + "here, we test breaking after a comma. Testing -option. " + "Long URL: http://qt-project.org/wiki/How_to_create_a_library_with_Qt_and_use_it_in_an_application " + "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")); + parser.addOption(newlineOption); + // This program supports different options depending on the "command" (first argument). // Call parse() to find out the positional arguments. parser.parse(QCoreApplication::arguments()); diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp index d8965dee5d..f37e192ad3 100644 --- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp +++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp @@ -459,27 +459,40 @@ void tst_QCommandLineParser::testVersionOption() #endif // !QT_NO_PROCESS } +static const char expectedOptionsHelp[] = + "Options:\n" + " -h, --help Displays this help.\n" + " -v, --version Displays version information.\n" + " --load <url> Load file from URL.\n" + " -o, --output <file> Set output file.\n" + " -D <key=value> Define macro.\n" + " -n, --no-implicit-includes Disable magic generation of implicit\n" + " #include-directives.\n" + " --newline This is an option with a rather long\n" + " description using explicit newline characters (but\n" + " testing automatic wrapping too). In addition,\n" + " here, we test breaking after a comma. Testing\n" + " -option. Long URL:\n" + " http://qt-project.org/wiki/How_to_create_a_library\n" + " _with_Qt_and_use_it_in_an_application\n" + " abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx\n" + " yzabcdefghijklmnopqrstuvwxyz\n"; + void tst_QCommandLineParser::testHelpOption_data() { QTest::addColumn<QCommandLineParser::SingleDashWordOptionMode>("parsingMode"); QTest::addColumn<QString>("expectedHelpOutput"); - QString expectedOutput = + QString expectedOutput = QString::fromLatin1( "Usage: testhelper/qcommandlineparser_test_helper [options] parsingMode command\n" "Test helper\n" - "\n" - "Options:\n" - " -h, --help Displays this help.\n" - " -v, --version Displays version information.\n" - " --load <url> Load file from URL.\n" - " -o, --output <file> Set output file.\n" - " -D <key=value> Define macro.\n" - " -n, --no-implicit-includes Disable automatic generation of implicit #include\n" - " -directives.\n" + "\n") + + QString::fromLatin1(expectedOptionsHelp) + + QString::fromLatin1( "\n" "Arguments:\n" " parsingMode The parsing mode to test.\n" - " command The command to execute.\n"; + " command The command to execute.\n"); #ifdef Q_OS_WIN expectedOutput.replace(" -h, --help Displays this help.\n", " -?, -h, --help Displays this help.\n"); @@ -510,6 +523,7 @@ void tst_QCommandLineParser::testHelpOption() #ifdef Q_OS_WIN output.replace(QStringLiteral("\r\n"), QStringLiteral("\n")); #endif + QCOMPARE(output.split('\n'), expectedHelpOutput.split('\n')); // easier to debug than the next line, on failure QCOMPARE(output, expectedHelpOutput); process.start("testhelper/qcommandlineparser_test_helper", QStringList() << "0" << "resize" << "--help"); @@ -519,18 +533,11 @@ void tst_QCommandLineParser::testHelpOption() #ifdef Q_OS_WIN output.replace(QStringLiteral("\r\n"), QStringLiteral("\n")); #endif - QByteArray expectedResizeHelp = + QByteArray expectedResizeHelp = QByteArrayLiteral( "Usage: testhelper/qcommandlineparser_test_helper [options] resize [resize_options]\n" "Test helper\n" - "\n" - "Options:\n" - " -h, --help Displays this help.\n" - " -v, --version Displays version information.\n" - " --load <url> Load file from URL.\n" - " -o, --output <file> Set output file.\n" - " -D <key=value> Define macro.\n" - " -n, --no-implicit-includes Disable automatic generation of implicit #include\n" - " -directives.\n" + "\n") + + expectedOptionsHelp + " --size <size> New size.\n" "\n" "Arguments:\n" diff --git a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp index 7deb31c2c9..9416224440 100644 --- a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp +++ b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp @@ -275,6 +275,9 @@ void tst_QPrinterInfo::testConstructors() QCOMPARE(null.printerName(), QString()); QVERIFY(null.isNull()); + QPrinterInfo null2(null); + QVERIFY(null2.isNull()); + QList<QPrinterInfo> printers = QPrinterInfo::availablePrinters(); for (int i = 0; i < printers.size(); ++i) { @@ -295,6 +298,12 @@ void tst_QPrinterInfo::testConstructors() void tst_QPrinterInfo::testAssignment() { + QPrinterInfo null; + QVERIFY(null.isNull()); + QPrinterInfo null2; + null2 = null; + QVERIFY(null2.isNull()); + QList<QPrinterInfo> printers = QPrinterInfo::availablePrinters(); for (int i = 0; i < printers.size(); ++i) { diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index b737f823c8..e332f01861 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -63,7 +63,7 @@ private slots: void cleanup(); private: - void doRunSubTest(QString const& subdir, QStringList const& loggers, QStringList const& arguments); + void doRunSubTest(QString const& subdir, QStringList const& loggers, QStringList const& arguments, bool crashes); QString logName(const QString &logger) const; QList<LoggerSet> allLoggerSets() const; @@ -324,6 +324,7 @@ void tst_Selftests::runSubTest_data() QTest::addColumn<QString>("subdir"); QTest::addColumn<QStringList>("loggers"); QTest::addColumn<QStringList>("arguments"); + QTest::addColumn<bool>("crashes"); QStringList tests = QStringList() // << "alive" // timer dependent @@ -479,11 +480,14 @@ void tst_Selftests::runSubTest_data() continue; } } - + const bool crashes = subtest == QLatin1String("assert") || subtest == QLatin1String("exceptionthrow") + || subtest == QLatin1String("fetchbogus") || subtest == QLatin1String("crashedterminate") + || subtest == QLatin1String("crashes") || subtest == QLatin1String("silent"); QTest::newRow(qPrintable(QString("%1 %2").arg(subtest).arg(loggerSet.name))) << subtest << loggers << arguments + << crashes ; } } @@ -491,30 +495,41 @@ void tst_Selftests::runSubTest_data() #ifndef QT_NO_PROCESS -static void insertEnvironmentVariable(QString const& name, QProcessEnvironment &result) -{ - const QProcessEnvironment systemEnvironment = QProcessEnvironment::systemEnvironment(); - const QString value = systemEnvironment.value(name); - if (!value.isEmpty()) - result.insert(name, value); -} - -static inline QProcessEnvironment processEnvironment() +static QProcessEnvironment processEnvironment() { - QProcessEnvironment result; - insertEnvironmentVariable(QStringLiteral("PATH"), result); - // Preserve DISPLAY for X11 as some tests use Qt GUI. -#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) - insertEnvironmentVariable(QStringLiteral("DISPLAY"), result); -#endif - insertEnvironmentVariable(QStringLiteral("QT_QPA_PLATFORM"), result); + static QProcessEnvironment result; + if (result.isEmpty()) { + const QProcessEnvironment systemEnvironment = QProcessEnvironment::systemEnvironment(); + foreach (const QString &key, systemEnvironment.keys()) { + const bool useVariable = key == QLatin1String("PATH") || key == QLatin1String("QT_QPA_PLATFORM") +#ifdef Q_OS_UNIX + || key == QLatin1String("HOME") || key == QLatin1String("USER") // Required for X11 on openSUSE +# ifndef Q_OS_MAC + || key == QLatin1String("DISPLAY") || key == QLatin1String("XAUTHLOCALHOSTNAME") + || key.startsWith(QLatin1String("XDG_")) +# endif // !Q_OS_MAC +#endif // Q_OS_UNIX #ifdef __COVERAGESCANNER__ - insertEnvironmentVariable(QStringLiteral("QT_TESTCOCOON_ACTIVE"), result); + || key == QLatin1String("QT_TESTCOCOON_ACTIVE") #endif + ; + if (useVariable) + result.insert(key, systemEnvironment.value(key)); + } + } return result; } -void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& loggers, QStringList const& arguments) +static inline QByteArray msgProcessError(const QString &binary, const QStringList &args, + const QProcessEnvironment &e, const QString &what) +{ + QString result; + QTextStream(&result) <<"Error running " << binary << ' ' << args.join(' ') + << " with environment " << e.toStringList().join(' ') << ": " << what; + return result.toLocal8Bit(); +} + +void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& loggers, QStringList const& arguments, bool crashes) { #if defined(__GNUC__) && defined(__i386) && defined(Q_OS_LINUX) if (arguments.contains("-callgrind")) { @@ -532,8 +547,14 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge proc.setProcessEnvironment(environment); const QString path = subdir + QLatin1Char('/') + subdir; proc.start(path, arguments); - QVERIFY2(proc.waitForStarted(), qPrintable(QString::fromLatin1("Cannot start '%1': %2").arg(path, proc.errorString()))); - QVERIFY2(proc.waitForFinished(), qPrintable(proc.errorString())); + QVERIFY2(proc.waitForStarted(), msgProcessError(path, arguments, environment, QStringLiteral("Cannot start: ") + proc.errorString())); + QVERIFY2(proc.waitForFinished(), msgProcessError(path, arguments, environment, QStringLiteral("Timed out: ") + proc.errorString())); + if (!crashes) { + QVERIFY2(proc.exitStatus() == QProcess::NormalExit, + msgProcessError(path, arguments, environment, + QStringLiteral("Crashed: ") + proc.errorString() + + QStringLiteral(": ") + QString::fromLocal8Bit(proc.readAllStandardError()))); + } QList<QByteArray> actualOutputs; for (int i = 0; i < loggers.count(); ++i) { @@ -700,8 +721,9 @@ void tst_Selftests::runSubTest() QFETCH(QString, subdir); QFETCH(QStringList, loggers); QFETCH(QStringList, arguments); + QFETCH(bool, crashes); - doRunSubTest(subdir, loggers, arguments); + doRunSubTest(subdir, loggers, arguments, crashes); #endif // !QT_NO_PROCESS } diff --git a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp index 68502f0d8d..060fa51293 100644 --- a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp +++ b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp @@ -57,6 +57,8 @@ public: virtual ~tst_QProgressDialog(); private slots: + void autoShow_data(); + void autoShow(); void getSetCheck(); void task198202(); void QTBUG_31046(); @@ -70,6 +72,34 @@ tst_QProgressDialog::~tst_QProgressDialog() { } +void tst_QProgressDialog::autoShow_data() +{ + QTest::addColumn<int>("min"); + QTest::addColumn<int>("max"); + QTest::addColumn<int>("delay"); + QTest::addColumn<bool>("expectedAutoShow"); + + QTest::newRow("50_to_100_long") << 50 << 100 << 100 << true; // 50*100ms = 5s + QTest::newRow("50_to_100_short") << 50 << 1 << 100 << false; // 50*1ms = 50ms + + QTest::newRow("0_to_100_long") << 0 << 100 << 100 << true; // 100*100ms = 10s + QTest::newRow("0_to_10_short") << 0 << 10 << 100 << false; // 10*100ms = 1s +} + +void tst_QProgressDialog::autoShow() +{ + QFETCH(int, min); + QFETCH(int, max); + QFETCH(int, delay); + QFETCH(bool, expectedAutoShow); + + QProgressDialog dlg("", "", min, max); + dlg.setValue(0); + QThread::msleep(delay); + dlg.setValue(min+1); + QCOMPARE(dlg.isVisible(), expectedAutoShow); +} + // Testing get/set functions void tst_QProgressDialog::getSetCheck() { diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index 0c6d369254..36bf76564f 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -58,17 +58,8 @@ #include <qscrollbar.h> #include <qboxlayout.h> #include <qlineedit.h> - -// Will try to wait for the condition while allowing event processing -// for a maximum of 5 seconds. -#define TRY_COMPARE(expr, expected) \ - do { \ - const int step = 50; \ - for (int q = 0; q < 5000 && ((expr) != (expected)); q+=step) { \ - QTest::qWait(step); \ - } \ - QCOMPARE(expr, expected); \ - } while(0) +#include <qscreen.h> +#include <qscopedpointer.h> static inline void setFrameless(QWidget *w) { @@ -78,6 +69,22 @@ static inline void setFrameless(QWidget *w) w->setWindowFlags(flags); } +static inline void centerOnScreen(QWidget *w) +{ + const QPoint offset = QPoint(w->width() / 2, w->height() / 2); + w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); +} + +// Move cursor out of widget area to avoid undesired interaction on Mac. +static inline void moveCursorAway(const QWidget *topLevel) +{ +#ifndef QT_NO_CURSOR + QCursor::setPos(topLevel->geometry().topRight() + QPoint(100, 0)); +#else + Q_UNUSED(topLevel) +#endif +} + class TestView : public QAbstractItemView { Q_OBJECT @@ -374,25 +381,27 @@ void tst_QAbstractItemView::emptyModels() { QFETCH(QString, viewType); - TestView *view = 0; + QScopedPointer<QAbstractItemView> view; if (viewType == "QListView") - view = reinterpret_cast<TestView*>(new QListView()); + view.reset(new QListView()); else if (viewType == "QTableView") - view = reinterpret_cast<TestView*>(new QTableView()); + view.reset(new QTableView()); else if (viewType == "QTreeView") - view = reinterpret_cast<TestView*>(new QTreeView()); + view.reset(new QTreeView()); else if (viewType == "QHeaderView") - view = reinterpret_cast<TestView*>(new QHeaderView(Qt::Vertical)); + view.reset(new QHeaderView(Qt::Vertical)); else QVERIFY(0); + centerOnScreen(view.data()); + moveCursorAway(view.data()); view->show(); + QVERIFY(QTest::qWaitForWindowExposed(view.data())); QVERIFY(!view->model()); QVERIFY(!view->selectionModel()); //QVERIFY(view->itemDelegate() != 0); - basic_tests(view); - delete view; + basic_tests(reinterpret_cast<TestView*>(view.data())); } void tst_QAbstractItemView::setModel_data() @@ -408,24 +417,28 @@ void tst_QAbstractItemView::setModel_data() void tst_QAbstractItemView::setModel() { QFETCH(QString, viewType); - TestView *view = 0; + + QScopedPointer<QAbstractItemView> view; + if (viewType == "QListView") - view = reinterpret_cast<TestView*>(new QListView()); + view.reset(new QListView()); else if (viewType == "QTableView") - view = reinterpret_cast<TestView*>(new QTableView()); + view.reset(new QTableView()); else if (viewType == "QTreeView") - view = reinterpret_cast<TestView*>(new QTreeView()); + view.reset(new QTreeView()); else if (viewType == "QHeaderView") - view = reinterpret_cast<TestView*>(new QHeaderView(Qt::Vertical)); + view.reset(new QHeaderView(Qt::Vertical)); else QVERIFY(0); + centerOnScreen(view.data()); + moveCursorAway(view.data()); view->show(); + QVERIFY(QTest::qWaitForWindowExposed(view.data())); QStandardItemModel model(20,20); view->setModel(0); view->setModel(&model); - basic_tests(view); - delete view; + basic_tests(reinterpret_cast<TestView*>(view.data())); } void tst_QAbstractItemView::basic_tests(TestView *view) @@ -636,7 +649,10 @@ void tst_QAbstractItemView::noModel() view.setModel(&model); // Make the viewport smaller than the contents, so that we can scroll view.resize(100,100); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); // make sure that the scrollbars are not at value 0 view.scrollTo(view.model()->index(10,10)); @@ -656,7 +672,10 @@ void tst_QAbstractItemView::dragSelect() QTableView view; view.setModel(&model); + centerOnScreen(&view); + moveCursorAway(&view); view.setVisible(true); + QVERIFY(QTest::qWaitForWindowExposed(&view)); const int delay = 2; for (int i = 0; i < 2; ++i) { @@ -677,7 +696,10 @@ void tst_QAbstractItemView::rowDelegate() QTableView view; view.setModel(&model); view.setItemDelegateForRow(3, &delegate); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QModelIndex index = model.index(3, 0); view.openPersistentEditor(index); @@ -694,7 +716,10 @@ void tst_QAbstractItemView::columnDelegate() QTableView view; view.setModel(&model); view.setItemDelegateForColumn(3, &delegate); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QModelIndex index = model.index(0, 3); view.openPersistentEditor(index); @@ -747,11 +772,13 @@ void tst_QAbstractItemView::persistentEditorFocus() view.setCurrentIndex(model.index(0, 0)); QCOMPARE(view.currentIndex(), model.index(0, 0)); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); - QTRY_VERIFY(view.isVisible()); + QVERIFY(QTest::qWaitForWindowExposed(&view)); for (int i = 0; i < list.count(); ++i) { - TRY_COMPARE(list.at(i)->isVisible(), true); + QTRY_VERIFY(list.at(i)->isVisible()); QPoint p = QPoint(5, 5); QMouseEvent mouseEvent(QEvent::MouseButtonPress, p, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); @@ -1045,6 +1072,8 @@ void tst_QAbstractItemView::setItemDelegate() } } } + centerOnScreen(&v); + moveCursorAway(&v); v.show(); #ifdef Q_WS_X11 QCursor::setPos(v.geometry().center()); @@ -1056,7 +1085,7 @@ void tst_QAbstractItemView::setItemDelegate() v.edit(index); // This will close the editor - TRY_COMPARE(QApplication::focusWidget() == 0, false); + QTRY_VERIFY(QApplication::focusWidget()); QWidget *editor = QApplication::focusWidget(); QVERIFY(editor); editor->hide(); @@ -1122,20 +1151,25 @@ void tst_QAbstractItemView::setCurrentIndex() QFETCH(int, itemFlags); QFETCH(bool, result); - TestView *view = 0; + QScopedPointer<QAbstractItemView> view; + if (viewType == "QListView") - view = reinterpret_cast<TestView*>(new QListView()); + view.reset(new QListView()); else if (viewType == "QTableView") - view = reinterpret_cast<TestView*>(new QTableView()); + view.reset(new QTableView()); else if (viewType == "QTreeView") - view = reinterpret_cast<TestView*>(new QTreeView()); + view.reset(new QTreeView()); else if (viewType == "QHeaderView") - view = reinterpret_cast<TestView*>(new QHeaderView(Qt::Vertical)); + view.reset(new QHeaderView(Qt::Vertical)); else QVERIFY(0); + + centerOnScreen(view.data()); + moveCursorAway(view.data()); view->show(); + QVERIFY(QTest::qWaitForWindowExposed(view.data())); - QStandardItemModel *model = new QStandardItemModel(view); + QStandardItemModel *model = new QStandardItemModel(view.data()); QStandardItem *item = new QStandardItem("first item"); item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); model->appendRow(item); @@ -1150,8 +1184,6 @@ void tst_QAbstractItemView::setCurrentIndex() QVERIFY(view->currentIndex() == model->index(0,0)); view->setCurrentIndex(model->index(1,0)); QVERIFY(view->currentIndex() == model->index(result ? 1 : 0,0)); - - delete view; } void tst_QAbstractItemView::task221955_selectedEditor() @@ -1170,11 +1202,13 @@ void tst_QAbstractItemView::task221955_selectedEditor() tree.setItemWidget(dummy, 0, button = new QPushButton("More...")); button->setAutoFillBackground(true); // as recommended in doc + centerOnScreen(&tree); + moveCursorAway(&tree); tree.show(); tree.setFocus(); tree.setCurrentIndex(tree.model()->index(1,0)); - QTest::qWait(100); QApplication::setActiveWindow(&tree); + QVERIFY(QTest::qWaitForWindowActive(&tree)); QVERIFY(! tree.selectionModel()->selectedIndexes().contains(tree.model()->index(3,0))); @@ -1218,9 +1252,11 @@ void tst_QAbstractItemView::task250754_fontChange() } tree.setModel(m); + w.resize(160, 240); // Minimum width for windows with frame on Windows 8 + centerOnScreen(&w); + moveCursorAway(&w); w.show(); - w.resize(150,240); - QTest::qWait(30); + QVERIFY(QTest::qWaitForWindowExposed(&w)); QFont font = tree.font(); font.setPixelSize(10); tree.setFont(font); @@ -1244,8 +1280,10 @@ void tst_QAbstractItemView::task200665_itemEntered() QStandardItemModel model(1000,1); QListView view; view.setModel(&model); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); - QTest::qWait(200); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QRect rect = view.visualRect(model.index(0,0)); QCursor::setPos( view.viewport()->mapToGlobal(rect.center()) ); QSignalSpy spy(&view, SIGNAL(entered(QModelIndex))); @@ -1267,7 +1305,10 @@ void tst_QAbstractItemView::task257481_emptyEditor() QTreeView treeView; treeView.setRootIsDecorated(false); treeView.setModel(&model); + centerOnScreen(&treeView); + moveCursorAway(&treeView); treeView.show(); + QVERIFY(QTest::qWaitForWindowExposed(&treeView)); treeView.edit(model.index(0,0)); QList<QLineEdit *> lineEditors = treeView.viewport()->findChildren<QLineEdit *>(); @@ -1298,14 +1339,16 @@ void tst_QAbstractItemView::shiftArrowSelectionAfterScrolling() } QListView view; - view.setFixedSize(150, 250); + view.setFixedSize(160, 250); // Minimum width for windows with frame on Windows 8 view.setFlow(QListView::LeftToRight); view.setGridSize(QSize(100, 100)); view.setSelectionMode(QListView::ExtendedSelection); view.setViewMode(QListView::IconMode); view.setModel(&model); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); - QTest::qWait(30); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QModelIndex index0 = model.index(0, 0); QModelIndex index1 = model.index(1, 0); @@ -1333,14 +1376,16 @@ void tst_QAbstractItemView::shiftSelectionAfterRubberbandSelection() } QListView view; - view.setFixedSize(150, 450); + view.setFixedSize(160, 450); // Minimum width for windows with frame on Windows 8 view.setFlow(QListView::LeftToRight); view.setGridSize(QSize(100, 100)); view.setSelectionMode(QListView::ExtendedSelection); view.setViewMode(QListView::IconMode); view.setModel(&model); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); - QTest::qWait(30); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QModelIndex index0 = model.index(0, 0); QModelIndex index1 = model.index(1, 0); @@ -1408,14 +1453,16 @@ void tst_QAbstractItemView::ctrlRubberbandSelection() } QListView view; - view.setFixedSize(150, 450); + view.setFixedSize(160, 450); // Minimum width for windows with frame on Windows 8 view.setFlow(QListView::LeftToRight); view.setGridSize(QSize(100, 100)); view.setSelectionMode(QListView::ExtendedSelection); view.setViewMode(QListView::IconMode); view.setModel(&model); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); - QTest::qWait(30); + QVERIFY(QTest::qWaitForWindowExposed(&view)); QModelIndex index1 = model.index(1, 0); QModelIndex index2 = model.index(2, 0); @@ -1454,6 +1501,8 @@ void tst_QAbstractItemView::QTBUG6407_extendedSelection() font.setPixelSize(10); view.setFont(font); view.resize(200,240); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); QApplication::setActiveWindow(&view); @@ -1493,7 +1542,11 @@ void tst_QAbstractItemView::QTBUG6753_selectOnSelection() for (int j = 0; j < table.columnCount(); ++j) table.setItem(i, j, new QTableWidgetItem("choo-be-doo-wah")); + centerOnScreen(&table); + moveCursorAway(&table); table.show(); + QVERIFY(QTest::qWaitForWindowExposed(&table)); + table.setSelectionMode(QAbstractItemView::ExtendedSelection); table.selectAll(); QVERIFY(QTest::qWaitForWindowExposed(&table)); @@ -1523,6 +1576,8 @@ void tst_QAbstractItemView::testClickedSignal() { QTableWidget view(5, 5); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); QApplication::setActiveWindow(&view); QVERIFY(QTest::qWaitForWindowActive(&view)); @@ -1591,6 +1646,8 @@ void tst_QAbstractItemView::testChangeEditorState() view.setEditTriggers(QAbstractItemView::CurrentChanged); view.setItemDelegate(new StateChangeDelegate); view.setModel(&model); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); QApplication::setActiveWindow(&view); QVERIFY(QTest::qWaitForWindowActive(&view)); @@ -1607,7 +1664,10 @@ void tst_QAbstractItemView::deselectInSingleSelection() s.setRowCount(10); s.setColumnCount(10); view.setModel(&s); + centerOnScreen(&view); + moveCursorAway(&view); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); view.setSelectionMode(QAbstractItemView::SingleSelection); view.setEditTriggers(QAbstractItemView::NoEditTriggers); QApplication::setActiveWindow(&view); @@ -1650,6 +1710,8 @@ void tst_QAbstractItemView::testNoActivateOnDisabledItem() model.setItem(0, 0, item); item->setFlags(Qt::NoItemFlags); treeView.setModel(&model); + centerOnScreen(&treeView); + moveCursorAway(&treeView); treeView.show(); QApplication::setActiveWindow(&treeView); diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index 398b1b4d98..3e6df0f136 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -368,6 +368,8 @@ void tst_QHeaderView::getSetCheck() QCOMPARE(0, obj1.minimumSectionSize()); obj1.setMinimumSectionSize(99999); QCOMPARE(99999, obj1.minimumSectionSize()); + obj1.setMinimumSectionSize(-1); + QVERIFY(obj1.minimumSectionSize() < 100); // int QHeaderView::offset() // void QHeaderView::setOffset(int) diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index 8d75298673..091927abe4 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -153,6 +153,7 @@ private slots: void focusChanged(); void focusOut(); + void focusMouseClick(); void execAfterExit(); @@ -1771,6 +1772,63 @@ void tst_QApplication::focusOut() QTest::qWait(2000); } +class SpontaneousEvent +{ + Q_GADGET + QDOC_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) + Q_ENUMS(Type) +public: + enum Type { + Void + }; + + virtual ~SpontaneousEvent() {} + + QEventPrivate *d; + ushort t; + + ushort posted : 1; + ushort spont : 1; +}; + +void tst_QApplication::focusMouseClick() +{ + int argc = 1; + QApplication app(argc, &argv0); + + QWidget w; + w.setFocusPolicy(Qt::StrongFocus); + QWidget w2(&w); + w2.setFocusPolicy(Qt::TabFocus); + w.show(); + w.setFocus(); + QTRY_COMPARE(QApplication::focusWidget(), &w); + + // front most widget has Qt::TabFocus, parent widget accepts clicks as well + // now send a mouse button press event and check what happens with the focus + // it should be given to the parent widget + QMouseEvent ev(QEvent::MouseButtonPress, QPointF(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); + reinterpret_cast<SpontaneousEvent *>(&ev)->spont = 1; + QVERIFY(ev.spontaneous()); + qApp->notify(&w2, &ev); + QCOMPARE(QApplication::focusWidget(), &w); + + // then we give the inner widget strong focus -> it should get focus + w2.setFocusPolicy(Qt::StrongFocus); + reinterpret_cast<SpontaneousEvent *>(&ev)->spont = 1; + QVERIFY(ev.spontaneous()); + qApp->notify(&w2, &ev); + QTRY_COMPARE(QApplication::focusWidget(), &w2); + + // now back to tab focus and click again (it already had focus) -> focus should stay + // (focus was revoked as of QTBUG-34042) + w2.setFocusPolicy(Qt::TabFocus); + reinterpret_cast<SpontaneousEvent *>(&ev)->spont = 1; + QVERIFY(ev.spontaneous()); + qApp->notify(&w2, &ev); + QCOMPARE(QApplication::focusWidget(), &w2); +} + void tst_QApplication::execAfterExit() { int argc = 1; diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp index 135605f185..d04b812878 100644 --- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp +++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp @@ -47,6 +47,7 @@ #include <qproxystyle.h> #include <qsizepolicy.h> +#include <QtWidgets/QCheckBox> #include <QtWidgets/QLabel> #include <QtWidgets/QLineEdit> #include <QtWidgets/QPushButton> @@ -347,6 +348,19 @@ void tst_QFormLayout::spacing() style->hspacing = 20; //QCOMPARE(fl->spacing(), 20); + + + // Do not assert if spacings are negative (QTBUG-34731) + style->vspacing = -1; + style->hspacing = -1; + QLabel *label = new QLabel(tr("Asserts")); + QCheckBox *checkBox = new QCheckBox(tr("Yes")); + fl->setWidget(0, QFormLayout::LabelRole, label); + fl->setWidget(1, QFormLayout::FieldRole, checkBox); + w->resize(200, 100); + w->show(); + QVERIFY(QTest::qWaitForWindowExposed(w)); + delete w; delete style; } diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 03d6c1cdbd..36a3a8bad5 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -171,7 +171,7 @@ static inline void centerOnScreen(QWidget *w) w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); } -#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) static inline void setWindowsAnimationsEnabled(bool enabled) { ANIMATIONINFO animation = { sizeof(ANIMATIONINFO), enabled }; @@ -184,10 +184,10 @@ static inline bool windowsAnimationsEnabled() SystemParametersInfo(SPI_GETANIMATION, 0, &animation, 0); return animation.iMinAnimate; } -#else // Q_OS_WIN && !Q_OS_WINCE +#else // Q_OS_WIN && !Q_OS_WINCE && !Q_OS_WINRT inline void setWindowsAnimationsEnabled(bool) {} static inline bool windowsAnimationsEnabled() { return false; } -#endif // !Q_OS_WIN || Q_OS_WINCE +#endif // !Q_OS_WIN || Q_OS_WINCE || Q_OS_WINRT class tst_QWidget : public QObject { diff --git a/tests/auto/widgets/widgets/qkeysequenceedit/tst_qkeysequenceedit.cpp b/tests/auto/widgets/widgets/qkeysequenceedit/tst_qkeysequenceedit.cpp index 8c010abfe6..1434d98e59 100644 --- a/tests/auto/widgets/widgets/qkeysequenceedit/tst_qkeysequenceedit.cpp +++ b/tests/auto/widgets/widgets/qkeysequenceedit/tst_qkeysequenceedit.cpp @@ -43,6 +43,8 @@ #include <QtTest/QtTest> #include <QKeySequenceEdit> +#include <QLineEdit> +#include <QString> Q_DECLARE_METATYPE(Qt::Key) Q_DECLARE_METATYPE(Qt::KeyboardModifiers) @@ -55,6 +57,7 @@ private slots: void testSetters(); void testKeys_data(); void testKeys(); + void testLineEditContents(); }; void tst_QKeySequenceEdit::testSetters() @@ -100,5 +103,26 @@ void tst_QKeySequenceEdit::testKeys() QTRY_COMPARE(spy.count(), 1); } +void tst_QKeySequenceEdit::testLineEditContents() +{ + QKeySequenceEdit edit; + QLineEdit *le = edit.findChild<QLineEdit*>(); + QVERIFY(le); + + QCOMPARE(le->text(), QString()); + + edit.setKeySequence(QKeySequence::New); + QCOMPARE(edit.keySequence(), QKeySequence(QKeySequence::New)); + + edit.clear(); + QCOMPARE(le->text(), QString()); + + edit.setKeySequence(QKeySequence::New); + QVERIFY(le->text() != QString()); + + edit.setKeySequence(QKeySequence()); + QCOMPARE(le->text(), QString()); +} + QTEST_MAIN(tst_QKeySequenceEdit) #include "tst_qkeysequenceedit.moc" diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp index 5b146cf443..b3e50b8ba8 100644 --- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp +++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp @@ -954,9 +954,6 @@ void tst_QMdiSubWindow::mouseDoubleClick() QStyleOptionTitleBar options; options.initFrom(window); int height = window->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options); - // ### Remove this after mac style has been fixed - if (window->style()->inherits("QMacStyle")) - height -= 4; // has border if (!window->style()->styleHint(QStyle::SH_TitleBar_NoBorder, &options, window)) height += window->isMinimized() ? 8 : 4; @@ -1692,11 +1689,6 @@ void tst_QMdiSubWindow::fixedMinMaxSize() QStyleOptionTitleBar options; options.initFrom(subWindow); int minimizedHeight = subWindow->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options); -#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) - // ### Remove this after mac style has been fixed - if (subWindow->style()->inherits("QMacStyle")) - minimizedHeight -= 4; -#endif if (!subWindow->style()->styleHint(QStyle::SH_TitleBar_NoBorder, &options, subWindow)) minimizedHeight += 8; int minimizedWidth = subWindow->style()->pixelMetric(QStyle::PM_MDIMinimizedWidth, &options); diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 7c1bb957d6..81ed983d0f 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -50,6 +50,7 @@ #include <QListWidget> #include <QWidgetAction> #include <QDesktopWidget> +#include <QScreen> #include <qdialog.h> #include <qmenu.h> @@ -59,6 +60,17 @@ Q_DECLARE_METATYPE(Qt::Key); Q_DECLARE_METATYPE(Qt::KeyboardModifiers); +static inline void centerOnScreen(QWidget *w, const QSize &size) +{ + const QPoint offset = QPoint(size.width() / 2, size.height() / 2); + w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); +} + +static inline void centerOnScreen(QWidget *w) +{ + centerOnScreen(w, w->geometry().size()); +} + class tst_QMenu : public QObject { Q_OBJECT @@ -257,9 +269,12 @@ void tst_QMenu::addActionsAndClear() void tst_QMenu::mouseActivation() { QWidget topLevel; + topLevel.resize(300, 200); + centerOnScreen(&topLevel); QMenu menu(&topLevel); topLevel.show(); menu.addAction("Menu Action"); + menu.move(topLevel.geometry().topRight() + QPoint(50, 0)); menu.show(); QTest::mouseClick(&menu, Qt::LeftButton, 0, menu.rect().center(), 300); QVERIFY(!menu.isVisible()); @@ -275,8 +290,10 @@ void tst_QMenu::mouseActivation() QMenu submenu("Menu"); submenu.addAction("action"); QAction *action = menubar.addMenu(&submenu); + menubar.move(topLevel.geometry().topRight() + QPoint(300, 0)); menubar.show(); + QTest::mouseClick(&menubar, Qt::LeftButton, 0, menubar.actionGeometry(action).center(), 300); QVERIFY(submenu.isVisible()); QTest::mouseClick(&submenu, Qt::LeftButton, 0, QPoint(5, 5), 300); @@ -378,13 +395,16 @@ void tst_QMenu::focus() #endif QWidget window; + window.resize(300, 200); QPushButton button("Push me", &window); + centerOnScreen(&window); window.show(); qApp->setActiveWindow(&window); QVERIFY(button.hasFocus()); QCOMPARE(QApplication::focusWidget(), (QWidget *)&button); QCOMPARE(QApplication::activeWindow(), &window); + menu.move(window.geometry().topRight() + QPoint(50, 0)); menu.show(); QVERIFY(button.hasFocus()); QCOMPARE(QApplication::focusWidget(), (QWidget *)&button); @@ -399,6 +419,8 @@ void tst_QMenu::overrideMenuAction() { //test the override menu action by first creating an action to which we set its menu QMainWindow w; + w.resize(300, 200); + centerOnScreen(&w); QAction *aFileMenu = new QAction("&File", &w); w.menuBar()->addAction(aFileMenu); @@ -442,6 +464,8 @@ void tst_QMenu::statusTip() { //check that the statustip of actions inserted into the menu are displayed QMainWindow w; + w.resize(300, 200); + centerOnScreen(&w); connect(w.statusBar(), SIGNAL(messageChanged(QString)), SLOT(onStatusMessageChanged(QString)));; //creates the status bar QToolBar tb; QAction a("main action", &tb); @@ -540,10 +564,12 @@ void tst_QMenu::tearOff() menu->addAction("bbb"); QVERIFY(menu->isTearOffEnabled()); + widget.resize(300, 200); + centerOnScreen(&widget); widget.show(); widget.activateWindow(); QVERIFY(QTest::qWaitForWindowActive(&widget)); - menu->popup(QPoint(0,0)); + menu->popup(widget.geometry().topRight() + QPoint(50, 0)); QVERIFY(QTest::qWaitForWindowActive(menu)); QVERIFY(!menu->isTearOffMenuVisible()); @@ -568,14 +594,18 @@ void tst_QMenu::layoutDirection() { QMainWindow win; win.setLayoutDirection(Qt::RightToLeft); + win.resize(300, 200); + centerOnScreen(&win); QMenu menu(&win); + menu.move(win.geometry().topRight() + QPoint(50, 0)); menu.show(); QVERIFY(QTest::qWaitForWindowExposed(&menu)); QCOMPARE(menu.layoutDirection(), Qt::RightToLeft); menu.close(); menu.setParent(0); + menu.move(win.geometry().topRight() + QPoint(50, 0)); menu.show(); QVERIFY(QTest::qWaitForWindowExposed(&menu)); QCOMPARE(menu.layoutDirection(), QApplication::layoutDirection()); @@ -702,6 +732,7 @@ void tst_QMenu::task256918_setFont() QFont f; f.setPointSize(30); action->setFont(f); + centerOnScreen(&menu, QSize(120, 40)); menu.show(); //ensures that the actiongeometry are calculated QVERIFY(menu.actionGeometry(action).height() > f.pointSize()); } @@ -830,6 +861,13 @@ void PopulateOnAboutToShowTestMenu::populateMenu() addSeparator(); } +static inline QByteArray msgGeometryIntersects(const QRect &r1, const QRect &r2) +{ + QString result; + QDebug(&result) << r1 << "intersects" << r2; + return result.toLocal8Bit(); +} + void tst_QMenu::pushButtonPopulateOnAboutToShow() { QPushButton b("Test PushButton"); @@ -842,7 +880,7 @@ void tst_QMenu::pushButtonPopulateOnAboutToShow() const QRect screen = QApplication::desktop()->screenGeometry(scrNumber); QRect desiredGeometry = b.geometry(); - desiredGeometry.moveTopLeft(QPoint(10, screen.bottom()-b.height()-5)); + desiredGeometry.moveTopLeft(QPoint(screen.x() + 10, screen.bottom() - b.height() - 5)); b.setGeometry(desiredGeometry); QVERIFY(QTest::qWaitForWindowExposed(&b)); @@ -859,13 +897,13 @@ void tst_QMenu::pushButtonPopulateOnAboutToShow() QTimer::singleShot(300, buttonMenu, SLOT(hide())); QTest::mouseClick(&b, Qt::LeftButton, Qt::NoModifier, b.rect().center()); - QVERIFY(!buttonMenu->geometry().intersects(b.geometry())); + QVERIFY2(!buttonMenu->geometry().intersects(b.geometry()), msgGeometryIntersects(buttonMenu->geometry(), b.geometry())); // note: we're assuming that, if we previously got the desired geometry, we'll get it here too b.move(10, screen.bottom()-buttonMenu->height()-5); QTimer::singleShot(300, buttonMenu, SLOT(hide())); QTest::mouseClick(&b, Qt::LeftButton, Qt::NoModifier, b.rect().center()); - QVERIFY(!buttonMenu->geometry().intersects(b.geometry())); + QVERIFY2(!buttonMenu->geometry().intersects(b.geometry()), msgGeometryIntersects(buttonMenu->geometry(), b.geometry())); } void tst_QMenu::QTBUG7907_submenus_autoselect() @@ -878,6 +916,7 @@ void tst_QMenu::QTBUG7907_submenus_autoselect() set1.addMenu(&subset); menu.addMenu(&set1); menu.addMenu(&set2); + centerOnScreen(&menu, QSize(120, 100)); menu.show(); QVERIFY(QTest::qWaitForWindowExposed(&menu)); QTest::mouseClick(&menu, Qt::LeftButton, Qt::NoModifier, QPoint(5,5) ); @@ -893,6 +932,7 @@ void tst_QMenu::QTBUG7411_submenus_activate() sub1.addAction("foo"); sub1.setTitle("&sub1"); QAction *act1 = menu.addMenu(&sub1); + centerOnScreen(&menu, QSize(120, 100)); menu.show(); QVERIFY(QTest::qWaitForWindowExposed(&menu)); menu.setActiveAction(act); @@ -911,12 +951,12 @@ void tst_QMenu::QTBUG30595_rtl_submenu() sub.addAction("bar"); sub.setTitle("&sub"); menu.addMenu(&sub); - menu.move(200, 20); + centerOnScreen(&menu, QSize(120, 40)); menu.show(); QVERIFY(QTest::qWaitForWindowExposed(&menu)); QTest::mouseClick(&menu, Qt::LeftButton, Qt::NoModifier, QPoint(5,5) ); QTRY_VERIFY(sub.isVisible()); - QVERIFY(sub.pos().x() < menu.pos().x()); + QVERIFY2(sub.pos().x() < menu.pos().x(), QByteArray::number(sub.pos().x()) + QByteArrayLiteral(" not less than ") + QByteArray::number(menu.pos().x())); } void tst_QMenu::QTBUG20403_nested_popup_on_shortcut_trigger() @@ -927,6 +967,7 @@ void tst_QMenu::QTBUG20403_nested_popup_on_shortcut_trigger() subsub1.addAction("foo"); sub1.addMenu(&subsub1); menu.addMenu(&sub1); + centerOnScreen(&menu, QSize(120, 100)); menu.show(); QVERIFY(QTest::qWaitForWindowExposed(&menu)); QTest::keyPress(&menu, Qt::Key_S); diff --git a/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro b/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro index 3940ddbf98..8fd4db6b4b 100644 --- a/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro +++ b/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro @@ -1,5 +1,6 @@ SOURCES = main.cpp CONFIG -= qt app_bundle CONFIG += console +winrt: QMAKE_LFLAGS += /ENTRY:mainCRTStartup DESTDIR = ./ DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp b/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp index a7480e6afe..47227ef630 100644 --- a/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp +++ b/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp @@ -88,7 +88,9 @@ void NativeMutexUnlock(NativeMutexType *mutex) } #endif #elif defined(Q_OS_WIN) -# define _WIN32_WINNT 0x0400 +# ifndef Q_OS_WINRT +# define _WIN32_WINNT 0x0400 +# endif # include <windows.h> typedef CRITICAL_SECTION NativeMutexType; void NativeMutexInitialize(NativeMutexType *mutex) diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index e2fef2c665..5ab413a971 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -180,7 +180,7 @@ Configure::Configure(int& argc, char** argv) dictionary[ "WMF_BACKEND" ] = "auto"; dictionary[ "WMSDK" ] = "auto"; dictionary[ "QML_DEBUG" ] = "yes"; - dictionary[ "PLUGIN_MANIFESTS" ] = "yes"; + dictionary[ "PLUGIN_MANIFESTS" ] = "no"; dictionary[ "DIRECTWRITE" ] = "no"; dictionary[ "NIS" ] = "no"; dictionary[ "NEON" ] = "auto"; diff --git a/util/accessibilityinspector/screenreader.cpp b/util/accessibilityinspector/screenreader.cpp index 5dcf52ef09..e5953637a1 100644 --- a/util/accessibilityinspector/screenreader.cpp +++ b/util/accessibilityinspector/screenreader.cpp @@ -42,7 +42,6 @@ #include "screenreader.h" #include "optionswidget.h" #include "accessibilityscenemanager.h" -#include <private/qaccessible2_p.h> #include <QtGui> ScreenReader::ScreenReader(QObject *parent) : |