From 98d51e42c81c0674bc724eccbdf8521d9317998a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 11 Nov 2010 09:59:53 +0100 Subject: Support exception handling in QtConcurrent::run() Use QFutureInterface::reportException() in the same way that we do in QtConcurrent::map(). --- src/corelib/concurrent/qtconcurrentrunbase.h | 26 +++++++++++++-- tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp | 38 ++++++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/src/corelib/concurrent/qtconcurrentrunbase.h b/src/corelib/concurrent/qtconcurrentrunbase.h index a6bbe3e..a7a5cc4 100644 --- a/src/corelib/concurrent/qtconcurrentrunbase.h +++ b/src/corelib/concurrent/qtconcurrentrunbase.h @@ -100,7 +100,19 @@ public: this->reportFinished(); return; } - this->runFunctor(); +#ifndef QT_NO_EXCEPTIONS + try { +#endif + this->runFunctor(); +#ifndef QT_NO_EXCEPTIONS + } catch (QtConcurrent::Exception &e) { + qDebug() << "cought exception"; + QFutureInterface::reportException(e); + } catch (...) { + QFutureInterface::reportException(QtConcurrent::UnhandledException()); + } +#endif + this->reportResult(result); this->reportFinished(); } @@ -117,7 +129,17 @@ public: this->reportFinished(); return; } - this->runFunctor(); +#ifndef QT_NO_EXCEPTIONS + try { +#endif + this->runFunctor(); +#ifndef QT_NO_EXCEPTIONS + } catch (QtConcurrent::Exception &e) { + QFutureInterface::reportException(e); + } catch (...) { + QFutureInterface::reportException(QtConcurrent::UnhandledException()); + } +#endif this->reportFinished(); } }; diff --git a/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp b/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp index 8fdc50c..8b10ea4 100644 --- a/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp +++ b/tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp @@ -61,6 +61,9 @@ private slots: void implicitConvertibleTypes(); void runWaitLoop(); void recursive(); +#ifndef QT_NO_EXCEPTIONS + void exceptions(); +#endif #if 0 void createFunctor(); #endif @@ -374,6 +377,41 @@ int fn2(double, int *) return 1; } + +#ifndef QT_NO_EXCEPTIONS +void throwFunction() +{ + throw QtConcurrent::Exception(); +} + +int throwFunctionReturn() +{ + throw QtConcurrent::Exception(); + return 0; +} + +void tst_QtConcurrentRun::exceptions() +{ + bool caught = false; + try { + QtConcurrent::run(throwFunction).waitForFinished(); + } catch (Exception &e) { + caught = true; + } + if (!caught) + QFAIL("did not get exception"); + + caught = false; + try { + QtConcurrent::run(throwFunctionReturn).waitForFinished(); + } catch (Exception &e) { + caught = true; + } + if (!caught) + QFAIL("did not get exception"); +} +#endif + #if 0 void tst_QtConcurrentRun::createFunctor() { -- cgit v0.12 From 8e8bae1f4faf676b6104bbf9039ad10f139fa7e8 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Thu, 11 Nov 2010 10:42:05 +0100 Subject: Fix for font engines that don't support subpixel positioning Reviewed-by: aavit --- src/gui/text/qfontengine.cpp | 20 +++++++++++++++++--- src/gui/text/qfontengine_mac.mm | 2 +- src/gui/text/qfontengine_p.h | 3 ++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 816c14a..24c4664 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -605,12 +605,13 @@ void QFontEngine::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int n addBitmapFontToPath(x, y, g, path, flags); } -QImage QFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &t) +QImage QFontEngine::alphaMapForGlyph(glyph_t glyph, QFixed /*subPixelPosition*/) { - return alphaMapForGlyph(glyph, 0, t); + // For font engines don't support subpixel positioning + return alphaMapForGlyph(glyph); } -QImage QFontEngine::alphaMapForGlyph(glyph_t glyph, QFixed /*subPixelPosition*/, const QTransform &t) +QImage QFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &t) { QImage i = alphaMapForGlyph(glyph); if (t.type() > QTransform::TxTranslate) @@ -620,6 +621,19 @@ QImage QFontEngine::alphaMapForGlyph(glyph_t glyph, QFixed /*subPixelPosition*/, return i; } +QImage QFontEngine::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t) +{ + if (! supportsSubPixelPositions()) + return alphaMapForGlyph(glyph, t); + + QImage i = alphaMapForGlyph(glyph, subPixelPosition); + if (t.type() > QTransform::TxTranslate) + i = i.transformed(t).convertToFormat(QImage::Format_Indexed8); + Q_ASSERT(i.depth() <= 8); // To verify that transformed didn't change the format... + + return i; +} + QImage QFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed /*subPixelPosition*/, int /* margin */, const QTransform &t) { QImage alphaMask = alphaMapForGlyph(glyph, t); diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm index cebd1f5..7efb1cc 100644 --- a/src/gui/text/qfontengine_mac.mm +++ b/src/gui/text/qfontengine_mac.mm @@ -713,7 +713,7 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition return im; } -QImage QCoreTextFontEngine::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t) +QImage QCoreTextFontEngine::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition) { QImage im = imageForGlyph(glyph, subPixelPosition, 0, false); diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 061bcfd..be9f48d 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -196,6 +196,7 @@ public: * Returns an image indexed_8 with index values ranging from 0=fully transparant to 255=opaque */ virtual QImage alphaMapForGlyph(glyph_t); + virtual QImage alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition); virtual QImage alphaMapForGlyph(glyph_t, const QTransform &t); virtual QImage alphaMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t); virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, int margin, const QTransform &t); @@ -474,7 +475,7 @@ public: virtual FaceId faceId() const; virtual bool getSfntTableData(uint /*tag*/, uchar * /*buffer*/, uint * /*length*/) const; virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics); - virtual QImage alphaMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t); + virtual QImage alphaMapForGlyph(glyph_t, QFixed subPixelPosition); virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, int margin, const QTransform &t); virtual qreal minRightBearing() const; virtual qreal minLeftBearing() const; -- cgit v0.12 From 451c3e973a49c8b467cc865f6d1f4a2c21902dc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 11 Nov 2010 13:01:37 +0100 Subject: Remove qDebug. --- src/corelib/concurrent/qtconcurrentrunbase.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/corelib/concurrent/qtconcurrentrunbase.h b/src/corelib/concurrent/qtconcurrentrunbase.h index a7a5cc4..888d395 100644 --- a/src/corelib/concurrent/qtconcurrentrunbase.h +++ b/src/corelib/concurrent/qtconcurrentrunbase.h @@ -106,7 +106,6 @@ public: this->runFunctor(); #ifndef QT_NO_EXCEPTIONS } catch (QtConcurrent::Exception &e) { - qDebug() << "cought exception"; QFutureInterface::reportException(e); } catch (...) { QFutureInterface::reportException(QtConcurrent::UnhandledException()); -- cgit v0.12 From 54865d47cfd859a0e84ba8e1bbff3b56c93d4e0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 11 Nov 2010 13:37:48 +0100 Subject: Fix restore of maximized window geometry on Windows Task-number: QTBUG-2064 --- src/gui/kernel/qwidget.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 25450ce..cd1c9f0 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -7053,7 +7053,11 @@ bool QWidget::restoreGeometry(const QByteArray &geometry) if (maximized || fullScreen) { // set geomerty before setting the window state to make // sure the window is maximized to the right screen. + // Skip on windows: the window is restored into a broken + // half-maximized state. +#ifndef Q_WS_WIN setGeometry(restoredNormalGeometry); +#endif Qt::WindowStates ws = windowState(); if (maximized) ws |= Qt::WindowMaximized; -- cgit v0.12 From 4b618e48c909fcc5665e9d60645023c48b2ffb43 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 11 Nov 2010 12:29:44 +0100 Subject: ShortcutOverride has no effect on some shortcuts on Mac OS X (Cocoa). When generating the native key sequences for menu items, Qt prefers the non private unicode characters. But the characters in the NSEvent for keyboard events can contain characters form the unicode range reserved for Apple. For e.g. when user presses the "delete" key, the event contains NSDeleteFunctionKey, where in Qt is expecting NSDeleteCharacter. For now this is the only key identified for translation. If we find similar translations, those can be added to qt_mac_removePrivateUnicode(). Task-number: QTBUG-12495 Reviewed-by: Denis --- src/gui/kernel/qt_cocoa_helpers_mac.mm | 22 ++++++++++++++++++++++ src/gui/widgets/qcocoamenu_mac.mm | 22 ++++++++++++++-------- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index 5a522f9..48d21e9 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -79,6 +79,7 @@ #include #include #include +#include #include #include #include @@ -616,6 +617,27 @@ Qt::KeyboardModifiers qt_cocoaModifiers2QtModifiers(ulong modifierFlags) return qtMods; } +NSString *qt_mac_removePrivateUnicode(NSString* string) +{ + int len = [string length]; + if (len) { + QVarLengthArray characters(len); + bool changed = false; + for (int i = 0; iactivePopupWidget()->focusWidget() : qApp->activePopupWidget()); else if (QApplicationPrivate::focus_widget) widget = QApplicationPrivate::focus_widget; + // If we could not find any receivers, pass it to the active window + if (!widget) + widget = qApp->activeWindow(); if (qaction && widget) { int key = qaction->shortcut(); QKeyEvent accel_ev(QEvent::ShortcutOverride, (key & (~Qt::KeyboardModifierMask)), @@ -177,11 +184,10 @@ QT_USE_NAMESPACE accel_ev.ignore(); qt_sendSpontaneousEvent(widget, &accel_ev); if (accel_ev.isAccepted()) { - if (qt_dispatchKeyEvent(event, widget)) { - *target = nil; - *action = nil; - return YES; - } + qt_dispatchKeyEvent(event, widget); + *target = nil; + *action = nil; + return YES; } } } -- cgit v0.12