From 043f5d3eb52587831f643bc52c95079c36d984c7 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 2 Dec 2015 10:27:54 -0800 Subject: QNetworkInterface: fix handling of interfaces with no addresses Certain Linux interfaces have no addresses at all (hardware or IP), like the nlmon interfaces. They weren't being reported. Change-Id: I8de47ed6c7be4847b99bffff141c2b60c2089ad3 Reviewed-by: Richard J. Moore --- src/network/kernel/qnetworkinterface_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/network/kernel/qnetworkinterface_unix.cpp b/src/network/kernel/qnetworkinterface_unix.cpp index 5e6d24dd44..b734476dc2 100644 --- a/src/network/kernel/qnetworkinterface_unix.cpp +++ b/src/network/kernel/qnetworkinterface_unix.cpp @@ -343,7 +343,7 @@ static QList createInterfaces(ifaddrs *rawList) // - virtual interfaces with no HW address have no AF_PACKET // - interface labels have no AF_PACKET, but shouldn't be shown as a new interface for (ifaddrs *ptr = rawList; ptr; ptr = ptr->ifa_next) { - if (ptr->ifa_addr && ptr->ifa_addr->sa_family != AF_PACKET) { + if (!ptr->ifa_addr || ptr->ifa_addr->sa_family != AF_PACKET) { QString name = QString::fromLatin1(ptr->ifa_name); if (seenInterfaces.contains(name)) continue; -- cgit v1.2.3 From 8cd67bbfac5783cd77f1e0617dc4c938dfd44229 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 2 Dec 2015 12:37:06 -0800 Subject: QNetworkInterface: don't add a QNetworkAddressEntry if no IP is known If SIOCGIFADDR fails, then don't bother trying to get the broadcast address or netmask, and especially don't add the empty QNetworkAddressEntry to the interface. This can happen on interfaces that have no IP address assigned (for example, inactive interfaces). Change-Id: I8de47ed6c7be4847b99bffff141c326d94ecca78 Reviewed-by: Richard J. Moore --- src/network/kernel/qnetworkinterface_unix.cpp | 34 +++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/network/kernel/qnetworkinterface_unix.cpp b/src/network/kernel/qnetworkinterface_unix.cpp index b734476dc2..eb73a2fb18 100644 --- a/src/network/kernel/qnetworkinterface_unix.cpp +++ b/src/network/kernel/qnetworkinterface_unix.cpp @@ -268,29 +268,29 @@ static QList interfaceListing() } #endif - // Get the interface broadcast address - QNetworkAddressEntry entry; - if (iface->flags & QNetworkInterface::CanBroadcast) { - if (qt_safe_ioctl(socket, SIOCGIFBRDADDR, &req) >= 0) { - sockaddr *sa = &req.ifr_addr; - if (sa->sa_family == AF_INET) - entry.setBroadcast(addressFromSockaddr(sa)); - } - } - // Get the address of the interface + QNetworkAddressEntry entry; 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)); - } + // Get the interface broadcast address + if (iface->flags & QNetworkInterface::CanBroadcast) { + if (qt_safe_ioctl(socket, SIOCGIFBRDADDR, &req) >= 0) { + sockaddr *sa = &req.ifr_addr; + if (sa->sa_family == AF_INET) + entry.setBroadcast(addressFromSockaddr(sa)); + } + } - iface->addressEntries << entry; + // Get the interface netmask + if (qt_safe_ioctl(socket, SIOCGIFNETMASK, &req) >= 0) { + sockaddr *sa = &req.ifr_addr; + entry.setNetmask(addressFromSockaddr(sa)); + } + + iface->addressEntries << entry; + } } ::close(socket); -- cgit v1.2.3 From 143c68436449203e83a3b2f49d9176d0e89d85a0 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 19 Jan 2016 07:45:13 -0800 Subject: Fix the use of R_X86_64_GOTPCREL on a 64-bit field: it should be 32-bit The ABI says that PC-relative displacements should be on 32-bit fields, even on 64-bit builds. For -mcmodel=large, it should use R_X86_64_GOT64 relocations, like 32-bit. Task-number: QTBUG-50537 Change-Id: I1041122c530b4f5bbaabffff142ade5b3cbfc4c5 Reviewed-by: Oswald Buddenhagen Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/global/qversiontagging.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qversiontagging.h b/src/corelib/global/qversiontagging.h index 4a1c01c89d..d6b4a65600 100644 --- a/src/corelib/global/qversiontagging.h +++ b/src/corelib/global/qversiontagging.h @@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE * qt_version_tag symbol that is present in QtCore. Such symbol is versioned, * so the linker will automatically pull the current Qt version and add it to * the ELF header of the library/application. The assembly produces one section - * called ".qtversion" containing two pointer-sized values. The first is a + * called ".qtversion" containing two 32-bit values. The first is a * relocation to the qt_version_tag symbol (which is what causes the ELF * version to get used). The second value is the current Qt version at the time * of compilation. @@ -58,10 +58,12 @@ QT_BEGIN_NAMESPACE // don't make tags in QtCore, bootstrapped systems or if the user asked not to #elif defined(Q_CC_GNU) && !defined(Q_OS_ANDROID) # if defined(Q_PROCESSOR_X86) && (defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD_KERNEL)) -# ifdef __LP64__ -# define QT_VERSION_TAG_RELOC(sym) ".quad " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOTPCREL\n" -# elif defined(Q_PROCESSOR_X86_64) // x32 -# define QT_VERSION_TAG_RELOC(sym) ".long " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOTPCREL\n" +# if defined(Q_PROCESSOR_X86_64) // x86-64 or x32 +# if defined(__code_model_large__) +# define QT_VERSION_TAG_RELOC(sym) ".quad " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOT\n" +# else +# define QT_VERSION_TAG_RELOC(sym) ".long " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOTPCREL\n" +# endif # else // x86 # define QT_VERSION_TAG_RELOC(sym) ".long " QT_STRINGIFY(QT_MANGLE_NAMESPACE(sym)) "@GOT\n" # endif -- cgit v1.2.3 From f4502fbaf0d31d08bf08f1685f1d7b30735b72b4 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 20 Jan 2016 19:33:01 +0100 Subject: [docs] Fix reverse STL iteration example Use reverse_iterator, now that we finally have it. Change-Id: If74ead1a6075c5437c1d111206913481a495a014 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/doc/snippets/code/doc_src_containers.cpp | 7 +++---- src/corelib/doc/src/containers.qdoc | 4 +--- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/corelib/doc/snippets/code/doc_src_containers.cpp b/src/corelib/doc/snippets/code/doc_src_containers.cpp index 395e48bc89..5b0d829367 100644 --- a/src/corelib/doc/snippets/code/doc_src_containers.cpp +++ b/src/corelib/doc/snippets/code/doc_src_containers.cpp @@ -156,10 +156,9 @@ for (i = list.begin(); i != list.end(); ++i) QList list; list << "A" << "B" << "C" << "D"; -QList::iterator i = list.end(); -while (i != list.begin()) { - --i; - *i = (*i).toLower(); +QList::reverse_iterator i; +for (i = list.rbegin(); i != list.rend(); ++i) + *i = i->toLower(); } //! [11] diff --git a/src/corelib/doc/src/containers.qdoc b/src/corelib/doc/src/containers.qdoc index 0ae3817ac7..988f728946 100644 --- a/src/corelib/doc/src/containers.qdoc +++ b/src/corelib/doc/src/containers.qdoc @@ -472,9 +472,7 @@ \image stliterators1.png - Iterating backward with an STL-style iterator requires us to - decrement the iterator \e before we access the item. This - requires a \c while loop: + Iterating backward with an STL-style iterator is done with reverse iterators: \snippet code/doc_src_containers.cpp 11 -- cgit v1.2.3 From f05c597ae506ea6163394dbb6b70ecc77fae3b3c Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Fri, 11 Dec 2015 13:42:28 +0100 Subject: winrt: msvc2015: refactor file handling msvc2015 reintroduced a couple of functions from the win32 API towards WinRT. Enable usage of those and simplify the file system engine. Furthermore update the autotests. Change-Id: I9eafffba0ddfd05917c184c4a6b9e166f86d71d9 Reviewed-by: Oliver Wolff --- src/corelib/io/qdir.cpp | 11 ++++++++++ src/corelib/io/qfileinfo.cpp | 2 +- src/corelib/io/qfilesystemengine_win.cpp | 33 ++++++++++++++++++++++-------- src/corelib/io/qfilesystementry.cpp | 10 +++++++++ src/corelib/io/qfilesystemiterator_win.cpp | 3 ++- src/corelib/io/qfsfileengine_win.cpp | 2 +- 6 files changed, 49 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 4d2b36632f..2c2bdd579e 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -152,7 +152,11 @@ inline void QDirPrivate::setPath(const QString &path) if (p.endsWith(QLatin1Char('/')) && p.length() > 1 #if defined(Q_OS_WIN) +# if defined (Q_OS_WINRT) + && (!(p.toLower() == QDir::rootPath().toLower())) +# else && (!(p.length() == 3 && p.at(1).unicode() == ':' && p.at(0).isLetter())) +# endif #endif ) { p.truncate(p.length() - 1); @@ -885,6 +889,9 @@ bool QDir::cd(const QString &dirName) #if defined (Q_OS_UNIX) //After cleanPath() if path is "/.." or starts with "/../" it means trying to cd above root. if (newPath.startsWith(QLatin1String("/../")) || newPath == QLatin1String("/..")) +#elif defined (Q_OS_WINRT) + const QString rootPath = QDir::rootPath(); + if (newPath.size() < rootPath.size() && rootPath.startsWith(newPath)) #else /* cleanPath() already took care of replacing '\' with '/'. @@ -2187,7 +2194,11 @@ QString QDir::cleanPath(const QString &path) // Strip away last slash except for root directories if (ret.length() > 1 && ret.endsWith(QLatin1Char('/'))) { #if defined (Q_OS_WIN) +# if defined(Q_OS_WINRT) + if (!((ret.length() == 3 || ret.length() == QDir::rootPath().length()) && ret.at(1) == QLatin1Char(':'))) +# else if (!(ret.length() == 3 && ret.at(1) == QLatin1Char(':'))) +# endif #endif ret.chop(1); } diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index 51b39b1114..dd194594c9 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -1095,7 +1095,7 @@ bool QFileInfo::isRoot() const return true; if (d->fileEngine == 0) { if (d->fileEntry.isRoot()) { -#if defined(Q_OS_WIN) +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) //the path is a drive root, but the drive may not exist //for backward compatibility, return true only if the drive exists if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::ExistsAttribute)) diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 379095a83d..f1a6019094 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -78,6 +78,11 @@ using namespace Microsoft::WRL::Wrappers; using namespace ABI::Windows::Foundation; using namespace ABI::Windows::Storage; using namespace ABI::Windows::ApplicationModel; + +#if _MSC_VER < 1900 +#define Q_OS_WINRT_WIN81 +#endif + #endif // Q_OS_WINRT #ifndef SPI_GETPLATFORMTYPE @@ -522,7 +527,7 @@ QString QFileSystemEngine::nativeAbsoluteFilePath(const QString &path) { // can be //server or //server/share QString absPath; -#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT_WIN81) QVarLengthArray buf(qMax(MAX_PATH, path.size() + 1)); wchar_t *fileName = 0; DWORD retLen = GetFullPathName((wchar_t*)path.utf16(), buf.size(), buf.data(), &fileName); @@ -532,6 +537,16 @@ QString QFileSystemEngine::nativeAbsoluteFilePath(const QString &path) } if (retLen != 0) absPath = QString::fromWCharArray(buf.data(), retLen); +# if defined(Q_OS_WINRT) + // Win32 returns eg C:/ as root directory with a trailing /. + // WinRT returns the sandbox root without /. + // Also C:/../.. returns C:/ on Win32, while for WinRT it steps outside the package + // and goes beyond package root. Hence force the engine to stay inside + // the package. + const QString rootPath = QDir::toNativeSeparators(QDir::rootPath()); + if (absPath.size() < rootPath.size() && rootPath.startsWith(absPath)) + absPath = rootPath; +# endif // Q_OS_WINRT #elif !defined(Q_OS_WINCE) if (QDir::isRelativePath(path)) absPath = QDir::toNativeSeparators(QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + path)); @@ -569,7 +584,7 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) ret = entry.filePath(); #endif } else { -#ifndef Q_OS_WINRT +#ifndef Q_OS_WINRT_WIN81 ret = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + entry.filePath()); #else // Some WinRT APIs do not support absolute paths (due to sandboxing). @@ -1218,8 +1233,8 @@ QString QFileSystemEngine::rootPath() if (FAILED(item->get_Path(finalWinPath.GetAddressOf()))) return ret; - ret = QDir::fromNativeSeparators(QString::fromWCharArray(finalWinPath.GetRawBuffer(nullptr))); - + const QString qtWinPath = QDir::fromNativeSeparators(QString::fromWCharArray(finalWinPath.GetRawBuffer(nullptr))); + ret = qtWinPath.endsWith(QLatin1Char('/')) ? qtWinPath : qtWinPath + QLatin1Char('/'); #else QString ret = QString::fromLatin1(qgetenv("SystemDrive")); if (ret.isEmpty()) @@ -1337,7 +1352,7 @@ bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &entry) if(!(meta.exists() && meta.isDirectory())) return false; -#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT_WIN81) //TODO: this should really be using nativeFilePath(), but that returns a path in long format \\?\c:\foo //which causes many problems later on when it's returned through currentPath() return ::SetCurrentDirectory(reinterpret_cast(QDir::toNativeSeparators(entry.filePath()).utf16())) != 0; @@ -1350,7 +1365,7 @@ bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &entry) QFileSystemEntry QFileSystemEngine::currentPath() { QString ret; -#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) +#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT_WIN81) DWORD size = 0; wchar_t currentName[PATH_MAX]; size = ::GetCurrentDirectory(PATH_MAX, currentName); @@ -1366,17 +1381,17 @@ QFileSystemEntry QFileSystemEngine::currentPath() } if (ret.length() >= 2 && ret[1] == QLatin1Char(':')) ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters. -#else // !Q_OS_WINCE && !Q_OS_WINRT +#else // !Q_OS_WINCE && !Q_OS_WINRT_WIN81 //TODO - a race condition exists when using currentPath / setCurrentPath from multiple threads if (qfsPrivateCurrentDir.isEmpty()) -#ifndef Q_OS_WINRT +#ifndef Q_OS_WINRT_WIN81 qfsPrivateCurrentDir = QCoreApplication::applicationDirPath(); #else qfsPrivateCurrentDir = QDir::rootPath(); #endif ret = qfsPrivateCurrentDir; -#endif // Q_OS_WINCE || Q_OS_WINRT +#endif // Q_OS_WINCE || Q_OS_WINRT_WIN81 return QFileSystemEntry(ret, QFileSystemEntry::FromNativePath()); } diff --git a/src/corelib/io/qfilesystementry.cpp b/src/corelib/io/qfilesystementry.cpp index 709970e3ac..c590d81f7a 100644 --- a/src/corelib/io/qfilesystementry.cpp +++ b/src/corelib/io/qfilesystementry.cpp @@ -166,6 +166,12 @@ void QFileSystemEntry::resolveNativeFilePath() const m_nativeFilePath.remove(0,1); if (m_nativeFilePath.isEmpty()) m_nativeFilePath.append(QLatin1Char('.')); + // WinRT/MSVC2015 allows a maximum of 256 characters for a filepath + // unless //?/ is prepended which extends the rule to have a maximum + // of 256 characters in the filename plus the preprending path +#if _MSC_VER >= 1900 + m_nativeFilePath.prepend("\\\\?\\"); +#endif #endif } } @@ -283,9 +289,13 @@ bool QFileSystemEntry::isAbsolute() const bool QFileSystemEntry::isDriveRoot() const { resolveFilePath(); +#ifndef Q_OS_WINRT return (m_filePath.length() == 3 && m_filePath.at(0).isLetter() && m_filePath.at(1) == QLatin1Char(':') && m_filePath.at(2) == QLatin1Char('/')); +#else // !Q_OS_WINRT + return m_filePath == QDir::rootPath(); +#endif // !Q_OS_WINRT } #endif diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp index 6351a3559d..d7fed87222 100644 --- a/src/corelib/io/qfilesystemiterator_win.cpp +++ b/src/corelib/io/qfilesystemiterator_win.cpp @@ -67,7 +67,8 @@ QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Fi if (!nativePath.endsWith(QLatin1Char('\\'))) nativePath.append(QLatin1Char('\\')); nativePath.append(QLatin1Char('*')); -#ifdef Q_OS_WINRT + // In MSVC2015+ case we prepend //?/ for longer file-name support +#if defined(Q_OS_WINRT) && _MSC_VER < 1900 if (nativePath.startsWith(QLatin1Char('\\'))) nativePath.remove(0, 1); #endif diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index cfd50955a6..886d526fb1 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -1037,7 +1037,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, offsetHi, offsetLo, size + extra); #else LPVOID mapAddress = ::MapViewOfFileFromApp(mapHandle, access, - (ULONG64(offsetHi) << 32) + offsetLo, size); + (ULONG64(offsetHi) << 32) + offsetLo, size + extra); #endif if (mapAddress) { uchar *address = extra + static_cast(mapAddress); -- cgit v1.2.3 From 1f9a06c2949cd206235e75d20d0183fee927cb3e Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Wed, 20 Jan 2016 11:26:19 +0100 Subject: winrt: Fix potential crash in readDatagram The native socket engine used strcpy for WinRT, which tries to copy terminating null character. The QSocketNotifier::async_readDatagramSlot autotest uses a buffer of size 1, which causes readDatagram to overwrite the buffer on the stack. Hence use memcpy instead to protect from additional copies beyond barriers. Note that we cannot use qstrcpy as that does a buf[size-1] = '\0' at the end, which would remove content for a buf size of 1. Change-Id: I20baf9e63646cd28c1c954a20b8ae9c7d5873c31 Reviewed-by: Oliver Wolff --- src/network/socket/qnativesocketengine_winrt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp index 1c68b28784..35b7d5474b 100644 --- a/src/network/socket/qnativesocketengine_winrt.cpp +++ b/src/network/socket/qnativesocketengine_winrt.cpp @@ -578,7 +578,7 @@ qint64 QNativeSocketEngine::readDatagram(char *data, qint64 maxlen, QIpPacketHea } else { readOrigin = datagram.data; } - strcpy(data, readOrigin); + memcpy(data, readOrigin, qMin(maxlen, qint64(datagram.data.length()))); return readOrigin.length(); } -- cgit v1.2.3 From 26379d0320637b11519a2f161fb458eb9360ed88 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 20 Jan 2016 09:36:35 +0100 Subject: QGnomeTheme: Change the QFont members to pointer members. When initializing the font members in the QGnomeTheme constructor, the QFont constructor called QGuiApplication::font() which in turn calls initFontUnlocked(), initializing QGuiApplicationPrivate::app_font to QPlatformFontDatabase::defaultFont() ("Deja Vu 12") since QGuiApplicationPrivate::platformTheme() is still 0 at that point. Change the fonts to pointer members and initialize them delayed in QGnomeThemePrivate::configureFonts() instead. Task-number: QTBUG-49095 Change-Id: I3282ea8484e04827be2a424f5ea3e34d607c4bc5 Reviewed-by: Allan Sandfeld Jensen --- .../themes/genericunix/qgenericunixthemes.cpp | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp index 8f6171f217..0bcd3464b7 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp @@ -577,23 +577,23 @@ const char *QGnomeTheme::name = "gnome"; class QGnomeThemePrivate : public QPlatformThemePrivate { public: - QGnomeThemePrivate() : fontsConfigured(false) { } + QGnomeThemePrivate() : systemFont(Q_NULLPTR), fixedFont(Q_NULLPTR) {} + ~QGnomeThemePrivate() { delete systemFont; delete fixedFont; } + void configureFonts(const QString >kFontName) const { - Q_ASSERT(!fontsConfigured); + Q_ASSERT(!systemFont); const int split = gtkFontName.lastIndexOf(QChar::Space); float size = gtkFontName.mid(split+1).toFloat(); QString fontName = gtkFontName.left(split); - systemFont = QFont(fontName, size); - fixedFont = QFont(QLatin1String("monospace"), systemFont.pointSize()); - fixedFont.setStyleHint(QFont::TypeWriter); - fontsConfigured = true; + systemFont = new QFont(fontName, size); + fixedFont = new QFont(QLatin1String("monospace"), systemFont->pointSize()); + fixedFont->setStyleHint(QFont::TypeWriter); } - mutable QFont systemFont; - mutable QFont fixedFont; - mutable bool fontsConfigured; + mutable QFont *systemFont; + mutable QFont *fixedFont; }; QGnomeTheme::QGnomeTheme() @@ -632,13 +632,13 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const const QFont *QGnomeTheme::font(Font type) const { Q_D(const QGnomeTheme); - if (!d->fontsConfigured) + if (!d->systemFont) d->configureFonts(gtkFontName()); switch (type) { case QPlatformTheme::SystemFont: - return &d->systemFont; + return d->systemFont; case QPlatformTheme::FixedFont: - return &d->fixedFont; + return d->fixedFont; default: return 0; } -- cgit v1.2.3 From acb2e873f0cfbddbf8a9d23004e1eefbb47fd0fe Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 20 Jan 2016 09:57:41 +0100 Subject: QtPlatformSupport: Remove virtual from declarations with override. Change-Id: If94207596411680dfc2dbe33f298dc48fd5b7cc0 Reviewed-by: Konstantin Ritt Reviewed-by: Marc Mutz --- src/gui/text/qfontengine_ft_p.h | 92 +++++++++++----------- .../fbconvenience/qfbbackingstore_p.h | 6 +- src/platformsupport/linuxaccessibility/bridge_p.h | 2 +- .../services/genericunix/qgenericunixservices_p.h | 4 +- .../themes/genericunix/qgenericunixthemes_p.h | 14 ++-- 5 files changed, 59 insertions(+), 59 deletions(-) (limited to 'src') diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h index 83f9a4ef3d..6f05645a3f 100644 --- a/src/gui/text/qfontengine_ft_p.h +++ b/src/gui/text/qfontengine_ft_p.h @@ -189,65 +189,65 @@ private: mutable int fast_glyph_count; }; - virtual QFontEngine::FaceId faceId() const Q_DECL_OVERRIDE; - virtual QFontEngine::Properties properties() const Q_DECL_OVERRIDE; - virtual QFixed emSquareSize() const Q_DECL_OVERRIDE; - virtual bool supportsSubPixelPositions() const Q_DECL_OVERRIDE + QFontEngine::FaceId faceId() const Q_DECL_OVERRIDE; + QFontEngine::Properties properties() const Q_DECL_OVERRIDE; + QFixed emSquareSize() const Q_DECL_OVERRIDE; + bool supportsSubPixelPositions() const Q_DECL_OVERRIDE { return default_hint_style == HintLight || default_hint_style == HintNone; } - virtual bool getSfntTableData(uint tag, uchar *buffer, uint *length) const Q_DECL_OVERRIDE; - virtual int synthesized() const Q_DECL_OVERRIDE; + bool getSfntTableData(uint tag, uchar *buffer, uint *length) const Q_DECL_OVERRIDE; + int synthesized() const Q_DECL_OVERRIDE; - virtual QFixed ascent() const Q_DECL_OVERRIDE; - virtual QFixed descent() const Q_DECL_OVERRIDE; - virtual QFixed leading() const Q_DECL_OVERRIDE; - virtual QFixed xHeight() const Q_DECL_OVERRIDE; - virtual QFixed averageCharWidth() const Q_DECL_OVERRIDE; + QFixed ascent() const Q_DECL_OVERRIDE; + QFixed descent() const Q_DECL_OVERRIDE; + QFixed leading() const Q_DECL_OVERRIDE; + QFixed xHeight() const Q_DECL_OVERRIDE; + QFixed averageCharWidth() const Q_DECL_OVERRIDE; - virtual qreal maxCharWidth() const Q_DECL_OVERRIDE; - virtual QFixed lineThickness() const Q_DECL_OVERRIDE; - virtual QFixed underlinePosition() const Q_DECL_OVERRIDE; + qreal maxCharWidth() const Q_DECL_OVERRIDE; + QFixed lineThickness() const Q_DECL_OVERRIDE; + QFixed underlinePosition() const Q_DECL_OVERRIDE; - virtual glyph_t glyphIndex(uint ucs4) const Q_DECL_OVERRIDE; + glyph_t glyphIndex(uint ucs4) const Q_DECL_OVERRIDE; void doKerning(QGlyphLayout *, ShaperFlags) const Q_DECL_OVERRIDE; - virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics) Q_DECL_OVERRIDE; + void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics) Q_DECL_OVERRIDE; - virtual bool supportsTransformation(const QTransform &transform) const Q_DECL_OVERRIDE; + bool supportsTransformation(const QTransform &transform) const Q_DECL_OVERRIDE; - virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs, - QPainterPath *path, QTextItem::RenderFlags flags) Q_DECL_OVERRIDE; - virtual void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, - QPainterPath *path, QTextItem::RenderFlags flags) Q_DECL_OVERRIDE; + void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs, + QPainterPath *path, QTextItem::RenderFlags flags) Q_DECL_OVERRIDE; + void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, + QPainterPath *path, QTextItem::RenderFlags flags) Q_DECL_OVERRIDE; - virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const Q_DECL_OVERRIDE; + bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const Q_DECL_OVERRIDE; - virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs) Q_DECL_OVERRIDE; - virtual glyph_metrics_t boundingBox(glyph_t glyph) Q_DECL_OVERRIDE; - virtual glyph_metrics_t boundingBox(glyph_t glyph, const QTransform &matrix) Q_DECL_OVERRIDE; + glyph_metrics_t boundingBox(const QGlyphLayout &glyphs) Q_DECL_OVERRIDE; + glyph_metrics_t boundingBox(glyph_t glyph) Q_DECL_OVERRIDE; + glyph_metrics_t boundingBox(glyph_t glyph, const QTransform &matrix) Q_DECL_OVERRIDE; - virtual void recalcAdvances(QGlyphLayout *glyphs, ShaperFlags flags) const Q_DECL_OVERRIDE; - virtual QImage alphaMapForGlyph(glyph_t g) Q_DECL_OVERRIDE { return alphaMapForGlyph(g, 0); } - virtual QImage alphaMapForGlyph(glyph_t, QFixed) Q_DECL_OVERRIDE; + void recalcAdvances(QGlyphLayout *glyphs, ShaperFlags flags) const Q_DECL_OVERRIDE; + QImage alphaMapForGlyph(glyph_t g) Q_DECL_OVERRIDE { return alphaMapForGlyph(g, 0); } + QImage alphaMapForGlyph(glyph_t, QFixed) Q_DECL_OVERRIDE; QImage alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t) Q_DECL_OVERRIDE; - virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t) Q_DECL_OVERRIDE; - virtual glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, - QFixed subPixelPosition, - const QTransform &matrix, - QFontEngine::GlyphFormat format) Q_DECL_OVERRIDE; - virtual QImage *lockedAlphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, - GlyphFormat neededFormat, const QTransform &t, - QPoint *offset) Q_DECL_OVERRIDE; - virtual bool hasInternalCaching() const Q_DECL_OVERRIDE { return cacheEnabled; } - virtual void unlockAlphaMapForGlyph() Q_DECL_OVERRIDE; - - virtual void removeGlyphFromCache(glyph_t glyph) Q_DECL_OVERRIDE; - virtual int glyphMargin(QFontEngine::GlyphFormat /* format */) Q_DECL_OVERRIDE { return 0; } - - virtual int glyphCount() const Q_DECL_OVERRIDE; + QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t) Q_DECL_OVERRIDE; + glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, + QFixed subPixelPosition, + const QTransform &matrix, + QFontEngine::GlyphFormat format) Q_DECL_OVERRIDE; + QImage *lockedAlphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, + GlyphFormat neededFormat, const QTransform &t, + QPoint *offset) Q_DECL_OVERRIDE; + bool hasInternalCaching() const Q_DECL_OVERRIDE { return cacheEnabled; } + void unlockAlphaMapForGlyph() Q_DECL_OVERRIDE; + + void removeGlyphFromCache(glyph_t glyph) Q_DECL_OVERRIDE; + int glyphMargin(QFontEngine::GlyphFormat /* format */) Q_DECL_OVERRIDE { return 0; } + + int glyphCount() const Q_DECL_OVERRIDE; enum Scaling { Scaled, @@ -277,12 +277,12 @@ private: bool init(FaceId faceId, bool antialias, GlyphFormat format, QFreetypeFace *freetypeFace); - virtual int getPointInOutline(glyph_t glyph, int flags, quint32 point, QFixed *xpos, QFixed *ypos, quint32 *nPoints) Q_DECL_OVERRIDE; + int getPointInOutline(glyph_t glyph, int flags, quint32 point, QFixed *xpos, QFixed *ypos, quint32 *nPoints) Q_DECL_OVERRIDE; void setQtDefaultHintStyle(QFont::HintingPreference hintingPreference); - virtual void setDefaultHintStyle(HintStyle style) Q_DECL_OVERRIDE; + void setDefaultHintStyle(HintStyle style) Q_DECL_OVERRIDE; - virtual QFontEngine *cloneWithSize(qreal pixelSize) const Q_DECL_OVERRIDE; + QFontEngine *cloneWithSize(qreal pixelSize) const Q_DECL_OVERRIDE; bool initFromFontEngine(const QFontEngineFT *fontEngine); HintStyle defaultHintStyle() const { return default_hint_style; } diff --git a/src/platformsupport/fbconvenience/qfbbackingstore_p.h b/src/platformsupport/fbconvenience/qfbbackingstore_p.h index 1dc8127fed..3a44128449 100644 --- a/src/platformsupport/fbconvenience/qfbbackingstore_p.h +++ b/src/platformsupport/fbconvenience/qfbbackingstore_p.h @@ -60,10 +60,10 @@ public: QFbBackingStore(QWindow *window); ~QFbBackingStore(); - virtual QPaintDevice *paintDevice() Q_DECL_OVERRIDE { return &mImage; } - virtual void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) Q_DECL_OVERRIDE; + QPaintDevice *paintDevice() Q_DECL_OVERRIDE { return &mImage; } + void flush(QWindow *window, const QRegion ®ion, const QPoint &offset) Q_DECL_OVERRIDE; - virtual void resize(const QSize &size, const QRegion ®ion) Q_DECL_OVERRIDE; + void resize(const QSize &size, const QRegion ®ion) Q_DECL_OVERRIDE; const QImage image(); diff --git a/src/platformsupport/linuxaccessibility/bridge_p.h b/src/platformsupport/linuxaccessibility/bridge_p.h index 802b1e4725..69ab618e17 100644 --- a/src/platformsupport/linuxaccessibility/bridge_p.h +++ b/src/platformsupport/linuxaccessibility/bridge_p.h @@ -66,7 +66,7 @@ public: virtual ~QSpiAccessibleBridge(); - virtual void notifyAccessibilityUpdate(QAccessibleEvent *event) Q_DECL_OVERRIDE; + void notifyAccessibilityUpdate(QAccessibleEvent *event) Q_DECL_OVERRIDE; QDBusConnection dBusConnection() const; public Q_SLOTS: diff --git a/src/platformsupport/services/genericunix/qgenericunixservices_p.h b/src/platformsupport/services/genericunix/qgenericunixservices_p.h index 0c15d62165..89d5a4dab4 100644 --- a/src/platformsupport/services/genericunix/qgenericunixservices_p.h +++ b/src/platformsupport/services/genericunix/qgenericunixservices_p.h @@ -57,8 +57,8 @@ public: QByteArray desktopEnvironment() const Q_DECL_OVERRIDE; - virtual bool openUrl(const QUrl &url) Q_DECL_OVERRIDE; - virtual bool openDocument(const QUrl &url) Q_DECL_OVERRIDE; + bool openUrl(const QUrl &url) Q_DECL_OVERRIDE; + bool openDocument(const QUrl &url) Q_DECL_OVERRIDE; private: QString m_webBrowser; diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h index 115b9d9f91..77aa04fe95 100644 --- a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h +++ b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h @@ -75,8 +75,8 @@ public: static QPlatformTheme *createUnixTheme(const QString &name); static QStringList themeNames(); - virtual const QFont *font(Font type) const Q_DECL_OVERRIDE; - virtual QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE; + const QFont *font(Font type) const Q_DECL_OVERRIDE; + QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE; static QStringList xdgIconThemePaths(); #if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON) @@ -96,11 +96,11 @@ public: QKdeTheme(const QStringList& kdeDirs, int kdeVersion); static QPlatformTheme *createKdeTheme(); - virtual QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE; + QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE; - virtual const QPalette *palette(Palette type = SystemPalette) const Q_DECL_OVERRIDE; + const QPalette *palette(Palette type = SystemPalette) const Q_DECL_OVERRIDE; - virtual const QFont *font(Font type) const Q_DECL_OVERRIDE; + const QFont *font(Font type) const Q_DECL_OVERRIDE; #if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON) QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const Q_DECL_OVERRIDE; #endif @@ -116,8 +116,8 @@ class QGnomeTheme : public QPlatformTheme Q_DECLARE_PRIVATE(QGnomeTheme) public: QGnomeTheme(); - virtual QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE; - virtual const QFont *font(Font type) const Q_DECL_OVERRIDE; + QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE; + const QFont *font(Font type) const Q_DECL_OVERRIDE; QString standardButtonText(int button) const Q_DECL_OVERRIDE; virtual QString gtkFontName() const; -- cgit v1.2.3 From 19866d8861ddb575c9fd50e0d47cd59af8025db2 Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Thu, 14 Jan 2016 20:09:52 +0300 Subject: Fix pixmap types in org.kde.StatusNotifierItem.xml According to the spec, pixmap type is ARRAY(INT, INT, ARRAY BYTE). This also matches our QXdgDBusImageVector typedef. Also fix the D-Bus Introspection class info. Change-Id: Ic13e8a078299b9c76d2742055d64cfdc54460d58 Reviewed-by: Dmitry Shachnev Reviewed-by: Shawn Rutledge --- src/3rdparty/dbus-ifaces/org.kde.StatusNotifierItem.xml | 8 ++++---- src/platformsupport/dbustray/qstatusnotifieritemadaptor_p.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/3rdparty/dbus-ifaces/org.kde.StatusNotifierItem.xml b/src/3rdparty/dbus-ifaces/org.kde.StatusNotifierItem.xml index aeeb42fa87..1cbd78a9c3 100644 --- a/src/3rdparty/dbus-ifaces/org.kde.StatusNotifierItem.xml +++ b/src/3rdparty/dbus-ifaces/org.kde.StatusNotifierItem.xml @@ -19,13 +19,13 @@ - + - + @@ -34,7 +34,7 @@ - + @@ -45,7 +45,7 @@ - + diff --git a/src/platformsupport/dbustray/qstatusnotifieritemadaptor_p.h b/src/platformsupport/dbustray/qstatusnotifieritemadaptor_p.h index c3849f0e03..46f605a480 100644 --- a/src/platformsupport/dbustray/qstatusnotifieritemadaptor_p.h +++ b/src/platformsupport/dbustray/qstatusnotifieritemadaptor_p.h @@ -86,19 +86,19 @@ class QStatusNotifierItemAdaptor: public QDBusAbstractAdaptor " \n" " \n" " \n" -" \n" +" \n" " \n" " \n" " \n" -" \n" +" \n" " \n" " \n" " \n" -" \n" +" \n" " \n" " \n" " \n" -" \n" +" \n" " \n" " \n" " \n" -- cgit v1.2.3 From 1185c28f2f408d858c148062bb0125974905ef22 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 18 Jan 2016 12:40:41 +0100 Subject: Fix some mis-guided fall-throughs #ifdef QT_BOOTSTRAPPED. A switch had a case whose body was in a #ifndef; when that got elided, this case fell through into an entirely misguided case. Give the #if a #else clause so that it break;s in the defined case. Code review revealed another, then I searched for more following the same pattern. Change-Id: I57fb59b6c8d349604f3fc6c8b1d424fb3c775d50 Reviewed-by: Thiago Macieira --- src/corelib/tools/qdatetime.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index ff20c57166..491ed99301 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -2697,10 +2697,11 @@ qint64 QDateTimePrivate::toMSecsSinceEpoch() const } case Qt::TimeZone: -#ifndef QT_BOOTSTRAPPED +#ifdef QT_BOOTSTRAPPED + break; +#else return zoneMSecsToEpochMSecs(m_msecs, m_timeZone); #endif - break; } Q_UNREACHABLE(); return 0; @@ -3197,7 +3198,9 @@ QString QDateTime::timeZoneAbbreviation() const case Qt::OffsetFromUTC: return QTimeZonePrivate::utcQString() + toOffsetString(Qt::ISODate, d->m_offsetFromUtc); case Qt::TimeZone: -#ifndef QT_BOOTSTRAPPED +#ifdef QT_BOOTSTRAPPED + break; +#else return d->m_timeZone.d->abbreviation(d->toMSecsSinceEpoch()); #endif // QT_BOOTSTRAPPED case Qt::LocalTime: { @@ -3228,7 +3231,9 @@ bool QDateTime::isDaylightTime() const case Qt::OffsetFromUTC: return false; case Qt::TimeZone: -#ifndef QT_BOOTSTRAPPED +#ifdef QT_BOOTSTRAPPED + break; +#else return d->m_timeZone.d->isDaylightTime(toMSecsSinceEpoch()); #endif // QT_BOOTSTRAPPED case Qt::LocalTime: { @@ -4820,10 +4825,8 @@ QDataStream &operator<<(QDataStream &out, const QDateTime &dateTime) out << (qint8)QDateTimePrivate::OffsetFromUTC; break; case Qt::TimeZone: -#ifndef QT_BOOTSTRAPPED out << (qint8)QDateTimePrivate::TimeZone; break; -#endif // QT_BOOTSTRAPPED case Qt::LocalTime: out << (qint8)QDateTimePrivate::LocalUnknown; break; @@ -4896,10 +4899,11 @@ QDataStream &operator>>(QDataStream &in, QDateTime &dateTime) spec = Qt::OffsetFromUTC; break; case QDateTimePrivate::TimeZone: -#ifndef QT_BOOTSTRAPPED spec = Qt::TimeZone; +#ifndef QT_BOOTSTRAPPED + // FIXME: need to use a different constructor ! +#endif break; -#endif // QT_BOOTSTRAPPED case QDateTimePrivate::LocalUnknown: case QDateTimePrivate::LocalStandard: case QDateTimePrivate::LocalDST: @@ -4955,8 +4959,8 @@ QDebug operator<<(QDebug dbg, const QDateTime &date) case Qt::TimeZone: #ifndef QT_BOOTSTRAPPED dbg << ' ' << date.timeZone().id(); - break; #endif // QT_BOOTSTRAPPED + break; case Qt::LocalTime: break; } -- cgit v1.2.3 From 7edd488a5f1d5ac2e21ce08177a0d733185e38df Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 20 Jan 2016 15:50:55 +0100 Subject: eglfs: Detect llvmpipe and show a warning Do ourselves and our users a favor by pointing out why Qt (Quick) apps perform horribly on commonly used distros on the RPi. Using a software rasterizer on such boards is not going to cut it. Task-number: QTBUG-50533 Change-Id: I087f502ddb9c6bdde84343e6abd85c87cdc474f0 Reviewed-by: Andy Nichols --- src/platformsupport/eglconvenience/qeglplatformcontext.cpp | 7 +++++++ src/platformsupport/eglconvenience/qeglplatformcontext_p.h | 1 + src/plugins/platforms/eglfs/qeglfscontext.cpp | 10 ++++++++++ src/plugins/platforms/eglfs/qeglfscontext.h | 1 + 4 files changed, 19 insertions(+) (limited to 'src') diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp index acd6197ed5..f5ba587293 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp +++ b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp @@ -275,6 +275,12 @@ void QEGLPlatformContext::destroyTemporaryOffscreenSurface(EGLSurface surface) eglDestroySurface(m_eglDisplay, surface); } +void QEGLPlatformContext::runGLChecks() +{ + // Nothing to do here, subclasses may override in order to perform OpenGL + // queries needing a context. +} + void QEGLPlatformContext::updateFormatFromGL() { #ifndef QT_NO_OPENGL @@ -346,6 +352,7 @@ void QEGLPlatformContext::updateFormatFromGL() } } } + runGLChecks(); eglMakeCurrent(prevDisplay, prevSurfaceDraw, prevSurfaceRead, prevContext); } else { qWarning("QEGLPlatformContext: Failed to make temporary surface current, format not updated (%x)", eglGetError()); diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h b/src/platformsupport/eglconvenience/qeglplatformcontext_p.h index 2fa465556b..41601272a3 100644 --- a/src/platformsupport/eglconvenience/qeglplatformcontext_p.h +++ b/src/platformsupport/eglconvenience/qeglplatformcontext_p.h @@ -84,6 +84,7 @@ protected: virtual EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) = 0; virtual EGLSurface createTemporaryOffscreenSurface(); virtual void destroyTemporaryOffscreenSurface(EGLSurface surface); + virtual void runGLChecks(); private: void init(const QSurfaceFormat &format, QPlatformOpenGLContext *share); diff --git a/src/plugins/platforms/eglfs/qeglfscontext.cpp b/src/plugins/platforms/eglfs/qeglfscontext.cpp index 6fcdae7ad2..db35338423 100644 --- a/src/plugins/platforms/eglfs/qeglfscontext.cpp +++ b/src/plugins/platforms/eglfs/qeglfscontext.cpp @@ -85,6 +85,16 @@ void QEglFSContext::destroyTemporaryOffscreenSurface(EGLSurface surface) } } +void QEglFSContext::runGLChecks() +{ + // Note that even though there is an EGL context current here, + // QOpenGLContext and QOpenGLFunctions are not yet usable at this stage. + const char *renderer = reinterpret_cast(glGetString(GL_RENDERER)); + // Be nice and warn about a common source of confusion. + if (renderer && strstr(renderer, "llvmpipe")) + qWarning("Running on a software rasterizer (LLVMpipe), expect limited performance."); +} + void QEglFSContext::swapBuffers(QPlatformSurface *surface) { // draw the cursor diff --git a/src/plugins/platforms/eglfs/qeglfscontext.h b/src/plugins/platforms/eglfs/qeglfscontext.h index 612960dc24..906d11b3d1 100644 --- a/src/plugins/platforms/eglfs/qeglfscontext.h +++ b/src/plugins/platforms/eglfs/qeglfscontext.h @@ -48,6 +48,7 @@ public: EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) Q_DECL_OVERRIDE; EGLSurface createTemporaryOffscreenSurface() Q_DECL_OVERRIDE; void destroyTemporaryOffscreenSurface(EGLSurface surface) Q_DECL_OVERRIDE; + void runGLChecks() Q_DECL_OVERRIDE; void swapBuffers(QPlatformSurface *surface) Q_DECL_OVERRIDE; private: -- cgit v1.2.3 From c3850dd636ab24c251942fde63f22d8f5b3a639e Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Tue, 24 Nov 2015 10:23:23 +0400 Subject: QString: optimize case conversion code Handle special case mapping of length 1 explicitly; Skip calculating of high surrogate for the same plane; Optimize branch prediction with Q_LIKELY/Q_UNLIKELY; Replace peekNext() + advance() with just next() in the caller function. Change-Id: I0d37969749bd8ca855321242e6a0e72c405c5f8d Reviewed-by: Thiago Macieira --- src/corelib/tools/qstring.cpp | 54 ++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 89d9889b2f..39ec66c7f1 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -5709,37 +5709,42 @@ static QString detachAndConvertCase(T &str, QStringIterator it) Q_ASSERT(!str.isEmpty()); QString s = qMove(str); // will copy if T is const QString QChar *pp = s.begin() + it.index(); // will detach if necessary - uint uc = it.nextUnchecked(); - forever { + + do { + uint uc = it.nextUnchecked(); + const QUnicodeTables::Properties *prop = qGetProp(uc); signed short caseDiff = Traits::caseDiff(prop); if (Q_UNLIKELY(Traits::caseSpecial(prop))) { - // slow path: the string is growing const ushort *specialCase = specialCaseMap + caseDiff; ushort length = *specialCase++; - int inpos = it.index() - 1; - int outpos = pp - s.constBegin(); - - s.replace(outpos, 1, reinterpret_cast(specialCase), length); - pp = const_cast(s.constBegin()) + outpos + length; - - // do we need to adjust the input iterator too? - // if it is pointing to s's data, str is empty - if (str.isEmpty()) - it = QStringIterator(s.constBegin(), inpos + length, s.constEnd()); - } else if (QChar::requiresSurrogates(uc)) { - *pp++ = QChar::highSurrogate(uc + caseDiff); + + if (Q_LIKELY(length == 1)) { + *pp++ = QChar(*specialCase); + } else { + // slow path: the string is growing + int inpos = it.index() - 1; + int outpos = pp - s.constBegin(); + + s.replace(outpos, 1, reinterpret_cast(specialCase), length); + pp = const_cast(s.constBegin()) + outpos + length; + + // do we need to adjust the input iterator too? + // if it is pointing to s's data, str is empty + if (str.isEmpty()) + it = QStringIterator(s.constBegin(), inpos + length, s.constEnd()); + } + } else if (Q_UNLIKELY(QChar::requiresSurrogates(uc))) { + // so far, case convertion never changes planes (guaranteed by the qunicodetables generator) + pp++; *pp++ = QChar::lowSurrogate(uc + caseDiff); } else { *pp++ = QChar(uc + caseDiff); } + } while (it.hasNext()); - if (!it.hasNext()) - return s; - - uc = it.nextUnchecked(); - } + return s; } template @@ -5752,12 +5757,13 @@ static QString convertCase(T &str) while (e != p && e[-1].isHighSurrogate()) --e; - const QUnicodeTables::Properties *prop; QStringIterator it(p, e); - for ( ; it.hasNext(); it.advanceUnchecked()) { - prop = qGetProp(it.peekNextUnchecked()); - if (Traits::caseDiff(prop)) + while (it.hasNext()) { + uint uc = it.nextUnchecked(); + if (Traits::caseDiff(qGetProp(uc))) { + it.recedeUnchecked(); return detachAndConvertCase(str, it); + } } return qMove(str); } -- cgit v1.2.3 From 24d851dcd2a140bf346343c5eb64d944cd1c1a87 Mon Sep 17 00:00:00 2001 From: Tobias Koenig Date: Tue, 19 Jan 2016 17:45:42 +0100 Subject: Avoid heap allocations in Median class Create a MedianDouble class and V2 version of BlockSizeManager, which use a fixed size array of double (since we always use 7 elements to calculate the median anyway). Change-Id: Ife90b90336a9a8c037b90726dee4cd2a1b8b6cd9 Reviewed-by: Marc Mutz --- src/concurrent/qtconcurrentiteratekernel.cpp | 52 ++++++++++++++++++++++ src/concurrent/qtconcurrentiteratekernel.h | 28 +++++++++++- src/concurrent/qtconcurrentmedian.h | 66 ++++++++++++++++++++++++++++ 3 files changed, 145 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/concurrent/qtconcurrentiteratekernel.cpp b/src/concurrent/qtconcurrentiteratekernel.cpp index 49056406c3..3b9b186b39 100644 --- a/src/concurrent/qtconcurrentiteratekernel.cpp +++ b/src/concurrent/qtconcurrentiteratekernel.cpp @@ -182,6 +182,58 @@ int BlockSizeManager::blockSize() return m_blockSize; } +/*! \internal + +*/ +BlockSizeManagerV2::BlockSizeManagerV2(int iterationCount) + : maxBlockSize(iterationCount / (QThreadPool::globalInstance()->maxThreadCount() * 2)), + beforeUser(0), afterUser(0), + m_blockSize(1) +{ } + +// Records the time before user code. +void BlockSizeManagerV2::timeBeforeUser() +{ + if (blockSizeMaxed()) + return; + + beforeUser = getticks(); + controlPartElapsed.addValue(elapsed(beforeUser, afterUser)); +} + + // Records the time after user code and adjust the block size if we are spending + // to much time in the for control code compared with the user code. +void BlockSizeManagerV2::timeAfterUser() +{ + if (blockSizeMaxed()) + return; + + afterUser = getticks(); + userPartElapsed.addValue(elapsed(afterUser, beforeUser)); + + if (controlPartElapsed.isMedianValid() == false) + return; + + if (controlPartElapsed.median() * TargetRatio < userPartElapsed.median()) + return; + + m_blockSize = qMin(m_blockSize * 2, maxBlockSize); + +#ifdef QTCONCURRENT_FOR_DEBUG + qDebug() << QThread::currentThread() << "adjusting block size" << controlPartElapsed.median() << userPartElapsed.median() << m_blockSize; +#endif + + // Reset the medians after adjusting the block size so we get + // new measurements with the new block size. + controlPartElapsed.reset(); + userPartElapsed.reset(); +} + +int BlockSizeManagerV2::blockSize() +{ + return m_blockSize; +} + } // namespace QtConcurrent QT_END_NAMESPACE diff --git a/src/concurrent/qtconcurrentiteratekernel.h b/src/concurrent/qtconcurrentiteratekernel.h index 32acf03338..40e2c6c115 100644 --- a/src/concurrent/qtconcurrentiteratekernel.h +++ b/src/concurrent/qtconcurrentiteratekernel.h @@ -82,6 +82,32 @@ private: Q_DISABLE_COPY(BlockSizeManager) }; +// ### Qt6: Replace BlockSizeManager with V2 implementation +class Q_CONCURRENT_EXPORT BlockSizeManagerV2 +{ +public: + explicit BlockSizeManagerV2(int iterationCount); + + void timeBeforeUser(); + void timeAfterUser(); + int blockSize(); + +private: + inline bool blockSizeMaxed() + { + return (m_blockSize >= maxBlockSize); + } + + const int maxBlockSize; + qint64 beforeUser; + qint64 afterUser; + MedianDouble controlPartElapsed; + MedianDouble userPartElapsed; + int m_blockSize; + + Q_DISABLE_COPY(BlockSizeManagerV2) +}; + template class ResultReporter { @@ -190,7 +216,7 @@ public: ThreadFunctionResult forThreadFunction() { - BlockSizeManager blockSizeManager(iterationCount); + BlockSizeManagerV2 blockSizeManager(iterationCount); ResultReporter resultReporter(this); for(;;) { diff --git a/src/concurrent/qtconcurrentmedian.h b/src/concurrent/qtconcurrentmedian.h index 2ae7954b7a..e35e2aec70 100644 --- a/src/concurrent/qtconcurrentmedian.h +++ b/src/concurrent/qtconcurrentmedian.h @@ -121,6 +121,72 @@ private: bool dirty; }; +// ### Qt6: Drop Median in favor of this faster MedianDouble +class MedianDouble +{ +public: + enum { BufferSize = 7 }; + + MedianDouble() + : currentMedian(), currentIndex(0), valid(false), dirty(true) + { + } + + void reset() + { + std::fill_n(values, static_cast(BufferSize), 0.0); + currentIndex = 0; + valid = false; + dirty = true; + } + + void addValue(double value) + { + ++currentIndex; + if (currentIndex == BufferSize) { + currentIndex = 0; + valid = true; + } + + // Only update the cached median value when we have to, that + // is when the new value is on then other side of the median + // compared to the current value at the index. + const double currentIndexValue = values[currentIndex]; + if ((currentIndexValue > currentMedian && currentMedian > value) + || (currentMedian > currentIndexValue && value > currentMedian)) { + dirty = true; + } + + values[currentIndex] = value; + } + + bool isMedianValid() const + { + return valid; + } + + double median() + { + if (dirty) { + dirty = false; + + double sorted[BufferSize]; + ::memcpy(&sorted, &values, sizeof(sorted)); + std::sort(sorted, sorted + static_cast(BufferSize)); + currentMedian = sorted[BufferSize / 2]; + } + + return currentMedian; + } + +private: + double values[BufferSize]; + double currentMedian; + int currentIndex; + bool valid; + bool dirty; +}; + } // namespace QtConcurrent #endif //Q_QDOC -- cgit v1.2.3 From c7a86c5e0c2c46be0972dac8ed797abbe3ed44ae Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 18 Jan 2016 11:57:05 +0100 Subject: Remove dead code from QOpenGLPaintEngine These variables were never used or set to anything meaningfull. Change-Id: Ic68ac5c38a3db28d7a5a05be004bcb6a554a1483 Reviewed-by: Laszlo Agocs --- src/gui/opengl/qopenglpaintengine.cpp | 15 +-------------- src/gui/opengl/qopenglpaintengine_p.h | 5 ----- 2 files changed, 1 insertion(+), 19 deletions(-) (limited to 'src') diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp index 4836dde343..0b92bf4b1d 100644 --- a/src/gui/opengl/qopenglpaintengine.cpp +++ b/src/gui/opengl/qopenglpaintengine.cpp @@ -93,13 +93,6 @@ QOpenGL2PaintEngineExPrivate::~QOpenGL2PaintEngineExPrivate() { delete shaderManager; - while (pathCaches.size()) { - QVectorPath::CacheEntry *e = *(pathCaches.constBegin()); - e->cleanup(e->engine, e->data); - e->data = 0; - e->engine = 0; - } - if (elementIndicesVBOId != 0) { funcs.glDeleteBuffers(1, &elementIndicesVBOId); elementIndicesVBOId = 0; @@ -292,8 +285,6 @@ void QOpenGL2PaintEngineExPrivate::updateBrushTexture() } updateTexture(QT_BRUSH_TEXTURE_UNIT, currentBrushImage, wrapMode, filterMode, ForceUpdate); - - textureInvertedY = false; } brushTextureDirty = false; } @@ -409,11 +400,7 @@ void QOpenGL2PaintEngineExPrivate::updateBrushUniforms() dy = 0; } QTransform gl_to_qt(1, 0, 0, m22, 0, dy); - QTransform inv_matrix; - if (style == Qt::TexturePattern && textureInvertedY == -1) - inv_matrix = gl_to_qt * (QTransform(1, 0, 0, -1, 0, currentBrush.texture().height()) * brushQTransform * matrix).inverted() * translate; - else - inv_matrix = gl_to_qt * (brushQTransform * matrix).inverted() * translate; + QTransform inv_matrix = gl_to_qt * (brushQTransform * matrix).inverted() * translate; shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::BrushTransform), inv_matrix); shaderManager->currentProgram()->setUniformValue(location(QOpenGLEngineShaderManager::BrushTexture), QT_BRUSH_TEXTURE_UNIT); diff --git a/src/gui/opengl/qopenglpaintengine_p.h b/src/gui/opengl/qopenglpaintengine_p.h index 17be72b1e9..f1ec669ca0 100644 --- a/src/gui/opengl/qopenglpaintengine_p.h +++ b/src/gui/opengl/qopenglpaintengine_p.h @@ -309,14 +309,9 @@ public: bool needsSync; bool multisamplingAlwaysEnabled; - GLfloat depthRange[2]; - - float textureInvertedY; - QTriangulatingStroker stroker; QDashedStrokeProcessor dasher; - QSet pathCaches; QVector unusedVBOSToClean; QVector unusedIBOSToClean; -- cgit v1.2.3 From a01146aac104b05dcf5c7ddbe7b79a897e8bf414 Mon Sep 17 00:00:00 2001 From: Tobias Koenig Date: Tue, 19 Jan 2016 14:22:28 +0100 Subject: Use QFileInfo::exists(f) instead of QFileInfo(f).exists() QFileInfo::exists(f) is somewhat faster than the version which creates an temporary object. Change-Id: I5f931a86d9dfad57d99efe04ca115422de43def9 Reviewed-by: Thiago Macieira --- src/plugins/platforms/android/qandroidplatformtheme.cpp | 2 +- src/testlib/qtestcase.cpp | 10 +++++----- src/widgets/itemviews/qdirmodel.cpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/android/qandroidplatformtheme.cpp b/src/plugins/platforms/android/qandroidplatformtheme.cpp index 5531910555..d53d678bcf 100644 --- a/src/plugins/platforms/android/qandroidplatformtheme.cpp +++ b/src/plugins/platforms/android/qandroidplatformtheme.cpp @@ -195,7 +195,7 @@ QJsonObject AndroidStyle::loadStyleData() } Q_ASSERT(!stylePath.isEmpty()); - if (!androidTheme.isEmpty() && QFileInfo(stylePath + androidTheme + QLatin1String("style.json")).exists()) + if (!androidTheme.isEmpty() && QFileInfo::exists(stylePath + androidTheme + QLatin1String("style.json"))) stylePath += androidTheme; QFile f(stylePath + QLatin1String("style.json")); diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 286da52be2..36eff6ac98 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -3219,7 +3219,7 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co QString testsPath = QLibraryInfo::location(QLibraryInfo::TestsPath); QString candidate = QString::fromLatin1("%1/%2/%3") .arg(testsPath, QFile::decodeName(testObjectName).toLower(), base); - if (QFileInfo(candidate).exists()) { + if (QFileInfo::exists(candidate)) { found = candidate; } else if (QTestLog::verboseLevel() >= 2) { @@ -3244,7 +3244,7 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co } QString candidate = QString::fromLatin1("%1/%2").arg(srcdir.canonicalFilePath(), base); - if (QFileInfo(candidate).exists()) { + if (QFileInfo::exists(candidate)) { found = candidate; } else if (QTestLog::verboseLevel() >= 2) { @@ -3258,21 +3258,21 @@ QString QTest::qFindTestData(const QString& base, const char *file, int line, co // 4. Try resources if (found.isEmpty()) { QString candidate = QString::fromLatin1(":/%1").arg(base); - if (QFileInfo(candidate).exists()) + if (QFileInfo::exists(candidate)) found = candidate; } // 5. Try current directory if (found.isEmpty()) { QString candidate = QString::fromLatin1("%1/%2").arg(QDir::currentPath()).arg(base); - if (QFileInfo(candidate).exists()) + if (QFileInfo::exists(candidate)) found = candidate; } // 6. Try main source directory if (found.isEmpty()) { QString candidate = QTest::mainSourcePath % QLatin1Char('/') % base; - if (QFileInfo(candidate).exists()) + if (QFileInfo::exists(candidate)) found = candidate; } diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp index 0c157c940f..ac23e22ef7 100644 --- a/src/widgets/itemviews/qdirmodel.cpp +++ b/src/widgets/itemviews/qdirmodel.cpp @@ -862,7 +862,7 @@ QModelIndex QDirModel::index(const QString &path, int column) const #endif QStringList pathElements = absolutePath.split(QLatin1Char('/'), QString::SkipEmptyParts); - if ((pathElements.isEmpty() || !QFileInfo(path).exists()) + if ((pathElements.isEmpty() || !QFileInfo::exists(path)) #if !defined(Q_OS_WIN) || defined(Q_OS_WINCE) && path != QLatin1String("/") #endif -- cgit v1.2.3 From a44e4a6cfe37482b3b4b1527eabc807c585d0500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 20 Jan 2016 14:24:07 +0100 Subject: Fix build with QT_NO_OPENGL Change-Id: I3056d101967d94961b35ce10692dc9f390189b40 Reviewed-by: Laszlo Agocs --- src/gui/kernel/qplatformgraphicsbufferhelper.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/gui/kernel/qplatformgraphicsbufferhelper.cpp b/src/gui/kernel/qplatformgraphicsbufferhelper.cpp index c0c51b8d5e..52457ed606 100644 --- a/src/gui/kernel/qplatformgraphicsbufferhelper.cpp +++ b/src/gui/kernel/qplatformgraphicsbufferhelper.cpp @@ -232,6 +232,7 @@ bool QPlatformGraphicsBufferHelper::bindSWToTexture(const QPlatformGraphicsBuffe #else Q_UNUSED(graphicsBuffer) Q_UNUSED(swizzleRandB) + Q_UNUSED(premultipliedB) Q_UNUSED(subRect) return false; #endif // QT_NO_OPENGL -- cgit v1.2.3 From d921a9bd157b04242722ab4326c5f2ea8e88cbea Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 26 Oct 2015 17:31:18 -0700 Subject: Hide better the private API QTextCursor constructors Both constructors were taking a pointer, so they participated in overload resolution along with QTextDocument and QTextFrame pointers. Instead, make them take references and move them to the private section of QTextCursor. That necessitated adding a method to QTextCursorPrivate to access that private constructor from non-friend classes. Change-Id: I7e6338336dd6468ead24ffff1410e3bc534d77dd Reviewed-by: Konstantin Ritt --- src/gui/text/qtextcursor.cpp | 4 ++-- src/gui/text/qtextcursor.h | 6 ++++-- src/gui/text/qtextcursor_p.h | 3 +++ src/gui/text/qtextdocument.cpp | 7 ++++--- src/gui/text/qtextdocument_p.cpp | 2 +- src/gui/text/qtextobject.cpp | 5 +++-- src/gui/text/qtexttable.cpp | 13 +++++++------ 7 files changed, 24 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index eb51447105..dfb6c9c471 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -1072,8 +1072,8 @@ QTextCursor::QTextCursor(const QTextBlock &block) /*! \internal */ -QTextCursor::QTextCursor(QTextDocumentPrivate *p, int pos) - : d(new QTextCursorPrivate(p)) +QTextCursor::QTextCursor(QTextDocumentPrivate &p, int pos) + : d(new QTextCursorPrivate(&p)) { d->adjusted_anchor = d->anchor = d->position = pos; diff --git a/src/gui/text/qtextcursor.h b/src/gui/text/qtextcursor.h index 350f38cd02..c5462b2936 100644 --- a/src/gui/text/qtextcursor.h +++ b/src/gui/text/qtextcursor.h @@ -61,10 +61,8 @@ class Q_GUI_EXPORT QTextCursor public: QTextCursor(); explicit QTextCursor(QTextDocument *document); - QTextCursor(QTextDocumentPrivate *p, int pos); explicit QTextCursor(QTextFrame *frame); explicit QTextCursor(const QTextBlock &block); - explicit QTextCursor(QTextCursorPrivate *d); QTextCursor(const QTextCursor &cursor); #ifdef Q_COMPILER_RVALUE_REFS QTextCursor &operator=(QTextCursor &&other) Q_DECL_NOTHROW { swap(other); return *this; } @@ -221,8 +219,12 @@ public: QTextDocument *document() const; private: + QTextCursor(QTextDocumentPrivate &p, int pos); + explicit QTextCursor(QTextCursorPrivate *d); + QSharedDataPointer d; friend class QTextCursorPrivate; + friend class QTextDocumentPrivate; friend class QTextDocumentFragmentPrivate; friend class QTextCopyHelper; friend class QWidgetTextControlPrivate; diff --git a/src/gui/text/qtextcursor_p.h b/src/gui/text/qtextcursor_p.h index 51fb92d37c..983ff13742 100644 --- a/src/gui/text/qtextcursor_p.h +++ b/src/gui/text/qtextcursor_p.h @@ -100,6 +100,9 @@ public: void aboutToRemoveCell(int from, int to); + static QTextCursor fromPosition(QTextDocumentPrivate *d, int pos) + { return QTextCursor(*d, pos); } + QTextDocumentPrivate *priv; qreal x; int position; diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index 0affd3239d..3edf652f35 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -33,6 +33,7 @@ #include "qtextdocument.h" #include +#include "qtextcursor_p.h" #include "qtextdocumentlayout_p.h" #include "qtextdocumentfragment.h" #include "qtextdocumentfragment_p.h" @@ -1273,7 +1274,7 @@ static bool findInBlock(const QTextBlock &block, const QString &expression, int } } //we have a hit, return the cursor for that. - *cursor = QTextCursor(block.docHandle(), block.position() + idx); + *cursor = QTextCursorPrivate::fromPosition(block.docHandle(), block.position() + idx); cursor->setPosition(cursor->position() + expression.length(), QTextCursor::KeepAnchor); return true; } @@ -1391,7 +1392,7 @@ static bool findInBlock(const QTextBlock &block, const QRegExp &expression, int } } //we have a hit, return the cursor for that. - *cursor = QTextCursor(block.docHandle(), block.position() + idx); + *cursor = QTextCursorPrivate::fromPosition(block.docHandle(), block.position() + idx); cursor->setPosition(cursor->position() + expr.matchedLength(), QTextCursor::KeepAnchor); return true; } @@ -1519,7 +1520,7 @@ static bool findInBlock(const QTextBlock &block, const QRegularExpression &expre } } //we have a hit, return the cursor for that. - *cursor = QTextCursor(block.docHandle(), block.position() + idx); + *cursor = QTextCursorPrivate::fromPosition(block.docHandle(), block.position() + idx); cursor->setPosition(cursor->position() + match.capturedLength(), QTextCursor::KeepAnchor); return true; } diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index 587844c1dd..e5dcfb2e55 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -1704,7 +1704,7 @@ bool QTextDocumentPrivate::ensureMaximumBlockCount() beginEditBlock(); const int blocksToRemove = blocks.numNodes() - maximumBlockCount; - QTextCursor cursor(this, 0); + QTextCursor cursor(*this, 0); cursor.movePosition(QTextCursor::NextBlock, QTextCursor::KeepAnchor, blocksToRemove); unreachableCharacterCount += cursor.selectionEnd() - cursor.selectionStart(); diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp index df7c8b9c71..e70b8ed300 100644 --- a/src/gui/text/qtextobject.cpp +++ b/src/gui/text/qtextobject.cpp @@ -33,6 +33,7 @@ #include "qtextobject.h" #include "qtextobject_p.h" +#include "qtextcursor_p.h" #include "qtextdocument.h" #include "qtextformat_p.h" #include "qtextdocument_p.h" @@ -461,7 +462,7 @@ QTextFrame *QTextFrame::parentFrame() const QTextCursor QTextFrame::firstCursorPosition() const { Q_D(const QTextFrame); - return QTextCursor(d->pieceTable, firstPosition()); + return QTextCursorPrivate::fromPosition(d->pieceTable, firstPosition()); } /*! @@ -472,7 +473,7 @@ QTextCursor QTextFrame::firstCursorPosition() const QTextCursor QTextFrame::lastCursorPosition() const { Q_D(const QTextFrame); - return QTextCursor(d->pieceTable, lastPosition()); + return QTextCursorPrivate::fromPosition(d->pieceTable, lastPosition()); } /*! diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp index 454d3440d6..553dc3c772 100644 --- a/src/gui/text/qtexttable.cpp +++ b/src/gui/text/qtexttable.cpp @@ -35,6 +35,7 @@ #include "qtextcursor.h" #include "qtextformat.h" #include +#include "qtextcursor_p.h" #include "qtexttable_p.h" #include "qvarlengtharray.h" @@ -220,7 +221,7 @@ int QTextTableCell::columnSpan() const */ QTextCursor QTextTableCell::firstCursorPosition() const { - return QTextCursor(table->d_func()->pieceTable, firstPosition()); + return QTextCursorPrivate::fromPosition(table->d_func()->pieceTable, firstPosition()); } /*! @@ -230,7 +231,7 @@ QTextCursor QTextTableCell::firstCursorPosition() const */ QTextCursor QTextTableCell::lastCursorPosition() const { - return QTextCursor(table->d_func()->pieceTable, lastPosition()); + return QTextCursorPrivate::fromPosition(table->d_func()->pieceTable, lastPosition()); } @@ -1103,10 +1104,10 @@ void QTextTable::mergeCells(int row, int column, int numRows, int numCols) if (nextPos > pos) { if (needsParagraph) { needsParagraph = false; - QTextCursor(p, insertPos++).insertBlock(); + QTextCursorPrivate::fromPosition(p, insertPos++).insertBlock(); p->move(pos + 1, insertPos, nextPos - pos); } else if (rowHasText) { - QTextCursor(p, insertPos++).insertText(QLatin1String(" ")); + QTextCursorPrivate::fromPosition(p, insertPos++).insertText(QLatin1String(" ")); p->move(pos + 1, insertPos, nextPos - pos); } else { p->move(pos, insertPos, nextPos - pos); @@ -1282,7 +1283,7 @@ QTextCursor QTextTable::rowStart(const QTextCursor &c) const int row = cell.row(); QTextDocumentPrivate *p = d->pieceTable; QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), d->grid[row*d->nCols]); - return QTextCursor(p, it.position()); + return QTextCursorPrivate::fromPosition(p, it.position()); } /*! @@ -1304,7 +1305,7 @@ QTextCursor QTextTable::rowEnd(const QTextCursor &c) const int fragment = row < d->nRows ? d->grid[row*d->nCols] : d->fragment_end; QTextDocumentPrivate *p = d->pieceTable; QTextDocumentPrivate::FragmentIterator it(&p->fragmentMap(), fragment); - return QTextCursor(p, it.position() - 1); + return QTextCursorPrivate::fromPosition(p, it.position() - 1); } /*! -- cgit v1.2.3 From db2675d6fdb0d44fe1b040eda47f75e8bb35ce7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 10 Sep 2015 11:16:38 +0200 Subject: Cocoa: Update QWindow::screen() on expose/show. This is needed to correctly handle show on non-primary screens. Change-Id: I80b13372b3a92786987a66f0da385af6b4a6a863 Task-number: QTBUG-47950 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoawindow.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 3b5909a37e..00cb43c940 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1775,6 +1775,18 @@ void QCocoaWindow::exposeWindow() if (!isWindowExposable()) return; + // Update the QWindow's screen property. This property is set + // to QGuiApplication::primaryScreen() at QWindow construciton + // time, and we won't get a NSWindowDidChangeScreenNotification + // on show. The case where the window is initially displayed + // on a non-primary screen needs special handling here. + NSUInteger screenIndex = [[NSScreen screens] indexOfObject:m_nsWindow.screen]; + if (screenIndex != NSNotFound) { + QCocoaScreen *cocoaScreen = QCocoaIntegration::instance()->screenAtIndex(screenIndex); + if (cocoaScreen) + window()->setScreen(cocoaScreen->screen()); + } + if (!m_isExposed) { m_isExposed = true; m_exposedGeometry = geometry(); -- cgit v1.2.3 From 684e5587d5024ff9523d76141d0befd1201dc24f Mon Sep 17 00:00:00 2001 From: Rafael Roquetto Date: Mon, 18 Jan 2016 15:37:11 -0200 Subject: QNX: Fix -developer-build -developer-build enables -Werror=undef, which uncovered a bug inside qcompilerdetection.h. According to the Dinkum headers, it is necessary to account for three different states concerning the values of the _HAS_* macros: 1. undefined 2. 0 3. 1 Therefore, it is necessary to check both whether it is defined and if it is not 0. Only checking whether a given macro is 0 will generate a trap by -Werror=undef. (__GLIBCXX__ is the sole exception). Change-Id: Ib95e485698ee38858a1671d930d7e960b75bb041 Reviewed-by: James McDonnell Reviewed-by: Dan Cape Reviewed-by: Thiago Macieira --- src/corelib/global/qcompilerdetection.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index ba830977ad..b11237dce5 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -931,8 +931,8 @@ // Older versions (QNX 650) do not support C++11 features // _HAS_* macros are set to 1 by toolchains that actually include // Dinkum C++11 libcpp. -# if !__GLIBCXX__ -# if !_HAS_CPP0X +# if !defined(__GLIBCXX__) +# if !defined(_HAS_CPP0X) || !_HAS_CPP0X // Disable C++11 features that depend on library support # undef Q_COMPILER_INITIALIZER_LISTS # undef Q_COMPILER_RVALUE_REFS @@ -940,10 +940,10 @@ # undef Q_COMPILER_UNICODE_STRINGS # undef Q_COMPILER_NOEXCEPT # endif // !_HAS_CPP0X -# if !_HAS_NULLPTR_T +# if !defined(_HAS_NULLPTR_T) || !_HAS_NULLPTR_T # undef Q_COMPILER_NULLPTR # endif //!_HAS_NULLPTR_T -# if !_HAS_CONSTEXPR +# if !defined(_HAS_CONSTEXPR) || !_HAS_CONSTEXPR // The libcpp is missing constexpr keywords on important functions like std::numeric_limits<>::min() // Disable constexpr support on QNX even if the compiler supports it # undef Q_COMPILER_CONSTEXPR -- cgit v1.2.3 From e7825015328a2297c0730a6708e17a9bcf9d7f48 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 22 Jan 2016 13:15:19 +0100 Subject: Speed up QObject::connect with function pointers When resolving the signal/slot of connect(&Foo::bar, ...) we place a meta-call to map the address to the method index. Once we have found the index, we don't need to continue but can return the result right away. Change-Id: I67bb22df394d7c22dc1731367c0961b958ed77b3 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/tools/moc/generator.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 5be58d3c4b..99629f0427 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -1254,6 +1254,7 @@ void Generator::generateStaticMetacall() fprintf(out, " if (*reinterpret_cast<_t *>(func) == static_cast<_t>(&%s::%s)) {\n", cdef->classname.constData(), f.name.constData()); fprintf(out, " *result = %d;\n", methodindex); + fprintf(out, " return;\n"); fprintf(out, " }\n }\n"); } if (!anythingUsed) -- cgit v1.2.3 From 81d6906ad9fa8ad3f73b151a1e8564ffaeccc3cf Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Thu, 21 Jan 2016 11:08:59 +0200 Subject: Android: Fix compile on arm64 Workaround Bionic bug. Check https://code.google.com/p/android/issues/detail?id=194631 for more info. Change-Id: Ib1abae37c94d4e76bb3bd633985c84128659bf4c Reviewed-by: Konstantin Ritt Reviewed-by: Thiago Macieira --- src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro b/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro index 031f7ecd58..edfc0e7954 100644 --- a/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro +++ b/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro @@ -15,6 +15,9 @@ DEFINES += HAVE_ATEXIT unix: DEFINES += HAVE_PTHREAD HAVE_SCHED_H HAVE_SCHED_YIELD win32: DEFINES += HB_NO_WIN1256 +#Workaround https://code.google.com/p/android/issues/detail?id=194631 +android: DEFINES += _POSIX_C_SOURCE=200112L + INCLUDEPATH += $$PWD/include INCLUDEPATH += $$QT.core.includes -- cgit v1.2.3 From 2fed43d8438b3fb751230aa2a8115de92789ccf3 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 23 Jan 2016 02:04:48 +0100 Subject: Q*Application: don't allocate memory just to compare C strings Instead of creating a QByteArray, possibly normalizing a leading '--' (one allocation, plus possibly one copy), simply use the old 'ol str(n)cmp, skipping the first character if the argument starts with '--'. It also fixes parsing of -stylesheet and other options which were erroneously parsed using indexOf() != -1, when they should have used startsWith(). Also saves 504/742/522b in text size for QtCore/QtGui/QtWidgets, resp., on optimized GCC 5.3 Linux AMD64 builds. Change-Id: Ida868badac3fb9b77285417ee537c861ccc4fc06 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qcoreapplication.cpp | 16 ++++++----- src/gui/kernel/qguiapplication.cpp | 48 ++++++++++++++++++--------------- src/widgets/kernel/qapplication.cpp | 18 +++++++------ 3 files changed, 45 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index abc5af94cb..48d70f2747 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -182,16 +182,18 @@ void QCoreApplicationPrivate::processCommandLineArguments() { int j = argc ? 1 : 0; for (int i = 1; i < argc; ++i) { - if (argv[i] && *argv[i] != '-') { + if (!argv[i]) + continue; + if (*argv[i] != '-') { argv[j++] = argv[i]; continue; } - QByteArray arg = argv[i]; - if (arg.startsWith("--")) - arg.remove(0, 1); - if (arg.startsWith("-qmljsdebugger=")) { - qmljs_debug_arguments = QString::fromLocal8Bit(arg.right(arg.length() - 15)); - } else if (arg == "-qmljsdebugger" && i < argc - 1) { + const char *arg = argv[i]; + if (arg[1] == '-') // startsWith("--") + ++arg; + if (strncmp(arg, "-qmljsdebugger=", 15) == 0) { + qmljs_debug_arguments = QString::fromLocal8Bit(arg + 15); + } else if (strcmp(arg, "-qmljsdebugger") == 0 && i < argc - 1) { ++i; qmljs_debug_arguments = QString::fromLocal8Bit(argv[i]); } else { diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 0f015af2b9..7d469dd25e 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1181,30 +1181,32 @@ void QGuiApplicationPrivate::createPlatformIntegration() int j = argc ? 1 : 0; for (int i=1; i Date: Fri, 22 Jan 2016 21:41:40 -0800 Subject: Fix tlw source rect transformation for backingstore blit. The srcRect is already in device window coordinates. Converting it again via deviceRect(QRect, QWindow) causes it to be overly large. Task-number: QTBUG-50613 Change-Id: Iaae390499c0d1add842bde6eec22fb07c8de663b Reviewed-by: Laszlo Agocs --- src/gui/painting/qplatformbackingstore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp index 83b75ae605..8e40eb6dff 100644 --- a/src/gui/painting/qplatformbackingstore.cpp +++ b/src/gui/painting/qplatformbackingstore.cpp @@ -385,7 +385,7 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion ®i // The backingstore is for the entire tlw. // In case of native children offset tells the position relative to the tlw. const QRect srcRect = toBottomLeftRect(deviceWindowRect.translated(offset), d_ptr->textureSize.height()); - const QMatrix3x3 source = QOpenGLTextureBlitter::sourceTransform(deviceRect(srcRect, window), + const QMatrix3x3 source = QOpenGLTextureBlitter::sourceTransform(srcRect, d_ptr->textureSize, origin); d_ptr->blitter->blit(textureId, QMatrix4x4(), source); -- cgit v1.2.3 From 5cac511908bc67b86e29b31350619488906a55a2 Mon Sep 17 00:00:00 2001 From: Dyami Caliri Date: Sat, 23 Jan 2016 11:22:09 -0800 Subject: Repaint QOpenGLWidget when screen changes Commit 5c7f000cd4c9e3769e8cd4085cf0beee104f9886 greatly reduces the number of repaints for QOpenGLWidget. Unfortunately, this included when the widget changes screens. Change-Id: Iaabcb94925e4519cb5d8561b47aaddcfdc7b01ac Reviewed-by: Laszlo Agocs --- src/widgets/kernel/qwidget.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index b2b5c539e5..5bff30524a 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -9146,6 +9146,9 @@ bool QWidget::event(QEvent *event) const QWindow *win = te->window; d->setWinId((win && win->handle()) ? win->handle()->winId() : 0); } +#ifndef QT_NO_OPENGL + d->renderToTextureReallyDirty = 1; +#endif break; #ifndef QT_NO_PROPERTIES case QEvent::DynamicPropertyChange: { -- cgit v1.2.3 From a1ba281a26d065d2e901b3a947a8517ec5790504 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 19 Jan 2016 22:29:33 -0800 Subject: Call out to QtDBus message spies in the main thread Whenever there are spies installed, we call out to the main thread to call to the kded/kiod message spies. This allows the spy code to do just about anything, where previously it was restricted in what it could do to avoid deadlocking or triggering assertions if it recursed back into QDBusConnection code in the manager thread. After the spies are done, the message is re-inserted into the QDBusConnection processing pipeline. This commit moves the spy handling to after the check for disabled dispatching, as doing otherwise would mean the message could get postponed again for no good reason. It's also possible that the main thread isn't done installing the hooks, so waiting until the dispatching is enabled is a good idea. For simplicity, this commit also restricts spying to method calls only. Signals are no longer spyable. Change-Id: I3d11545be52c43119f0fffff142b0e9d447415c2 Reviewed-by: David Faure --- src/dbus/qdbusconnection_p.h | 3 ++- src/dbus/qdbusintegrator.cpp | 48 +++++++++++++++++++++++++++++++++----------- src/dbus/qdbusintegrator_p.h | 19 ++++++++++++++++++ 3 files changed, 57 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index f030a3ff8c..c77daf7ee1 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2015 Intel Corporation. +** Copyright (C) 2016 Intel Corporation. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtDBus module of the Qt Toolkit. @@ -281,6 +281,7 @@ private slots: signals: void dispatchStatusChanged(); + void spyHooksFinished(const QDBusMessage &msg); void messageNeedsSending(QDBusPendingCallPrivate *pcall, void *msg, int timeout = -1); void signalNeedsConnecting(const QString &key, const QDBusConnectionPrivate::SignalHook &hook); bool signalNeedsDisconnecting(const QString &key, const QDBusConnectionPrivate::SignalHook &hook); diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index f6221d51b6..f0b8f1b441 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2015 Intel Corporation. +** Copyright (C) 2016 Intel Corporation. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtDBus module of the Qt Toolkit. @@ -120,8 +120,7 @@ void qdbusDefaultThreadDebug(int action, int condition, QDBusConnectionPrivate * qdbusThreadDebugFunc qdbusThreadDebug = 0; #endif -typedef void (*QDBusSpyHook)(const QDBusMessage&); -typedef QVarLengthArray QDBusSpyHookList; +typedef QVarLengthArray QDBusSpyHookList; Q_GLOBAL_STATIC(QDBusSpyHookList, qDBusSpyHookList) extern "C" { @@ -461,12 +460,29 @@ static QStringList matchArgsForService(const QString &service, QDBusServiceWatch } -extern Q_DBUS_EXPORT void qDBusAddSpyHook(QDBusSpyHook); -void qDBusAddSpyHook(QDBusSpyHook hook) +extern Q_DBUS_EXPORT void qDBusAddSpyHook(QDBusSpyCallEvent::Hook); +void qDBusAddSpyHook(QDBusSpyCallEvent::Hook hook) { qDBusSpyHookList()->append(hook); } +QDBusSpyCallEvent::~QDBusSpyCallEvent() +{ + // Reinsert the message into the processing queue for the connection. + // This is done in the destructor so the message is reinserted even if + // QCoreApplication is destroyed. + QDBusConnectionPrivate *d = static_cast(const_cast(sender())); + qDBusDebug() << d << "message spies done for" << msg; + emit d->spyHooksFinished(msg); +} + +void QDBusSpyCallEvent::placeMetaCall(QObject *) +{ + // call the spy hook list + for (int i = 0; i < hookCount; ++i) + hooks[i](msg); +} + extern "C" { static DBusHandlerResult qDBusSignalFilter(DBusConnection *connection, DBusMessage *message, void *data) @@ -488,16 +504,11 @@ qDBusSignalFilter(DBusConnection *connection, DBusMessage *message, void *data) bool QDBusConnectionPrivate::handleMessage(const QDBusMessage &amsg) { - const QDBusSpyHookList *list = qDBusSpyHookList(); - for (int i = 0; list && i < list->size(); ++i) { - qDBusDebug() << "calling the message spy hook"; - (*(*list)[i])(amsg); - } - if (!ref.load()) return false; if (!dispatchEnabled && !QDBusMessagePrivate::isLocal(amsg)) { // queue messages only, we'll handle them later + qDBusDebug() << this << "delivery is suspended"; pendingMessages << amsg; return amsg.type() == QDBusMessage::MethodCallMessage; } @@ -509,6 +520,15 @@ bool QDBusConnectionPrivate::handleMessage(const QDBusMessage &amsg) // let them see the signal too return false; case QDBusMessage::MethodCallMessage: + // run it through the spy filters (if any) before the regular processing + if (Q_UNLIKELY(qDBusSpyHookList.exists()) && qApp) { + const QDBusSpyHookList &list = *qDBusSpyHookList; + qDBusDebug() << this << "invoking message spies"; + QCoreApplication::postEvent(qApp, new QDBusSpyCallEvent(this, QDBusConnection(this), + amsg, list.constData(), list.size())); + return true; + } + handleObjectCall(amsg); return true; case QDBusMessage::ReplyMessage: @@ -981,6 +1001,8 @@ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p) QDBusMetaTypeId::init(); connect(this, &QDBusConnectionPrivate::dispatchStatusChanged, this, &QDBusConnectionPrivate::doDispatch, Qt::QueuedConnection); + connect(this, &QDBusConnectionPrivate::spyHooksFinished, + this, &QDBusConnectionPrivate::handleObjectCall, Qt::QueuedConnection); connect(this, &QDBusConnectionPrivate::messageNeedsSending, this, &QDBusConnectionPrivate::sendInternal); connect(this, &QDBusConnectionPrivate::signalNeedsConnecting, @@ -1092,8 +1114,10 @@ void QDBusConnectionPrivate::doDispatch() // dispatch previously queued messages PendingMessageList::Iterator it = pendingMessages.begin(); PendingMessageList::Iterator end = pendingMessages.end(); - for ( ; it != end; ++it) + for ( ; it != end; ++it) { + qDBusDebug() << this << "dequeueing message" << *it; handleMessage(qMove(*it)); + } pendingMessages.clear(); } } diff --git a/src/dbus/qdbusintegrator_p.h b/src/dbus/qdbusintegrator_p.h index 62106e4c0b..2bbebdf708 100644 --- a/src/dbus/qdbusintegrator_p.h +++ b/src/dbus/qdbusintegrator_p.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2016 Intel Corporation. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtDBus module of the Qt Toolkit. @@ -65,6 +66,7 @@ QT_BEGIN_NAMESPACE class QDBusConnectionPrivate; +class QDBusMessage; // Really private structs used by qdbusintegrator.cpp // Things that aren't used by any other file @@ -133,6 +135,23 @@ private: bool handled; }; +class QDBusSpyCallEvent : public QMetaCallEvent +{ +public: + typedef void (*Hook)(const QDBusMessage&); + QDBusSpyCallEvent(QDBusConnectionPrivate *cp, const QDBusConnection &c, const QDBusMessage &msg, + const Hook *hooks, int count) + : QMetaCallEvent(0, 0, Q_NULLPTR, cp, 0), conn(c), msg(msg), hooks(hooks), hookCount(count) + {} + ~QDBusSpyCallEvent(); + void placeMetaCall(QObject *) Q_DECL_OVERRIDE; + + QDBusConnection conn; // keeps the refcount in QDBusConnectionPrivate up + QDBusMessage msg; + const Hook *hooks; + int hookCount; +}; + QT_END_NAMESPACE Q_DECLARE_METATYPE(QDBusSlotCache) -- cgit v1.2.3 From 63c88ae809838925e78146b7896dbac7821ffee5 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Tue, 8 Dec 2015 13:18:01 +0200 Subject: Android: Probe for virtual keyboard height Knowing the real virtual keyboard height will be easier for us to decide if we pan or resize the current view. The virtual keyboard is re-shown if current virtual keyboard height is different from previous one. Task-number: QTBUG-43739 Change-Id: I1bb41a70cced4c1d0e5f05a6c554831459b7a917 Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Christian Stromme --- .../qtproject/qt5/android/QtActivityDelegate.java | 56 +++++++++++++++++++--- 1 file changed, 49 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java index dd5a7b4fec..ac77de0bab 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java @@ -42,6 +42,7 @@ import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Configuration; import android.graphics.drawable.ColorDrawable; +import android.graphics.Rect; import android.net.LocalServerSocket; import android.net.LocalSocket; import android.os.Build; @@ -67,7 +68,6 @@ import android.view.ViewGroup; import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; import android.view.ViewTreeObserver; -import android.graphics.Rect; import java.io.BufferedReader; import java.io.DataOutputStream; @@ -125,6 +125,9 @@ public class QtActivityDelegate private boolean m_keyboardIsVisible = false; public boolean m_backKeyPressedSent = false; private long m_showHideTimeStamp = System.nanoTime(); + private int m_portraitKeyboardHeight = 0; + private int m_landscapeKeyboardHeight = 0; + private int m_probeKeyboardHeightDelay = 50; // ms public void setFullScreen(boolean enterFullScreen) { @@ -247,19 +250,26 @@ public class QtActivityDelegate }, 5); } - public void showSoftwareKeyboard(int x, int y, int width, int height, int inputHints, int enterKeyType) + public void showSoftwareKeyboard(final int x, final int y, final int width, final int height, final int inputHints, final int enterKeyType) { if (m_imm == null) return; + DisplayMetrics metrics = new DisplayMetrics(); + m_activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); + + // If the screen is in portrait mode than we estimate that keyboard height will not be higher than 2/5 of the screen. + // else than we estimate that keyboard height will not be higher than 2/3 of the screen + final int visibleHeight; + if (metrics.widthPixels < metrics.heightPixels) + visibleHeight = m_portraitKeyboardHeight != 0 ? m_portraitKeyboardHeight : metrics.heightPixels * 3 / 5; + else + visibleHeight = m_landscapeKeyboardHeight != 0 ? m_landscapeKeyboardHeight : metrics.heightPixels / 3; + if (m_softInputMode != 0) { m_activity.getWindow().setSoftInputMode(m_softInputMode); - // softInputIsHidden is true if SOFT_INPUT_STATE_HIDDEN or SOFT_INPUT_STATE_ALWAYS_HIDDEN is set. - final boolean softInputIsHidden = (m_softInputMode & WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) != 0; - if (softInputIsHidden) - return; } else { - if (height > m_layout.getHeight() * 2 / 3) + if (height > visibleHeight) m_activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); else m_activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); @@ -366,6 +376,38 @@ public class QtActivityDelegate //FALLTHROUGH case InputMethodManager.RESULT_UNCHANGED_SHOWN: setKeyboardVisibility(true, System.nanoTime()); + if (m_softInputMode == 0) { + // probe for real keyboard height + m_layout.postDelayed(new Runnable() { + @Override + public void run() { + if (!m_keyboardIsVisible) + return; + DisplayMetrics metrics = new DisplayMetrics(); + m_activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); + Rect r = new Rect(); + m_activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(r); + if (metrics.heightPixels != r.bottom) { + if (metrics.widthPixels > metrics.heightPixels) { // landscape + if (m_landscapeKeyboardHeight != r.bottom) { + m_landscapeKeyboardHeight = r.bottom; + showSoftwareKeyboard(x, y, width, height, inputHints, enterKeyType); + } + } else { + if (m_portraitKeyboardHeight != r.bottom) { + m_portraitKeyboardHeight = r.bottom; + showSoftwareKeyboard(x, y, width, height, inputHints, enterKeyType); + } + } + } else { + // no luck ? + // maybe the delay was too short, so let's make it longer + if (m_probeKeyboardHeightDelay < 1000) + m_probeKeyboardHeightDelay *= 2; + } + } + }, m_probeKeyboardHeightDelay); + } break; case InputMethodManager.RESULT_HIDDEN: case InputMethodManager.RESULT_UNCHANGED_HIDDEN: -- cgit v1.2.3