summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2010-11-12 00:00:10 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2010-11-12 00:00:10 (GMT)
commit2e36c20f3039b94b02b49567edf4470fe73cceb8 (patch)
tree86ec0c4880619e0b7f8bb60f241090de2402a53f
parentf153f135f18b0874d456f01ea8d73d127685b3fb (diff)
parent7b3880475d02bd3db630387bccccc7e1ef9d4e9a (diff)
downloadQt-2e36c20f3039b94b02b49567edf4470fe73cceb8.zip
Qt-2e36c20f3039b94b02b49567edf4470fe73cceb8.tar.gz
Qt-2e36c20f3039b94b02b49567edf4470fe73cceb8.tar.bz2
Merge branch 'master-upstream' into master-water
-rw-r--r--src/corelib/concurrent/qtconcurrentrunbase.h25
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac.mm22
-rw-r--r--src/gui/kernel/qwidget.cpp4
-rw-r--r--src/gui/text/qfontengine.cpp20
-rw-r--r--src/gui/text/qfontengine_mac.mm2
-rw-r--r--src/gui/text/qfontengine_p.h3
-rw-r--r--src/gui/widgets/qcocoamenu_mac.mm22
-rw-r--r--tests/auto/qtconcurrentrun/tst_qtconcurrentrun.cpp38
8 files changed, 121 insertions, 15 deletions
diff --git a/src/corelib/concurrent/qtconcurrentrunbase.h b/src/corelib/concurrent/qtconcurrentrunbase.h
index a6bbe3e..888d395 100644
--- a/src/corelib/concurrent/qtconcurrentrunbase.h
+++ b/src/corelib/concurrent/qtconcurrentrunbase.h
@@ -100,7 +100,18 @@ public:
this->reportFinished();
return;
}
- this->runFunctor();
+#ifndef QT_NO_EXCEPTIONS
+ try {
+#endif
+ this->runFunctor();
+#ifndef QT_NO_EXCEPTIONS
+ } catch (QtConcurrent::Exception &e) {
+ QFutureInterface<T>::reportException(e);
+ } catch (...) {
+ QFutureInterface<T>::reportException(QtConcurrent::UnhandledException());
+ }
+#endif
+
this->reportResult(result);
this->reportFinished();
}
@@ -117,7 +128,17 @@ public:
this->reportFinished();
return;
}
- this->runFunctor();
+#ifndef QT_NO_EXCEPTIONS
+ try {
+#endif
+ this->runFunctor();
+#ifndef QT_NO_EXCEPTIONS
+ } catch (QtConcurrent::Exception &e) {
+ QFutureInterface<void>::reportException(e);
+ } catch (...) {
+ QFutureInterface<void>::reportException(QtConcurrent::UnhandledException());
+ }
+#endif
this->reportFinished();
}
};
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 <qdesktopwidget.h>
#include <qevent.h>
#include <qpixmapcache.h>
+#include <qvarlengtharray.h>
#include <private/qevent_p.h>
#include <private/qt_cocoa_helpers_mac_p.h>
#include <private/qt_mac_p.h>
@@ -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 <unichar, 10> characters(len);
+ bool changed = false;
+ for (int i = 0; i<len; i++) {
+ characters[i] = [string characterAtIndex:i];
+ // check if they belong to key codes in private unicode range
+ // currently we need to handle only the NSDeleteFunctionKey
+ if (characters[i] == NSDeleteFunctionKey) {
+ characters[i] = NSDeleteCharacter;
+ changed = true;
+ }
+ }
+ if (changed)
+ return [NSString stringWithCharacters:characters.data() length:len];
+ }
+ return string;
+}
+
Qt::KeyboardModifiers qt_cocoaDragOperation2QtModifiers(uint dragOperations)
{
Qt::KeyboardModifiers qtMods =Qt::NoModifier;
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;
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;
diff --git a/src/gui/widgets/qcocoamenu_mac.mm b/src/gui/widgets/qcocoamenu_mac.mm
index 15fae23..b670186 100644
--- a/src/gui/widgets/qcocoamenu_mac.mm
+++ b/src/gui/widgets/qcocoamenu_mac.mm
@@ -156,10 +156,14 @@ QT_USE_NAMESPACE
// In every other case we return NO, which means that Cocoa can do as it pleases
// (i.e., fire the menu action).
NSMenuItem *whichItem;
+ // Change the private unicode keys to the ones used in setting the "Key Equivalents"
+ extern NSString *qt_mac_removePrivateUnicode(NSString* string);
+ NSString *characters = qt_mac_removePrivateUnicode([event characters]);
if ([self hasShortcut:menu
- forKey:[event characters]
- forModifiers:([event modifierFlags] & NSDeviceIndependentModifierFlagsMask)
- whichItem:&whichItem]) {
+ forKey:characters
+ // Interested only in Shift, Cmd, Ctrl & Alt Keys, so ignoring masks like, Caps lock, Num Lock ...
+ forModifiers:([event modifierFlags] & (NSShiftKeyMask | NSControlKeyMask | NSCommandKeyMask | NSAlternateKeyMask))
+ whichItem:&whichItem]) {
QWidget *widget = 0;
QAction *qaction = 0;
if (whichItem && [whichItem tag]) {
@@ -170,6 +174,9 @@ QT_USE_NAMESPACE
qApp->activePopupWidget()->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;
}
}
}
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()
{