diff options
Diffstat (limited to 'src')
90 files changed, 653 insertions, 393 deletions
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 e062a38185..e02026ca4c 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/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/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/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..33ae60a017 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -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/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/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; |