From 4f15449bc2584ad299569c86f707994dca76d733 Mon Sep 17 00:00:00 2001 From: Jian Liang Date: Tue, 7 Jul 2015 22:23:33 +0800 Subject: Windows: register alias for application font Previously Qt didn't register an English name alias for application font files under Windows. Suppose we add an application font file using QFontDatabase::addApplicationFont(), the font family name returned by QFontDatabase::applicationFontFamilies() then was the English name of the font file, but the corresponding font family name returned by QFontDatabase::families() was the localized version. This prevented us from using the English font family to access the font since it was not registered as alias. Add an overload of populateFamily() which will register the English name of the application font file as alias. Task-number: QTBUG-47096 Change-Id: Idb89b7d8a419646c209426e826e7fd1ebee49662 Reviewed-by: Friedemann Kleint Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/windows/qwindowsfontdatabase.cpp | 15 ++++++++++----- src/plugins/platforms/windows/qwindowsfontdatabase.h | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index 1c5b114efd..b1bb944fc6 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -933,7 +933,7 @@ static bool addFontToDatabase(const QString &familyName, uchar charSet, } static int QT_WIN_CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetric, - int type, LPARAM) + int type, LPARAM registerAlias) { const QString familyName = QString::fromWCharArray(f->elfLogFont.lfFaceName); const uchar charSet = f->elfLogFont.lfCharSet; @@ -943,13 +943,13 @@ static int QT_WIN_CALLBACK storeFont(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetr // NEWTEXTMETRICEX is a NEWTEXTMETRIC, which according to the documentation is // identical to a TEXTMETRIC except for the last four members, which we don't use // anyway - addFontToDatabase(familyName, charSet, (TEXTMETRIC *)textmetric, &signature, type, false); + addFontToDatabase(familyName, charSet, (TEXTMETRIC *)textmetric, &signature, type, registerAlias); // keep on enumerating return 1; } -void QWindowsFontDatabase::populateFamily(const QString &familyName) +void QWindowsFontDatabase::populateFamily(const QString &familyName, bool registerAlias) { qCDebug(lcQpaFonts) << familyName; if (familyName.size() >= LF_FACESIZE) { @@ -962,10 +962,15 @@ void QWindowsFontDatabase::populateFamily(const QString &familyName) familyName.toWCharArray(lf.lfFaceName); lf.lfFaceName[familyName.size()] = 0; lf.lfPitchAndFamily = 0; - EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont, 0, 0); + EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)storeFont, (LPARAM)registerAlias, 0); ReleaseDC(0, dummy); } +void QWindowsFontDatabase::populateFamily(const QString &familyName) +{ + populateFamily(familyName, false); +} + namespace { // Context for enumerating system fonts, records whether the default font has been encountered, // which is normally not enumerated by EnumFontFamiliesEx(). @@ -1382,7 +1387,7 @@ QStringList QWindowsFontDatabase::addApplicationFont(const QByteArray &fontData, // Fonts based on files are added via populate, as they will show up in font enumeration. for (int j = 0; j < families.count(); ++j) - populateFamily(families.at(j)); + populateFamily(families.at(j), true); } m_applicationFonts << font; diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.h b/src/plugins/platforms/windows/qwindowsfontdatabase.h index 3615612c78..efb5421996 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.h +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.h @@ -100,6 +100,7 @@ public: static QString familyForStyleHint(QFont::StyleHint styleHint); private: + void populateFamily(const QString &familyName, bool registerAlias); void removeApplicationFonts(); struct WinApplicationFont { -- cgit v1.2.3 From f3e1dfb786c8c425562a29bd2ca18dbeb1d4ea84 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 20 Jul 2015 16:30:35 +0200 Subject: Windows: Fix handling of cursor flash time. Check for special return value INFINITE (unsigned -1) of GetCaretBlinkTime() (indicating cursor should not flash) and return 0 in that case. Change-Id: Iead41a20a68b79d04b03f77a3caf063d4e1d577e Task-number: QTBUG-47208 Reviewed-by: Joerg Bornemann --- src/plugins/platforms/windows/qwindowsintegration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 9b0f126241..79df6ce720 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -491,7 +491,7 @@ QVariant QWindowsIntegration::styleHint(QPlatformIntegration::StyleHint hint) co switch (hint) { case QPlatformIntegration::CursorFlashTime: if (const unsigned timeMS = GetCaretBlinkTime()) - return QVariant(int(timeMS) * 2); + return QVariant(timeMS != INFINITE ? int(timeMS) * 2 : 0); break; #ifdef SPI_GETKEYBOARDSPEED case KeyboardAutoRepeatRate: -- cgit v1.2.3 From a0e2e715f58134c7c913996e036b154df1f71d99 Mon Sep 17 00:00:00 2001 From: Ron Bessems Date: Wed, 8 Jul 2015 10:14:10 -0400 Subject: Fixed null pointer dereference Crash in qtwidgets.dll when Qt app is used with accessibility tools like Dragon. Crash due to null pointer dereference. Task-number: QTBUG-47093 Change-Id: I140196ba44b68dfaf229dd8a8e6031379ea1acac Reviewed-by: Frederik Gladhorn --- .../platforms/windows/accessible/qwindowsmsaaaccessible.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp index 8b67f235bb..2189938248 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp +++ b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp @@ -689,7 +689,7 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::get_accChild(VARIANT varChildI return E_INVALIDARG; QAccessibleInterface *acc = childPointer(accessible, varChildID); - if (acc) { + if (acc && acc->isValid()) { *ppdispChild = QWindowsAccessibility::wrap(acc); return S_OK; } @@ -778,7 +778,7 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::get_accDescription(VARIANT var QString descr; if (varID.lVal) { QAccessibleInterface *child = childPointer(accessible, varID); - if (!child) + if (!child || !child->isValid()) return E_FAIL; descr = child->text(QAccessible::Description); } else { @@ -803,7 +803,7 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::get_accHelp(VARIANT varID, BST QString help; if (varID.lVal) { QAccessibleInterface *child = childPointer(accessible, varID); - if (!child) + if (!child || !child->isValid()) return E_FAIL; help = child->text(QAccessible::Help); } else { @@ -862,7 +862,7 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::get_accName(VARIANT varID, BST QString name; if (varID.lVal) { QAccessibleInterface *child = childPointer(accessible, varID); - if (!child) + if (!child || !child->isValid()) return E_FAIL; name = child->text(QAccessible::Name); if (name.isEmpty()) { @@ -910,7 +910,7 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::get_accRole(VARIANT varID, VAR QAccessible::Role role; if (varID.lVal) { QAccessibleInterface *child = childPointer(accessible, varID); - if (!child) + if (!child || !child->isValid()) return E_FAIL; role = child->role(); } else { @@ -947,7 +947,7 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::get_accState(VARIANT varID, VA QAccessible::State state; if (varID.lVal) { QAccessibleInterface *child = childPointer(accessible, varID); - if (!child) + if (!child || !child->isValid()) return E_FAIL; state = child->state(); } else { -- cgit v1.2.3 From 50f064f788c6a570ab01909f06a7fe629aa4a621 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 21 Jul 2015 18:09:38 +0200 Subject: fix -no-opengl build Change-Id: Id3570cf10d86908ddff35be65103d16b353dad04 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowsnativeinterface.cpp | 4 +++- src/plugins/platforms/windows/qwindowswindow.cpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp index 6e58c55bbe..db8b2ec094 100644 --- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp +++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp @@ -135,7 +135,9 @@ QVariantMap QWindowsNativeInterface::windowProperties(QPlatformWindow *window) c void *QWindowsNativeInterface::nativeResourceForIntegration(const QByteArray &resource) { -#ifndef QT_NO_OPENGL +#ifdef QT_NO_OPENGL + Q_UNUSED(resource) +#else if (resourceType(resource) == GlHandleType) return QWindowsIntegration::staticOpenGLContext()->moduleHandle(); #endif diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 543c08135f..853cf036a7 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -2271,6 +2271,7 @@ void QWindowsWindow::setCustomMargins(const QMargins &newCustomMargins) void *QWindowsWindow::surface(void *nativeConfig, int *err) { #ifdef QT_NO_OPENGL + Q_UNUSED(err) Q_UNUSED(nativeConfig) return 0; #else -- cgit v1.2.3 From 3627d8b171379e4f0d3b52d33fcce4767282f1d9 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 23 Jul 2015 11:02:41 +0200 Subject: Windows/QClipboard: Fix crash in debug output of QMimeData. Rewrite QDebug operator<<(QDebug d, const QMimeData &mimeData) to take a pointer and handle 0 values. Change the formatting to the style commonly used in Qt. Make it static as it is not used anywhere else. Task-number: QTBUG-47393 Change-Id: I78174e10b75769bf4acd33a894acc0a51e525c39 Reviewed-by: Joerg Bornemann --- .../platforms/windows/qwindowsclipboard.cpp | 37 ++++++++++++---------- .../platforms/windows/qwindowsinternalmimedata.h | 2 -- 2 files changed, 20 insertions(+), 19 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowsclipboard.cpp b/src/plugins/platforms/windows/qwindowsclipboard.cpp index 4cea845c36..925427ac30 100644 --- a/src/plugins/platforms/windows/qwindowsclipboard.cpp +++ b/src/plugins/platforms/windows/qwindowsclipboard.cpp @@ -69,25 +69,28 @@ static const char formatTextHtmlC[] = "text/html"; \ingroup qt-lighthouse-win */ -QDebug operator<<(QDebug d, const QMimeData &m) +static QDebug operator<<(QDebug d, const QMimeData *mimeData) { QDebugStateSaver saver(d); d.nospace(); - const QStringList formats = m.formats(); - d << "QMimeData: " << formats.join(QStringLiteral(", ")) << '\n' - << " Text=" << m.hasText() << " HTML=" << m.hasHtml() - << " Color=" << m.hasColor() << " Image=" << m.hasImage() - << " URLs=" << m.hasUrls() << '\n'; - if (m.hasText()) - d << " Text: '" << m.text() << "'\n"; - if (m.hasHtml()) - d << " HTML: '" << m.html() << "'\n"; - if (m.hasColor()) - d << " Color: " << qvariant_cast(m.colorData()) << '\n'; - if (m.hasImage()) - d << " Image: " << qvariant_cast(m.imageData()).size() << '\n'; - if (m.hasUrls()) - d << " URLs: " << m.urls() << '\n'; + d << "QMimeData("; + if (mimeData) { + const QStringList formats = mimeData->formats(); + d << "formats=" << formats.join(QStringLiteral(", ")); + if (mimeData->hasText()) + d << ", text=" << mimeData->text(); + if (mimeData->hasHtml()) + d << ", html=" << mimeData->html(); + if (mimeData->hasColor()) + d << ", colorData=" << qvariant_cast(mimeData->colorData()); + if (mimeData->hasImage()) + d << ", imageData=" << qvariant_cast(mimeData->imageData()); + if (mimeData->hasUrls()) + d << ", urls=" << mimeData->urls(); + } else { + d << '0'; + } + d << ')'; return d; } @@ -297,7 +300,7 @@ QMimeData *QWindowsClipboard::mimeData(QClipboard::Mode mode) void QWindowsClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode) { - qCDebug(lcQpaMime) << __FUNCTION__ << mode << *mimeData; + qCDebug(lcQpaMime) << __FUNCTION__ << mode << mimeData; if (mode != QClipboard::Clipboard) return; diff --git a/src/plugins/platforms/windows/qwindowsinternalmimedata.h b/src/plugins/platforms/windows/qwindowsinternalmimedata.h index 09ab417268..6a60a9676a 100644 --- a/src/plugins/platforms/windows/qwindowsinternalmimedata.h +++ b/src/plugins/platforms/windows/qwindowsinternalmimedata.h @@ -55,8 +55,6 @@ protected: virtual void releaseDataObject(IDataObject *) const {} }; -QDebug operator<<(QDebug d, const QMimeData &m); - QT_END_NAMESPACE #endif // QWINDOWSINTERNALMIME_H -- cgit v1.2.3 From 4ef3d985dd959d8e878ea9b1080691fca861f8ea Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 20 Jul 2015 11:01:39 +0200 Subject: Windows: Split code paths for touch/native gesture events. Fix up 2b5df245d6cdbfb3150ee815debccf655af8f19f which routed WM_GESTURE through QWindowsMouseHandler::translateTouchEvent() causing asserts on missing touch devices. Task-number: QTBUG-47184 Change-Id: Ie843ebb343e34487bcac9c9dbea88de641d51e28 Reviewed-by: Oliver Wolff Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowscontext.cpp | 6 +++++- .../platforms/windows/qwindowsmousehandler.cpp | 24 +++++++++++++++++----- .../platforms/windows/qwindowsmousehandler.h | 3 +++ 3 files changed, 27 insertions(+), 6 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index a532e92397..3f355db607 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -919,7 +919,11 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, case QtWindows::InputMethodRequest: return QWindowsInputContext::instance()->handleIME_Request(wParam, lParam, result); case QtWindows::GestureEvent: - return d->m_mouseHandler.translateTouchEvent(platformWindow->window(), hwnd, et, msg, result); +#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER) + return platformSessionManager()->isInteractionBlocked() ? true : d->m_mouseHandler.translateGestureEvent(platformWindow->window(), hwnd, et, msg, result); +#else + return d->m_mouseHandler.translateGestureEvent(platformWindow->window(), hwnd, et, msg, result); +#endif case QtWindows::InputMethodOpenCandidateWindowEvent: case QtWindows::InputMethodCloseCandidateWindowEvent: // TODO: Release/regrab mouse if a popup has mouse grab. diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index db635b602b..e6b80f2b93 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -472,12 +472,11 @@ bool QWindowsMouseHandler::translateScrollEvent(QWindow *window, HWND, } // from bool QApplicationPrivate::translateTouchEvent() -bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND hwnd, +bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND, QtWindows::WindowsEventType, MSG msg, LRESULT *) { #ifndef Q_OS_WINCE - Q_UNUSED(hwnd); typedef QWindowSystemInterface::TouchPoint QTouchPoint; typedef QList QTouchPointList; @@ -545,8 +544,24 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND hwnd, QWindowSystemInterface::handleTouchEvent(window, m_touchDevice, touchPoints); +#else // !Q_OS_WINCE + Q_UNUSED(window) + Q_UNUSED(msg) +#endif return true; -#else //Q_OS_WINCE + +} + +bool QWindowsMouseHandler::translateGestureEvent(QWindow *window, HWND hwnd, + QtWindows::WindowsEventType, + MSG msg, LRESULT *) +{ +#ifndef Q_OS_WINCE + Q_UNUSED(window) + Q_UNUSED(hwnd) + Q_UNUSED(msg) + return false; +#else // !Q_OS_WINCE GESTUREINFO gi; memset(&gi, 0, sizeof(GESTUREINFO)); gi.cbSize = sizeof(GESTUREINFO); @@ -625,9 +640,8 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND hwnd, QWindowSystemInterface::handleEnterEvent(window); m_windowUnderMouse = window; } - return true; -#endif +#endif // Q_OS_WINCE } QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.h b/src/plugins/platforms/windows/qwindowsmousehandler.h index ce3e6b6fc4..61aa8d6084 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.h +++ b/src/plugins/platforms/windows/qwindowsmousehandler.h @@ -59,6 +59,9 @@ public: bool translateTouchEvent(QWindow *widget, HWND hwnd, QtWindows::WindowsEventType t, MSG msg, LRESULT *result); + bool translateGestureEvent(QWindow *window, HWND hwnd, + QtWindows::WindowsEventType, + MSG msg, LRESULT *); bool translateScrollEvent(QWindow *window, HWND hwnd, MSG msg, LRESULT *result); -- cgit v1.2.3 From 5e3e34731b7880ac775e8f1fa156ce016e6820f1 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Mon, 18 May 2015 09:27:10 +0400 Subject: Default implementation for QPlatformFontDatabase::fallbacksForFamily() ...mainly for platforms that do not provide a native/unified way to obtain system-defined font fallbacks list (ie !CoreText && !FontConfig). Change-Id: I23c5589d79ddecb6311ccc52ec8b29977f06d408 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/windows/qwindowsfontdatabase.cpp | 11 +++-------- src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp | 6 +++--- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index b1bb944fc6..3b27964b0e 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -1080,11 +1080,7 @@ QWindowsFontDatabase::~QWindowsFontDatabase() QFontEngineMulti *QWindowsFontDatabase::fontEngineMulti(QFontEngine *fontEngine, QChar::Script script) { - if (script == QChar::Script_Common) - return new QWindowsMultiFontEngine(fontEngine, script); - // ### as long as fallbacksForFamily() does not take script parameter into account, - // prefer QFontEngineMulti's loadEngine() implementation for complex scripts - return QPlatformFontDatabase::fontEngineMulti(fontEngine, script); + return new QWindowsMultiFontEngine(fontEngine, script); } QFontEngine * QWindowsFontDatabase::fontEngine(const QFontDef &fontDef, void *handle) @@ -1666,11 +1662,10 @@ QString QWindowsFontDatabase::familyForStyleHint(QFont::StyleHint styleHint) QStringList QWindowsFontDatabase::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const { - QStringList result = QPlatformFontDatabase::fallbacksForFamily(family, style, styleHint, script); - if (!result.isEmpty()) - return result; + QStringList result; result.append(QWindowsFontDatabase::familyForStyleHint(styleHint)); result.append(QWindowsFontDatabase::extraTryFontsForFamily(family)); + result.append(QPlatformFontDatabase::fallbacksForFamily(family, style, styleHint, script)); qCDebug(lcQpaFonts) << __FUNCTION__ << family << style << styleHint << script << result; diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp index ad75a0bd54..795554698c 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp @@ -661,9 +661,7 @@ QFontEngine *QWindowsFontDatabaseFT::fontEngine(const QByteArray &fontData, qrea QStringList QWindowsFontDatabaseFT::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const { - QStringList result = QPlatformFontDatabase::fallbacksForFamily(family, style, styleHint, script); - if (!result.isEmpty()) - return result; + QStringList result; result.append(QWindowsFontDatabase::familyForStyleHint(styleHint)); @@ -679,6 +677,8 @@ QStringList QWindowsFontDatabaseFT::fallbacksForFamily(const QString &family, QF result.append(QWindowsFontDatabase::extraTryFontsForFamily(family)); + result.append(QPlatformFontDatabase::fallbacksForFamily(family, style, styleHint, script)); + qCDebug(lcQpaFonts) << __FUNCTION__ << family << style << styleHint << script << result; -- cgit v1.2.3