#559 Fix Qt font rendering on OS X 10.9

brodykenrick-master
Marius Kintel 2013-12-08 15:16:58 -05:00
parent b131464f95
commit 88cc7edafd
2 changed files with 115 additions and 0 deletions

View File

@ -0,0 +1,86 @@
--- src/gui/kernel/qeventdispatcher_mac_p.h 2013-06-07 01:16:59.000000000 -0400
+++ src/gui/kernel/qeventdispatcher_mac_p_new-8184b49c12d887928921ed5b695c8c6f04a07514.h 2013-12-08 14:31:01.000000000 -0500
@@ -173,6 +173,7 @@
#ifdef QT_MAC_USE_COCOA
// The following variables help organizing modal sessions:
static QStack<QCocoaModalSessionInfo> cocoaModalSessionStack;
+ static QStack<QCocoaModalSessionInfo> cocoaModalSessionStackPendingEnd;
static bool currentExecIsNSAppRun;
static bool nsAppRunCalledByQt;
static bool cleanupModalSessionsNeeded;
@@ -180,6 +181,7 @@
static NSModalSession currentModalSession();
static void updateChildrenWorksWhenModal();
static void temporarilyStopAllModalSessions();
+ static void stopAllPendingEndModalSessions();
static void beginModalSession(QWidget *widget);
static void endModalSession(QWidget *widget);
static void cancelWaitForMoreEvents();
--- src/gui/kernel/qeventdispatcher_mac.mm 2013-06-07 01:16:59.000000000 -0400
+++ src/gui/kernel/qeventdispatcher_mac_new-833e02de99494686f8dd7a567f6e19e847508f11.mm 2013-12-08 14:30:59.000000000 -0500
@@ -603,6 +603,9 @@
while ([NSApp runModalSession:session] == NSRunContinuesResponse && !d->interrupt)
qt_mac_waitForMoreModalSessionEvents();
+ // stop all pending end modal sessions
+ d->stopAllPendingEndModalSessions();
+
if (!d->interrupt && session == d->currentModalSessionCached) {
// Someone called [NSApp stopModal:] from outside the event
// dispatcher (e.g to stop a native dialog). But that call wrongly stopped
@@ -678,6 +681,9 @@
if (!d->interrupt)
QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData);
+ // stop all pending end modal sessions
+ d->stopAllPendingEndModalSessions();
+
// Since the window that holds modality might have changed while processing
// events, we we need to interrupt when we return back the previous process
// event recursion to ensure that we spin the correct modal session.
@@ -781,6 +787,7 @@
#ifdef QT_MAC_USE_COCOA
QStack<QCocoaModalSessionInfo> QEventDispatcherMacPrivate::cocoaModalSessionStack;
+QStack<QCocoaModalSessionInfo> QEventDispatcherMacPrivate::cocoaModalSessionStackPendingEnd;
bool QEventDispatcherMacPrivate::currentExecIsNSAppRun = false;
bool QEventDispatcherMacPrivate::nsAppRunCalledByQt = false;
bool QEventDispatcherMacPrivate::cleanupModalSessionsNeeded = false;
@@ -828,6 +835,20 @@
currentModalSessionCached = 0;
}
+void QEventDispatcherMacPrivate::stopAllPendingEndModalSessions()
+{
+ // stop all modal sessions pending end
+ int stackSize = cocoaModalSessionStackPendingEnd.size();
+ for (int i=stackSize-1; i>=0; --i) {
+ QCocoaModalSessionInfo &info = cocoaModalSessionStackPendingEnd[i];
+ cocoaModalSessionStackPendingEnd.remove(i);
+ if (info.session) {
+ [NSApp endModalSession:info.session];
+ [(NSWindow *)info.nswindow release];
+ }
+ }
+}
+
NSModalSession QEventDispatcherMacPrivate::currentModalSession()
{
// If we have one or more modal windows, this function will create
@@ -925,10 +946,12 @@
}
cocoaModalSessionStack.remove(i);
currentModalSessionCached = 0;
- if (info.session) {
- [NSApp endModalSession:info.session];
- [(NSWindow *)info.nswindow release];
- }
+
+ // Cannot stop the sessions here since we might still be inside a
+ // [NSApp runModalSession:] call. Add the session to the pending end stack and
+ // process the stack after the call to [NSApp runModalSession:] returns.
+ if (info.session)
+ cocoaModalSessionStackPendingEnd.push(info);
}
updateChildrenWorksWhenModal();

View File

@ -0,0 +1,29 @@
--- src/gui/text/qfontdatabase.cpp 2013-06-07 01:16:59.000000000 -0400
+++ src/gui/text/qfontdatabase_new-bb2beddc3ae55c4676d190d0ac99aa32d322a6a5.cpp 2013-12-08 14:51:10.000000000 -0500
@@ -441,6 +441,7 @@
#endif
#if !defined(QWS) && defined(Q_OS_MAC)
bool fixedPitchComputed : 1;
+ QString postscriptName;
#endif
#ifdef Q_WS_X11
bool symbol_checked : 1;
--- src/gui/text/qfontdatabase_mac.cpp 2013-06-07 01:16:59.000000000 -0400
+++ src/gui/text/qfontdatabase_mac_new-41f29865db84152efb41c048470f713353a0a84c.cpp 2013-12-08 14:51:05.000000000 -0500
@@ -147,6 +147,7 @@
QCFString family_name = (CFStringRef)CTFontDescriptorCopyLocalizedAttribute(font, kCTFontFamilyNameAttribute, NULL);
QCFString style_name = (CFStringRef)CTFontDescriptorCopyLocalizedAttribute(font, kCTFontStyleNameAttribute, NULL);
QtFontFamily *family = db->family(family_name, true);
+ family->postscriptName = QCFString((CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontNameAttribute));
if (QCFType<CFArrayRef> languages = (CFArrayRef) CTFontDescriptorCopyAttribute(font, kCTFontLanguagesAttribute)) {
CFIndex length = CFArrayGetCount(languages);
@@ -327,7 +328,7 @@
if (db->families[k]->name.compare(family_list.at(i), Qt::CaseInsensitive) == 0) {
QByteArray family_name = db->families[k]->name.toUtf8();
#if defined(QT_MAC_USE_COCOA)
- QCFType<CTFontRef> ctFont = CTFontCreateWithName(QCFString(db->families[k]->name), 12, NULL);
+ QCFType<CTFontRef> ctFont = CTFontCreateWithName(QCFString(db->families[k]->postscriptName), 12, NULL);
if (ctFont) {
fontName = CTFontCopyFullName(ctFont);
goto found;