From b7ea50145c6dc443e15d9f3f1e1dd1737a5135cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Thu, 29 Apr 2010 09:11:02 +0200 Subject: Ensured that WA_InputMethodEnabled was set before FocusInEvent was sent. When focusInEvent is called we need to ensure that WA_InputMethodEnabled is set, since FocusInEvent might lead to that QInputContext::setFocusWidget is called (with the QGraphicsView as the widget parameter). However, if the widget still does not have WA_InputMethodEnabled set yet it will assert in QInputContext::setFocusWidget (it requires that the widget has the flag set). This was a problem for the morbit bridge, where Dui requires the attribute to be set (while Orbit actually does not require) Task-number: QTBUG-10276 Reviewed-by: jasplin Reviewed-by: Alexis Menard --- src/gui/graphicsview/qgraphicsscene.cpp | 6 +++--- tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 26 ++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index b368a82..98fc10f 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -808,13 +808,13 @@ void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item, #endif //QT_NO_IM } - if (item) { + if (item) focusItem = item; + updateInputMethodSensitivityInViews(); + if (item) { QFocusEvent event(QEvent::FocusIn, focusReason); sendEvent(item, &event); } - - updateInputMethodSensitivityInViews(); } /*! diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 1c19fab..e3c699b 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -3664,6 +3664,22 @@ void tst_QGraphicsView::update() #endif } +class FocusItem : public QGraphicsRectItem +{ +public: + FocusItem() : QGraphicsRectItem(0, 0, 20, 20) { + m_viewHasIMEnabledInFocusInEvent = false; + } + + void focusInEvent(QFocusEvent *event) + { + QGraphicsView *view = scene()->views().first(); + m_viewHasIMEnabledInFocusInEvent = view->testAttribute(Qt::WA_InputMethodEnabled); + } + + bool m_viewHasIMEnabledInFocusInEvent; +}; + void tst_QGraphicsView::inputMethodSensitivity() { QGraphicsScene scene; @@ -3673,7 +3689,7 @@ void tst_QGraphicsView::inputMethodSensitivity() QApplication::setActiveWindow(&view); QTRY_COMPARE(QApplication::activeWindow(), static_cast(&view)); - QGraphicsRectItem *item = new QGraphicsRectItem; + FocusItem *item = new FocusItem; view.setAttribute(Qt::WA_InputMethodEnabled, true); @@ -3702,6 +3718,7 @@ void tst_QGraphicsView::inputMethodSensitivity() scene.setFocusItem(item); QCOMPARE(scene.focusItem(), static_cast(item)); QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), true); + QCOMPARE(item->m_viewHasIMEnabledInFocusInEvent, true); item->setFlag(QGraphicsItem::ItemAcceptsInputMethod, false); QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), false); @@ -3710,15 +3727,17 @@ void tst_QGraphicsView::inputMethodSensitivity() QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), true); // introduce another item that is focusable but does not accept input methods - QGraphicsRectItem *item2 = new QGraphicsRectItem; + FocusItem *item2 = new FocusItem; item2->setFlag(QGraphicsItem::ItemIsFocusable); scene.addItem(item2); scene.setFocusItem(item2); QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), false); + QCOMPARE(item2->m_viewHasIMEnabledInFocusInEvent, false); QCOMPARE(scene.focusItem(), static_cast(item2)); scene.setFocusItem(item); QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), true); + QCOMPARE(item->m_viewHasIMEnabledInFocusInEvent, true); QCOMPARE(scene.focusItem(), static_cast(item)); view.setScene(0); @@ -3727,10 +3746,12 @@ void tst_QGraphicsView::inputMethodSensitivity() view.setScene(&scene); QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), true); + QCOMPARE(item->m_viewHasIMEnabledInFocusInEvent, true); QCOMPARE(scene.focusItem(), static_cast(item)); scene.setFocusItem(item2); QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), false); + QCOMPARE(item2->m_viewHasIMEnabledInFocusInEvent, false); QCOMPARE(scene.focusItem(), static_cast(item2)); view.setScene(0); @@ -3743,6 +3764,7 @@ void tst_QGraphicsView::inputMethodSensitivity() view.setScene(&scene); QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), true); + QCOMPARE(item->m_viewHasIMEnabledInFocusInEvent, true); QCOMPARE(scene.focusItem(), static_cast(item)); } -- cgit v0.12 From 2dbb9373af3d5cb0d395d99bad285d195ae9fa5c Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 29 Apr 2010 13:42:37 +0300 Subject: Fix long menu item texts causing crash Symbian uses buffer of CEikMenuPaneItem::SData::ENominalTextLength characters for menu item texts, so truncate any text that is longer than that. Task-number: QTBUG-10207 Reviewed-by: Janne Anttila --- src/gui/widgets/qmenu_symbian.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp index 7224768..d4b1250 100644 --- a/src/gui/widgets/qmenu_symbian.cpp +++ b/src/gui/widgets/qmenu_symbian.cpp @@ -149,8 +149,12 @@ static void qt_symbian_insert_action(QSymbianMenuAction* action, QListstyleHint(QStyle::SH_UnderlineShortcut); - QString iconText = action->action->iconText(); - TPtrC menuItemText = qt_QString2TPtrC( underlineShortCut ? action->action->text() : iconText); + QString actionText; + if (underlineShortCut) + actionText = action->action->text().left(CEikMenuPaneItem::SData::ENominalTextLength); + else + actionText = action->action->iconText().left(CEikMenuPaneItem::SData::ENominalTextLength); + TPtrC menuItemText = qt_QString2TPtrC(actionText); if (action->action->menu()) { SymbianMenuItem* menuItem = new SymbianMenuItem(); menuItem->menuItemData.iCascadeId = action->command; -- cgit v0.12 From 78e8af4fea3cc527b0dc5ace5a4c4445f044c2cd Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 29 Apr 2010 13:14:06 +0200 Subject: tst_selftest: Fix off-by-one error in cleaning up line numbers and filenames --- tests/auto/selftests/tst_selftests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp index 0be4e22..30b2126 100644 --- a/tests/auto/selftests/tst_selftests.cpp +++ b/tests/auto/selftests/tst_selftests.cpp @@ -131,11 +131,11 @@ static QList splitLines(QByteArray ba) if (index == -1) { continue; } - int end = line.indexOf('"', index + strlen(markers[j][0]) + 1); + int end = line.indexOf('"', index + strlen(markers[j][0])); if (end == -1) { continue; } - line.replace(index, end-index, markers[j][1]); + line.replace(index, end-index + 1, markers[j][1]); } } -- cgit v0.12 From ce3d9fb3b3ec1f23d76b04a8593680d7eeee689d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 29 Apr 2010 13:14:09 +0200 Subject: Fix crash in QDBusInterface when invoking a method in a derived class. If metaObject is 0 and the signal or slot is in a class deriving from QDBusInterface, this would lead to a crash. Deriving from QDBusInterface is very unusual and usually indicates misunderstanding of QtDBus, but the fix is correct. Task-number: https://projects.maemo.org/bugzilla/show_bug.cgi?id=165175 Patch-By: Maemo developer Reviewed-by: Thiago Macieira --- src/dbus/qdbusinterface.cpp | 2 +- tests/auto/qdbusinterface/tst_qdbusinterface.cpp | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/dbus/qdbusinterface.cpp b/src/dbus/qdbusinterface.cpp index 300f425..56d5231 100644 --- a/src/dbus/qdbusinterface.cpp +++ b/src/dbus/qdbusinterface.cpp @@ -258,7 +258,7 @@ void *QDBusInterface::qt_metacast(const char *_clname) int QDBusInterface::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QDBusAbstractInterface::qt_metacall(_c, _id, _a); - if (_id < 0 || !d_func()->isValid) + if (_id < 0 || !d_func()->isValid || !d_func()->metaObject) return _id; return d_func()->metacall(_c, _id, _a); } diff --git a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp index 826bd70..d8ff2d3 100644 --- a/tests/auto/qdbusinterface/tst_qdbusinterface.cpp +++ b/tests/auto/qdbusinterface/tst_qdbusinterface.cpp @@ -157,6 +157,18 @@ public slots: } }; +class DerivedFromQDBusInterface: public QDBusInterface +{ + Q_OBJECT +public: + DerivedFromQDBusInterface() + : QDBusInterface("com.example.Test", "/") + {} + +public slots: + void method() {} +}; + // helper function void emitSignal(const QString &interface, const QString &name, const QString &arg) { @@ -183,6 +195,7 @@ private slots: void notConnected(); void notValid(); + void notValidDerived(); void invalidAfterServiceOwnerChanged(); void introspect(); void callMethod(); @@ -219,6 +232,7 @@ void tst_QDBusInterface::notConnected() connection); QVERIFY(!interface.isValid()); + QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection)); } void tst_QDBusInterface::notValid() @@ -230,6 +244,14 @@ void tst_QDBusInterface::notValid() connection); QVERIFY(!interface.isValid()); + QVERIFY(!QMetaObject::invokeMethod(&interface, "ListNames", Qt::DirectConnection)); +} + +void tst_QDBusInterface::notValidDerived() +{ + DerivedFromQDBusInterface c; + QVERIFY(!c.isValid()); + QMetaObject::invokeMethod(&c, "method", Qt::DirectConnection); } void tst_QDBusInterface::invalidAfterServiceOwnerChanged() -- cgit v0.12 From 7fac03fc111f0c5938eff80f96d25c03c70c4040 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Thu, 29 Apr 2010 13:29:06 +0200 Subject: Fixed a leak in QTextDocument::print(). Also fixed a typo in the QScopedPointer docs. Task-number: QTBUG-10301 Reviewed-by: Kim --- src/corelib/tools/qscopedpointer.cpp | 4 ++-- src/gui/text/qtextdocument.cpp | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp index e7dd769..b06112d 100644 --- a/src/corelib/tools/qscopedpointer.cpp +++ b/src/corelib/tools/qscopedpointer.cpp @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE called resource acquisition is initialization(RAII). QScopedPointer guarantees that the object pointed to will get deleted when - the current scope dissapears. + the current scope disappears. Consider this function which does heap allocations, and have various exit points: @@ -227,7 +227,7 @@ QT_BEGIN_NAMESPACE /*! \class QScopedArrayPointer - + \brief The QScopedArrayPointer class stores a pointer to a dynamically allocated array of objects, and deletes it upon destruction. diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index f5d322a..1677ee6 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -1679,7 +1679,7 @@ void QTextDocument::print(QPrinter *printer) const return; const QTextDocument *doc = this; - QTextDocument *clonedDoc = 0; + QScopedPointer clonedDoc; (void)doc->documentLayout(); // make sure that there is a layout QRectF body = QRectF(QPointF(0, 0), d->pageSize); @@ -1712,7 +1712,7 @@ void QTextDocument::print(QPrinter *printer) const printerPageSize.height() / scaledPageSize.height()); } else { doc = clone(const_cast(this)); - clonedDoc = const_cast(doc); + clonedDoc.reset(const_cast(doc)); for (QTextBlock srcBlock = firstBlock(), dstBlock = clonedDoc->firstBlock(); srcBlock.isValid() && dstBlock.isValid(); @@ -1787,7 +1787,7 @@ void QTextDocument::print(QPrinter *printer) const for (int j = 0; j < pageCopies; ++j) { if (printer->printerState() == QPrinter::Aborted || printer->printerState() == QPrinter::Error) - goto UserCanceled; + return; printPage(page, &p, doc, body, pageNumberPos); if (j < pageCopies - 1) printer->newPage(); @@ -1807,9 +1807,6 @@ void QTextDocument::print(QPrinter *printer) const if ( i < docCopies - 1) printer->newPage(); } - -UserCanceled: - delete clonedDoc; } #endif -- cgit v0.12 From e07a0d8acae7feb4142f0848baf68cee267498fe Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 29 Apr 2010 14:35:18 +0300 Subject: Revert "Event dispatcher slow down using delays rather than thread priority" This reverts commit 99dbc23113eaf40f4e311eb0f21092e54676bd10. This commit caused UI to freeze on gui applications on older phones such as 5800XM and N95. --- src/corelib/kernel/qeventdispatcher_symbian.cpp | 127 +++++++----------------- src/corelib/kernel/qeventdispatcher_symbian_p.h | 5 +- 2 files changed, 37 insertions(+), 95 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index fa337ca..8c96057 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -635,74 +636,6 @@ void QSocketActiveObject::deleteLater() } } -#ifdef QT_SYMBIAN_PRIORITY_DROP -class QIdleDetectorThread -{ -public: - QIdleDetectorThread() - : m_state(STATE_RUN), m_stop(false) - { - qt_symbian_throwIfError(m_lock.CreateLocal()); - TInt err = m_idleDetectorThread.Create(KNullDesC(), &idleDetectorThreadFunc, 1024, &User::Allocator(), this); - if (err != KErrNone) - m_lock.Close(); - qt_symbian_throwIfError(err); - m_idleDetectorThread.SetPriority(EPriorityAbsoluteBackgroundNormal); - m_idleDetectorThread.Resume(); - } - - ~QIdleDetectorThread() - { - // close down the idle thread because if corelib is loaded temporarily, this would leak threads into the host process - m_stop = true; - m_lock.Signal(); - m_idleDetectorThread.SetPriority(EPriorityNormal); - TRequestStatus s; - m_idleDetectorThread.Logon(s); - User::WaitForRequest(s); - m_idleDetectorThread.Close(); - m_lock.Close(); - } - - void kick() - { - m_state = STATE_KICKED; - m_lock.Signal(); - } - - bool hasRun() - { - return m_state == STATE_RUN; - } - -private: - static TInt idleDetectorThreadFunc(TAny* self) - { - static_cast(self)->IdleLoop(); - return KErrNone; - } - - void IdleLoop() - { - while (!m_stop) { - m_lock.Wait(); - m_state = STATE_RUN; - } - } - -private: - enum IdleStates {STATE_KICKED, STATE_RUN} m_state; - bool m_stop; - RThread m_idleDetectorThread; - RFastLock m_lock; -}; - -Q_GLOBAL_STATIC(QIdleDetectorThread, idleDetectorThread); - -const int maxBusyTime = 2000; // maximum time we allow idle detector to be blocked before worrying, in milliseconds -const int baseDelay = 1000; // minimum delay time used when backing off to allow idling, in microseconds -#endif - QEventDispatcherSymbian::QEventDispatcherSymbian(QObject *parent) : QAbstractEventDispatcher(parent), m_activeScheduler(0), @@ -713,15 +646,11 @@ QEventDispatcherSymbian::QEventDispatcherSymbian(QObject *parent) m_iterationCount(0), m_noSocketEvents(false) { -#ifdef QT_SYMBIAN_PRIORITY_DROP - m_delay = baseDelay; - m_avgEventTime = 0; - idleDetectorThread(); -#endif } QEventDispatcherSymbian::~QEventDispatcherSymbian() { + m_processHandle.Close(); } void QEventDispatcherSymbian::startingUp() @@ -782,7 +711,23 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla m_interrupt = false; #ifdef QT_SYMBIAN_PRIORITY_DROP - QTime eventTimer; + /* + * This QTime variable is used to measure the time it takes to finish + * the event loop. If we take too long in the loop, other processes + * may be starved and killed. After the first event has completed, we + * take the current time, and if the remaining events take longer than + * a preset time, we temporarily lower the priority to force a context + * switch. For applications that do not take unecessarily long in the + * event loop, the priority will not be altered. + */ + QTime time; + enum { + FirstRun, + SubsequentRun, + TimeStarted + } timeState = FirstRun; + + TProcessPriority priority; #endif while (1) { @@ -798,18 +743,10 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla } #ifdef QT_SYMBIAN_PRIORITY_DROP - if (idleDetectorThread()->hasRun()) { - if (m_delay > baseDelay) - m_delay -= baseDelay; - m_lastIdleRequestTimer.start(); - idleDetectorThread()->kick(); - } else if (m_lastIdleRequestTimer.elapsed() > maxBusyTime) { - User::AfterHighRes(m_delay); - // allow delay to be up to 1/4 of execution time - if (!idleDetectorThread()->hasRun() && m_delay*3 < m_avgEventTime) - m_delay += baseDelay; + if (timeState == SubsequentRun) { + time.start(); + timeState = TimeStarted; } - eventTimer.start(); #endif TInt error; @@ -819,12 +756,6 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla CActiveScheduler::Current()->Error(error); } -#ifdef QT_SYMBIAN_PRIORITY_DROP - int eventDur = eventTimer.elapsed()*1000; - // average is calcualted as a 5% decaying exponential average - m_avgEventTime = (m_avgEventTime * 95 + eventDur * 5) / 100; -#endif - if (!handledSymbianEvent) { qFatal("QEventDispatcherSymbian::processEvents(): Caught Symbian stray signal"); } @@ -833,6 +764,20 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla break; } block = false; +#ifdef QT_SYMBIAN_PRIORITY_DROP + if (timeState == TimeStarted && time.elapsed() > 100) { + priority = m_processHandle.Priority(); + m_processHandle.SetPriority(EPriorityBackground); + time.start(); + // Slight chance of race condition in the next lines, but nothing fatal + // will happen, just wrong priority. + if (m_processHandle.Priority() == EPriorityBackground) { + m_processHandle.SetPriority(priority); + } + } + if (timeState == FirstRun) + timeState = SubsequentRun; +#endif }; emit awake(); diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h index 8a9c9a0..1ab31cc 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian_p.h +++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h @@ -62,7 +62,6 @@ #include #include #include -#include #include @@ -280,9 +279,7 @@ private: QList m_deferredActiveObjects; - int m_delay; - int m_avgEventTime; - QTime m_lastIdleRequestTimer; + RProcess m_processHandle; }; #ifdef QT_DEBUG -- cgit v0.12 From 89c588ab206e5358544d9402fb3b44aeddf634dc Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Thu, 29 Apr 2010 11:41:26 +0200 Subject: Map Symbian touch points to the screen's coordinate system. The 'iPosition' that we receive from the TAdvancedPointerEvent is relative to the origin of the window that received the event, not the screen so it needs to mapped to be correct. Reviewed-by: Bradley T. Hughes --- src/gui/kernel/qapplication_s60.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 7087b47..2bd29fc 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -440,7 +440,7 @@ void QSymbianControl::translateAdvancedPointerEvent(const TAdvancedPointerEvent state |= Qt::TouchPointPrimary; touchPoint.setState(state); - QPointF screenPos = QPointF(event->iPosition.iX, event->iPosition.iY); + QPointF screenPos = qwidget->mapToGlobal(QPoint(event->iPosition.iX, event->iPosition.iY)); touchPoint.setScreenPos(screenPos); touchPoint.setNormalizedPos(QPointF(screenPos.x() / screenGeometry.width(), screenPos.y() / screenGeometry.height())); -- cgit v0.12 From 5997edf9ee427850746c41d1a3df4725b9009408 Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Thu, 29 Apr 2010 16:57:11 +0300 Subject: Support 'Text' mode in Symbian specific input methods The default values for QCoeFepInputContext are set so that lower ('ab') and upper cases ('AB') are supported. Without any input method hints, input mode widgets cannot get into text mode ('Ab') at all. Changed the implementation so that default value is 'Text' like in native S60 devices. Task-number: QTBUG-10006 Reviewed-by: Janne Koskinen --- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index b42e0ab..610ac3c 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -87,7 +87,7 @@ QCoeFepInputContext::QCoeFepInputContext(QObject *parent) m_fepState->SetDefaultInputMode( EAknEditorTextInputMode ); m_fepState->SetPermittedInputModes( EAknEditorAllInputModes ); m_fepState->SetDefaultCase( EAknEditorLowerCase ); - m_fepState->SetPermittedCases( EAknEditorLowerCase|EAknEditorUpperCase ); + m_fepState->SetPermittedCases( EAknEditorAllCaseModes ); m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG); m_fepState->SetNumericKeymap( EAknEditorStandardNumberModeKeymap ); } -- cgit v0.12 From 2665a992c56b902d098818e192e11164d9bf4e01 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 30 Apr 2010 11:14:36 +0200 Subject: Removing unused code. MOpenFontShapingExtension was not used. Cleaning up and reducing delta between branches Reviewed-by: Aleksandar Sasha Babic --- src/gui/text/qfontengine_s60.cpp | 25 +------------------------ src/gui/text/qfontengine_s60_p.h | 4 +--- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp index a9960e4..93f02ff 100644 --- a/src/gui/text/qfontengine_s60.cpp +++ b/src/gui/text/qfontengine_s60.cpp @@ -59,13 +59,10 @@ QSymbianTypeFaceExtras::QSymbianTypeFaceExtras(CFont* fontOwner, COpenFont *font , m_symbolCMap(false) , m_fontOwner(fontOwner) { - TAny *shapingExtension = NULL; - m_font->ExtendedInterface(KUidOpenFontShapingExtension, shapingExtension); - m_shapingExtension = static_cast(shapingExtension); TAny *trueTypeExtension = NULL; m_font->ExtendedInterface(KUidOpenFontTrueTypeExtension, trueTypeExtension); m_trueTypeExtension = static_cast(trueTypeExtension); - Q_ASSERT(m_shapingExtension && m_trueTypeExtension); + Q_ASSERT(m_trueTypeExtension); } QByteArray QSymbianTypeFaceExtras::getSfntTable(uint tag) const @@ -114,26 +111,6 @@ const unsigned char *QSymbianTypeFaceExtras::cmap() const return m_cmap; } -QPainterPath QSymbianTypeFaceExtras::glyphOutline(glyph_t glyph) const -{ - QPainterPath result; - QPolygonF polygon; - TInt glyphIndex = glyph; - TInt pointNumber = 0; - TInt x, y; - while (m_shapingExtension->GlyphPointInFontUnits(glyphIndex, pointNumber++, x, y)) { - const QPointF point(qreal(x) / 0xffff, qreal(y) / 0xffff); - if (polygon.contains(point)) { - result.addPolygon(polygon); - result.closeSubpath(); - polygon.clear(); - } else { - polygon.append(point); - } - } - return result; -} - CFont *QSymbianTypeFaceExtras::fontOwner() const { return m_fontOwner; diff --git a/src/gui/text/qfontengine_s60_p.h b/src/gui/text/qfontengine_s60_p.h index b6b117f..6883730 100644 --- a/src/gui/text/qfontengine_s60_p.h +++ b/src/gui/text/qfontengine_s60_p.h @@ -62,7 +62,7 @@ class CFont; QT_BEGIN_NAMESPACE -// ..gives us access to truetype tables, UTF-16<->GlyphID mapping, and glyph outlines +// ..gives us access to truetype tables class QSymbianTypeFaceExtras { public: @@ -71,12 +71,10 @@ public: QByteArray getSfntTable(uint tag) const; bool getSfntTableData(uint tag, uchar *buffer, uint *length) const; const unsigned char *cmap() const; - QPainterPath glyphOutline(glyph_t glyph) const; CFont *fontOwner() const; private: COpenFont *m_font; - const MOpenFontShapingExtension *m_shapingExtension; mutable MOpenFontTrueTypeExtension *m_trueTypeExtension; mutable const unsigned char *m_cmap; mutable bool m_symbolCMap; -- cgit v0.12 From 25ed3acf3daa1141e7ae5ac65f6456b9af9b451a Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Fri, 30 Apr 2010 12:32:38 +0100 Subject: Fixed incorrect runtime platform version check in Phonon MMF backend In S60 3.2, CMdaAudioPlayerUtility::SetVolume(TInt) was changed from having a void return type to returning TInt. The code in the Phonon MMF backend which calls this function uses a runtime platform version check to ensure that only on S60 3.2 and above is the return value from SetVolume treated as valid. This check was previously testing for the wrong platform version (5.0 rather than 3.2). Reviewed-by: Shane Kearns --- src/3rdparty/phonon/mmf/audioplayer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index 77a0964..f49e898 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -99,7 +99,7 @@ int MMF::AudioPlayer::setDeviceVolume(int mmfVolume) * stack by doing a runtime check of the SDK version. */ #if !defined(__SERIES60_31__) const int err = m_player->SetVolume(mmfVolume); - if (QSysInfo::s60Version() >= QSysInfo::SV_S60_5_0) + if (QSysInfo::s60Version() >= QSysInfo::SV_S60_3_2) return err; else return KErrNone; -- cgit v0.12 From accde4c624fc0fc7a3942925922fc981888c4ac4 Mon Sep 17 00:00:00 2001 From: mread Date: Fri, 30 Apr 2010 14:27:08 +0100 Subject: Event dispatcher slow down using delays rather than thread priority The Symbian event dispatcher has a mechanism to slow down the Qt app to prevent viewsrv crashes and keep the device responsive. This was implemented using a thread priority drop. But that has some bad side effects, such as app and system performance instability. This new implementation of a slow down mechanism uses a separate low priority thread to test when the system is getting too busy. Adaptive millisecond waits are used to slow the app down just enough to let the low prioirity thread to run. In practice this avoids the performance instability of the previous method, and results in much better system stability where the system stays more responsive with fewer viewsrv panics when heavy Qt apps are running. The slow down code kicks in after 2 seconds of busy time. The delays grow 1ms at a time to a maximum of 1/4 of average event run time. This updated version of the fix used an RSemaphore rather than RFastlock, which should not have been used for cross-thread signalling. Task-number: QTBUG-9489 Reviewed-by: Shane Kearns --- src/corelib/kernel/qeventdispatcher_symbian.cpp | 127 +++++++++++++++++------- src/corelib/kernel/qeventdispatcher_symbian_p.h | 5 +- 2 files changed, 95 insertions(+), 37 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index 8c96057..c85d1be 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -43,7 +43,6 @@ #include #include #include -#include #include #include @@ -636,6 +635,74 @@ void QSocketActiveObject::deleteLater() } } +#ifdef QT_SYMBIAN_PRIORITY_DROP +class QIdleDetectorThread +{ +public: + QIdleDetectorThread() + : m_state(STATE_RUN), m_stop(false) + { + qt_symbian_throwIfError(m_lock.CreateLocal(0)); + TInt err = m_idleDetectorThread.Create(KNullDesC(), &idleDetectorThreadFunc, 1024, NULL, this); + if (err != KErrNone) + m_lock.Close(); + qt_symbian_throwIfError(err); + m_idleDetectorThread.SetPriority(EPriorityAbsoluteBackgroundNormal); + m_idleDetectorThread.Resume(); + } + + ~QIdleDetectorThread() + { + // close down the idle thread because if corelib is loaded temporarily, this would leak threads into the host process + m_stop = true; + m_lock.Signal(); + m_idleDetectorThread.SetPriority(EPriorityNormal); + TRequestStatus s; + m_idleDetectorThread.Logon(s); + User::WaitForRequest(s); + m_idleDetectorThread.Close(); + m_lock.Close(); + } + + void kick() + { + m_state = STATE_KICKED; + m_lock.Signal(); + } + + bool hasRun() + { + return m_state == STATE_RUN; + } + +private: + static TInt idleDetectorThreadFunc(TAny* self) + { + static_cast(self)->IdleLoop(); + return KErrNone; + } + + void IdleLoop() + { + while (!m_stop) { + m_lock.Wait(); + m_state = STATE_RUN; + } + } + +private: + enum IdleStates {STATE_KICKED, STATE_RUN} m_state; + bool m_stop; + RThread m_idleDetectorThread; + RSemaphore m_lock; +}; + +Q_GLOBAL_STATIC(QIdleDetectorThread, idleDetectorThread); + +const int maxBusyTime = 2000; // maximum time we allow idle detector to be blocked before worrying, in milliseconds +const int baseDelay = 1000; // minimum delay time used when backing off to allow idling, in microseconds +#endif + QEventDispatcherSymbian::QEventDispatcherSymbian(QObject *parent) : QAbstractEventDispatcher(parent), m_activeScheduler(0), @@ -646,11 +713,15 @@ QEventDispatcherSymbian::QEventDispatcherSymbian(QObject *parent) m_iterationCount(0), m_noSocketEvents(false) { +#ifdef QT_SYMBIAN_PRIORITY_DROP + m_delay = baseDelay; + m_avgEventTime = 0; + idleDetectorThread(); +#endif } QEventDispatcherSymbian::~QEventDispatcherSymbian() { - m_processHandle.Close(); } void QEventDispatcherSymbian::startingUp() @@ -711,23 +782,7 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla m_interrupt = false; #ifdef QT_SYMBIAN_PRIORITY_DROP - /* - * This QTime variable is used to measure the time it takes to finish - * the event loop. If we take too long in the loop, other processes - * may be starved and killed. After the first event has completed, we - * take the current time, and if the remaining events take longer than - * a preset time, we temporarily lower the priority to force a context - * switch. For applications that do not take unecessarily long in the - * event loop, the priority will not be altered. - */ - QTime time; - enum { - FirstRun, - SubsequentRun, - TimeStarted - } timeState = FirstRun; - - TProcessPriority priority; + QTime eventTimer; #endif while (1) { @@ -743,10 +798,18 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla } #ifdef QT_SYMBIAN_PRIORITY_DROP - if (timeState == SubsequentRun) { - time.start(); - timeState = TimeStarted; + if (idleDetectorThread()->hasRun()) { + if (m_delay > baseDelay) + m_delay -= baseDelay; + m_lastIdleRequestTimer.start(); + idleDetectorThread()->kick(); + } else if (m_lastIdleRequestTimer.elapsed() > maxBusyTime) { + User::AfterHighRes(m_delay); + // allow delay to be up to 1/4 of execution time + if (!idleDetectorThread()->hasRun() && m_delay*3 < m_avgEventTime) + m_delay += baseDelay; } + eventTimer.start(); #endif TInt error; @@ -756,6 +819,12 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla CActiveScheduler::Current()->Error(error); } +#ifdef QT_SYMBIAN_PRIORITY_DROP + int eventDur = eventTimer.elapsed()*1000; + // average is calcualted as a 5% decaying exponential average + m_avgEventTime = (m_avgEventTime * 95 + eventDur * 5) / 100; +#endif + if (!handledSymbianEvent) { qFatal("QEventDispatcherSymbian::processEvents(): Caught Symbian stray signal"); } @@ -764,20 +833,6 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla break; } block = false; -#ifdef QT_SYMBIAN_PRIORITY_DROP - if (timeState == TimeStarted && time.elapsed() > 100) { - priority = m_processHandle.Priority(); - m_processHandle.SetPriority(EPriorityBackground); - time.start(); - // Slight chance of race condition in the next lines, but nothing fatal - // will happen, just wrong priority. - if (m_processHandle.Priority() == EPriorityBackground) { - m_processHandle.SetPriority(priority); - } - } - if (timeState == FirstRun) - timeState = SubsequentRun; -#endif }; emit awake(); diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h index 1ab31cc..8a9c9a0 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian_p.h +++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h @@ -62,6 +62,7 @@ #include #include #include +#include #include @@ -279,7 +280,9 @@ private: QList m_deferredActiveObjects; - RProcess m_processHandle; + int m_delay; + int m_avgEventTime; + QTime m_lastIdleRequestTimer; }; #ifdef QT_DEBUG -- cgit v0.12 From 2559aea71b0edd8062179d8051c10a515e55777f Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 30 Apr 2010 18:15:56 +0200 Subject: Fix bold text rendering of Thai and Vietnamese on Symbian The Symbian Qt font database made the wrong assumption that a font face name maps one to one to a font. That led to a mismaptch between actual font face variants (bold) versus the retrieved font tables. S60, usually comes with two 'Series 60 Sans' font files where one is semi bold. The rasterizer plugin merges both fonts to one and returns the semi bold font if a bold font is requested, otherwise it returns the normal font. Both font files have slight differences in the cmap. Qt's font implementation always retrieved the font tables for the normal font even if it drew the bold font. That led to wrong glyphs in some languages (Thai, Vietnamese), thanks to the cmap differences. This fix makes sure that when retrieving the font tables, bold and italic are considered. It avoids innecessary double allocations of MOpenFontTrueTypeExtension instances. Also the ChunkHeap size of m_heap does now depend on the number of loaded font files. Task-number: QTBUG-6812 Reviewed-by: Aleksandar Sasha Babic --- src/gui/text/qfontdatabase_s60.cpp | 57 ++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp index 376ad43..4171e40 100644 --- a/src/gui/text/qfontdatabase_s60.cpp +++ b/src/gui/text/qfontdatabase_s60.cpp @@ -98,18 +98,26 @@ public: QSymbianFontDatabaseExtrasImplementation(); ~QSymbianFontDatabaseExtrasImplementation(); - const QSymbianTypeFaceExtras *extras(const QString &typeface) const; + const QSymbianTypeFaceExtras *extras(const QString &typeface, bool bold, bool italic) const; private: RHeap* m_heap; CFontStore *m_store; COpenFontRasterizer *m_rasterizer; - mutable QHash m_extras; + mutable QList m_extras; + mutable QHash m_extrasHash; }; QSymbianFontDatabaseExtrasImplementation::QSymbianFontDatabaseExtrasImplementation() { - m_heap = User::ChunkHeap(NULL, 0x1000, 0x100000); + QStringList filters; + filters.append(QLatin1String("*.ttf")); + filters.append(QLatin1String("*.ccc")); + const QFileInfoList fontFiles = alternativeFilePaths(QLatin1String("resource\\Fonts"), filters); + + const TInt heapMinLength = 0x1000; + const TInt heapMaxLength = qMax(0x20000 * fontFiles.count(), heapMinLength); + m_heap = User::ChunkHeap(NULL, heapMinLength, heapMaxLength); QT_TRAP_THROWING( m_store = CFontStore::NewL(m_heap); m_rasterizer = COpenFontRasterizer::NewL(TUid::Uid(0x101F7F5E)); @@ -117,19 +125,16 @@ QSymbianFontDatabaseExtrasImplementation::QSymbianFontDatabaseExtrasImplementati m_store->InstallRasterizerL(m_rasterizer); CleanupStack::Pop(m_rasterizer);); - QStringList filters; - filters.append(QString::fromLatin1("*.ttf")); - filters.append(QString::fromLatin1("*.ccc")); - const QFileInfoList fontFiles = alternativeFilePaths(QString::fromLatin1("resource\\Fonts"), filters); foreach (const QFileInfo &fontFileInfo, fontFiles) { const QString fontFile = QDir::toNativeSeparators(fontFileInfo.absoluteFilePath()); TPtrC fontFilePtr(qt_QString2TPtrC(fontFile)); QT_TRAP_THROWING(m_store->AddFileL(fontFilePtr)); } } + QSymbianFontDatabaseExtrasImplementation::~QSymbianFontDatabaseExtrasImplementation() { - typedef QHash::iterator iterator; + typedef QList::iterator iterator; for (iterator p = m_extras.begin(); p != m_extras.end(); ++p) { m_store->ReleaseFont((*p)->fontOwner()); delete *p; @@ -156,13 +161,18 @@ COpenFont* OpenFontFromBitmapFont(const CBitmapFont* aBitmapFont) } #endif // FNTSTORE_H_INLINES_SUPPORT_FMM -const QSymbianTypeFaceExtras *QSymbianFontDatabaseExtrasImplementation::extras(const QString &typeface) const +const QSymbianTypeFaceExtras *QSymbianFontDatabaseExtrasImplementation::extras(const QString &typeface, + bool bold, bool italic) const { - if (!m_extras.contains(typeface)) { + const QString searchKey = typeface + QString::number(int(bold)) + QString::number(int(italic)); + if (!m_extrasHash.contains(searchKey)) { CFont* font = NULL; - TFontSpec spec(qt_QString2TPtrC(typeface), 1); - spec.iHeight = 1; - const TInt err = m_store->GetNearestFontToDesignHeightInPixels(font, spec); + TFontSpec searchSpec(qt_QString2TPtrC(typeface), 1); + if (bold) + searchSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); + if (italic) + searchSpec.iFontStyle.SetPosture(EPostureItalic); + const TInt err = m_store->GetNearestFontToDesignHeightInPixels(font, searchSpec); Q_ASSERT(err == KErrNone && font); const CBitmapFont *bitmapFont = static_cast(font); COpenFont *openFont = @@ -171,9 +181,20 @@ const QSymbianTypeFaceExtras *QSymbianFontDatabaseExtrasImplementation::extras(c #else OpenFontFromBitmapFont(bitmapFont); #endif // FNTSTORE_H_INLINES_SUPPORT_FMM - m_extras.insert(typeface, new QSymbianTypeFaceExtras(font, openFont)); + const TOpenFontFaceAttrib* const attrib = openFont->FaceAttrib(); + const QString foundKey = + QString((const QChar*)attrib->FullName().Ptr(), attrib->FullName().Length()); + if (!m_extrasHash.contains(foundKey)) { + QSymbianTypeFaceExtras *extras = new QSymbianTypeFaceExtras(font, openFont); + m_extras.append(extras); + m_extrasHash.insert(searchKey, extras); + m_extrasHash.insert(foundKey, extras); + } else { + m_store->ReleaseFont(font); + m_extrasHash.insert(searchKey, m_extrasHash.value(foundKey)); + } } - return m_extras.value(typeface); + return m_extrasHash.value(searchKey); } #else class QFontEngineFTS60 : public QFontEngineFT @@ -273,7 +294,8 @@ static void initializeDb() style->smoothScalable = typefaceSupport.iIsScalable; style->pixelSize(0, true); - const QSymbianTypeFaceExtras *typeFaceExtras = dbExtras->extras(familyName); + const QSymbianTypeFaceExtras *typeFaceExtras = + dbExtras->extras(familyName, faceAttrib.IsBold(), faceAttrib.IsItalic()); const QByteArray os2Table = typeFaceExtras->getSfntTable(MAKE_TAG('O', 'S', '/', '2')); const unsigned char* data = reinterpret_cast(os2Table.constData()); const unsigned char* ulUnicodeRange = data + 42; @@ -396,7 +418,8 @@ QFontEngine *QFontDatabase::findFont(int script, const QFontPrivate *, const QFo #if defined(QT_NO_FREETYPE) const QSymbianFontDatabaseExtrasImplementation *dbExtras = static_cast(db->symbianExtras); - const QSymbianTypeFaceExtras *typeFaceExtras = dbExtras->extras(fontFamily); + const QSymbianTypeFaceExtras *typeFaceExtras = + dbExtras->extras(fontFamily, request.weight > QFont::Normal, request.style != QFont::StyleNormal); fe = new QFontEngineS60(request, typeFaceExtras); #else QFontEngine::FaceId faceId; -- cgit v0.12