diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-30 17:33:46 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-04-30 17:33:46 (GMT) |
commit | 6ee87fa7ccd139e6e5f516f0f6b9be707a5c3a5e (patch) | |
tree | 9c98139b44be776aecb2f2015363660a26a512ca /src | |
parent | 3e6a12e90d05d24bca68128d60215c207a416ef6 (diff) | |
parent | 872fd4dea1cb27b454617286508c4855c96fae95 (diff) | |
download | Qt-6ee87fa7ccd139e6e5f516f0f6b9be707a5c3a5e.zip Qt-6ee87fa7ccd139e6e5f516f0f6b9be707a5c3a5e.tar.gz Qt-6ee87fa7ccd139e6e5f516f0f6b9be707a5c3a5e.tar.bz2 |
Merge branch 'qt-4.7-from-4.6' of scm.dev.nokia.troll.no:qt/qt-integration into 4.7-integration
* 'qt-4.7-from-4.6' of scm.dev.nokia.troll.no:qt/qt-integration: (105 commits)
Testlib XML flush: use benchmarkMetricName (identifier) overall instead of benchmarkMetricUnit (human text)
Update the testlib XML baselines with the unit names from QTestLib
Renaming a few unexported, private symbols
tst_selftest: parse benchlib results in XML format too
tst_selftests: replace a line number with __LINE__ in XML too
Removed fullscreen responsiveness of softkeys
tst_selftest: use @INSERT_QT_VERSION_HERE@ to indicate the Qt version.
fix crash in QXmlStreamReader
Fixed a QFontEngine leak for QFont objects used in threads.
The cmd line arguments have not been delegated properly.
Apply Rhys's fix to qpaintengine_vg.cpp to make it compile
Fixed QGLWidget::grabFrameBuffer() to honor the 'withAlpha' value.
Adjusted layout of audiodevice example to use scrollbar.
win32 backend for low-level audio fixes
QXmlSchema internals: fix crash with anonymous types
QNAM HTTP: Fix invoking a method when being destructed right now (2)
QNAM: Use a reference in appendDownstreamData
QNAM HTTP: Divide QNetworkReplyImplPrivate::appendDownstreamData
QNAM HTTP: Avoid one copy
Re-apply change 5107946e97cbc480a9329565c29b7384c8ba0860 by Iain
...
Diffstat (limited to 'src')
51 files changed, 638 insertions, 389 deletions
diff --git a/src/corelib/codecs/qiconvcodec.cpp b/src/corelib/codecs/qiconvcodec.cpp index 0fcdf96..44a0a01 100644 --- a/src/corelib/codecs/qiconvcodec.cpp +++ b/src/corelib/codecs/qiconvcodec.cpp @@ -168,7 +168,7 @@ Q_GLOBAL_STATIC(QThreadStorage<QIconvCodec::IconvState *>, toUnicodeState) QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState *convState) const { if (utf16Codec == reinterpret_cast<QTextCodec *>(~0)) - return QString::fromAscii(chars, len); + return QString::fromLatin1(chars, len); int invalidCount = 0; int remainingCount = 0; @@ -207,9 +207,9 @@ QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState static int reported = 0; if (!reported++) { fprintf(stderr, - "QIconvCodec::convertToUnicode: using ASCII for conversion, iconv_open failed\n"); + "QIconvCodec::convertToUnicode: using Latin-1 for conversion, iconv_open failed\n"); } - return QString::fromAscii(chars, len); + return QString::fromLatin1(chars, len); } *pstate = new IconvState(cd); @@ -273,14 +273,14 @@ QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState // some other error // note, cannot use qWarning() since we are implementing the codecForLocale :) - perror("QIconvCodec::convertToUnicode: using ASCII for conversion, iconv failed"); + perror("QIconvCodec::convertToUnicode: using Latin-1 for conversion, iconv failed"); if (!convState) { // reset state iconv(state->cd, 0, &inBytesLeft, 0, &outBytesLeft); } - return QString::fromAscii(chars, len); + return QString::fromLatin1(chars, len); } } while (inBytesLeft != 0); @@ -353,12 +353,12 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt state = new IconvState(QIconvCodec::createIconv_t(0, UTF16)); if (state->cd == reinterpret_cast<iconv_t>(-1)) { if (!setByteOrder(state->cd)) { - perror("QIconvCodec::convertFromUnicode: using ASCII for conversion, iconv failed for BOM"); + perror("QIconvCodec::convertFromUnicode: using Latin-1 for conversion, iconv failed for BOM"); iconv_close(state->cd); state->cd = reinterpret_cast<iconv_t>(-1); - return QString(uc, len).toAscii(); + return QString(uc, len).toLatin1(); } } } @@ -366,9 +366,9 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt static int reported = 0; if (!reported++) { fprintf(stderr, - "QIconvCodec::convertFromUnicode: using ASCII for conversion, iconv_open failed\n"); + "QIconvCodec::convertFromUnicode: using Latin-1 for conversion, iconv_open failed\n"); } - return QString(uc, len).toAscii(); + return QString(uc, len).toLatin1(); } size_t outBytesLeft = len; @@ -425,12 +425,12 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt default: { // note, cannot use qWarning() since we are implementing the codecForLocale :) - perror("QIconvCodec::convertFromUnicode: using ASCII for conversion, iconv failed"); + perror("QIconvCodec::convertFromUnicode: using Latin-1 for conversion, iconv failed"); // reset to initial state iconv(state->cd, 0, &inBytesLeft, 0, &outBytesLeft); - return QString(uc, len).toAscii(); + return QString(uc, len).toLatin1(); } } } diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index dfa2c17..373c0b4 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2079,7 +2079,28 @@ static void mac_default_handler(const char *msg) } #endif // Q_CC_MWERKS && Q_OS_MACX - +#if !defined(Q_OS_WIN) && !defined(QT_NO_THREAD) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) && \ + defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L +namespace { + // There are two incompatible versions of strerror_r: + // a) the XSI/POSIX.1 version, which returns an int, + // indicating success or not + // b) the GNU version, which returns a char*, which may or may not + // be the beginning of the buffer we used + // The GNU libc manpage for strerror_r says you should use the the XSI + // version in portable code. However, it's impossible to do that if + // _GNU_SOURCE is defined so we use C++ overloading to decide what to do + // depending on the return type + static inline QString fromstrerror_helper(int, const QByteArray &buf) + { + return QString::fromLocal8Bit(buf); + } + static inline QString fromstrerror_helper(const char *str, const QByteArray &) + { + return QString::fromLocal8Bit(str); + } +} +#endif QString qt_error_string(int errorCode) { @@ -2122,12 +2143,9 @@ QString qt_error_string(int errorCode) if (ret.isEmpty() && errorCode == ERROR_MOD_NOT_FOUND) ret = QString::fromLatin1("The specified module could not be found."); - #elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) - QByteArray buf(1024, '\0'); - strerror_r(errorCode, buf.data(), buf.size()); - ret = QString::fromLocal8Bit(buf.constData()); + ret = fromstrerror_helper(strerror_r(errorCode, buf.data(), buf.size()), buf); #else ret = QString::fromLocal8Bit(strerror(errorCode)); #endif diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp index f2cef4e1..bb11d6b 100644 --- a/src/corelib/io/qiodevice.cpp +++ b/src/corelib/io/qiodevice.cpp @@ -755,7 +755,6 @@ qint64 QIODevice::bytesToWrite() const qint64 QIODevice::read(char *data, qint64 maxSize) { Q_D(QIODevice); - CHECK_READABLE(read, qint64(-1)); #if defined QIODEVICE_DEBUG printf("%p QIODevice::read(%p, %d), d->pos = %d, d->buffer.size() = %d\n", @@ -786,13 +785,13 @@ qint64 QIODevice::read(char *data, qint64 maxSize) do { // Try reading from the buffer. int lastReadChunkSize = d->buffer.read(data, maxSize); - *d->pPos += lastReadChunkSize; - readSoFar += lastReadChunkSize; - // fast exit when satisfied by buffer - if (lastReadChunkSize == maxSize && !(d->openMode & Text)) - return readSoFar; - if (lastReadChunkSize > 0) { + *d->pPos += lastReadChunkSize; + readSoFar += lastReadChunkSize; + // fast exit when satisfied by buffer + if (lastReadChunkSize == maxSize && !(d->openMode & Text)) + return readSoFar; + data += lastReadChunkSize; maxSize -= lastReadChunkSize; #if defined QIODEVICE_DEBUG diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp index 3b86e89..4566ec0 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian.cpp +++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp @@ -43,7 +43,6 @@ #include <private/qthread_p.h> #include <qcoreapplication.h> #include <private/qcoreapplication_p.h> -#include <qdatetime.h> #include <unistd.h> #include <errno.h> @@ -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()); + 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<QIdleDetectorThread*>(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_selectThread(0), @@ -647,11 +714,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() @@ -720,23 +791,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) { @@ -752,10 +807,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; @@ -765,6 +828,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"); } @@ -773,20 +842,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 5281199..05758ca 100644 --- a/src/corelib/kernel/qeventdispatcher_symbian_p.h +++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h @@ -62,6 +62,7 @@ #include <qmutex.h> #include <qwaitcondition.h> #include <qsocketnotifier.h> +#include <qdatetime.h> #include <e32base.h> @@ -280,7 +281,9 @@ private: QList<QActiveObject *> m_deferredActiveObjects; - RProcess m_processHandle; + int m_delay; + int m_avgEventTime; + QTime m_lastIdleRequestTimer; }; #ifdef QT_DEBUG diff --git a/src/corelib/tools/qbytedata_p.h b/src/corelib/tools/qbytedata_p.h index c48bb33..08249e0 100644 --- a/src/corelib/tools/qbytedata_p.h +++ b/src/corelib/tools/qbytedata_p.h @@ -84,7 +84,7 @@ public: } - inline void append(QByteArray& bd) + inline void append(const QByteArray& bd) { if (bd.isEmpty()) return; diff --git a/src/corelib/xml/qxmlstream.g b/src/corelib/xml/qxmlstream.g index 1b882e0..e91408f 100644 --- a/src/corelib/xml/qxmlstream.g +++ b/src/corelib/xml/qxmlstream.g @@ -748,7 +748,7 @@ bool QXmlStreamReaderPrivate::parse() state_stack[tos] = 0; return true; } else if (act > 0) { - if (++tos == stack_size) + if (++tos == stack_size-1) reallocateStack(); Value &val = sym_stack[tos]; diff --git a/src/corelib/xml/qxmlstream_p.h b/src/corelib/xml/qxmlstream_p.h index ac421cf..f6ab3a1 100644 --- a/src/corelib/xml/qxmlstream_p.h +++ b/src/corelib/xml/qxmlstream_p.h @@ -61,7 +61,7 @@ class QXmlStreamReader_Table { public: - enum { + enum VariousConstants { EOF_SYMBOL = 0, AMPERSAND = 5, ANY = 41, @@ -1242,7 +1242,7 @@ bool QXmlStreamReaderPrivate::parse() state_stack[tos] = 0; return true; } else if (act > 0) { - if (++tos == stack_size) + if (++tos == stack_size-1) reallocateStack(); Value &val = sym_stack[tos]; diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 6b22607..569a329 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -845,6 +845,13 @@ inline bool QGraphicsItemPrivate::insertionOrder(QGraphicsItem *a, QGraphicsItem inline void QGraphicsItemPrivate::markParentDirty(bool updateBoundingRect) { QGraphicsItemPrivate *parentp = this; +#ifndef QT_NO_GRAPHICSEFFECT + if (updateBoundingRect && parentp->graphicsEffect && !parentp->inSetPosHelper) { + parentp->notifyInvalidated = 1; + static_cast<QGraphicsItemEffectSourcePrivate *>(parentp->graphicsEffect->d_func() + ->source->d_func())->invalidateCache(); + } +#endif while (parentp->parent) { parentp = parentp->parent->d_ptr.data(); parentp->dirtyChildren = 1; diff --git a/src/gui/graphicsview/qgraphicsview_p.h b/src/gui/graphicsview/qgraphicsview_p.h index 729837a..80e3ec1 100644 --- a/src/gui/graphicsview/qgraphicsview_p.h +++ b/src/gui/graphicsview/qgraphicsview_p.h @@ -183,8 +183,12 @@ public: else QCoreApplication::sendPostedEvents(viewport->window(), QEvent::UpdateRequest); #else - QCoreApplication::processEvents(QEventLoop::AllEvents | QEventLoop::ExcludeSocketNotifiers - | QEventLoop::ExcludeUserInputEvents); + // At this point either HIViewSetNeedsDisplay (Carbon) or setNeedsDisplay: YES (Cocoa) + // is called, which means there's a pending update request. We want to dispatch it + // now because otherwise graphics view updates would require two + // round-trips in the event loop before the item is painted. + extern void qt_mac_dispatchPendingUpdateRequests(QWidget *); + qt_mac_dispatchPendingUpdateRequests(viewport->window()); #endif } diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index c735d1f..5f7813b 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -73,6 +73,7 @@ # endif # include <private/qs60mainapplication_p.h> # include <centralrepository.h> +# include "qs60mainappui.h" #endif #include "private/qstylesheetstyle_p.h" @@ -539,6 +540,14 @@ void QSymbianControl::HandlePointerEvent(const TPointerEvent& pEvent) sendMouseEvent(receiver, type, globalPos, button, modifiers); } +#ifdef Q_WS_S60 +void QSymbianControl::HandleStatusPaneSizeChange() +{ + QS60MainAppUi *s60AppUi = static_cast<QS60MainAppUi *>(S60->appUi()); + s60AppUi->HandleStatusPaneSizeChange(); +} +#endif + void QSymbianControl::sendMouseEvent( QWidget *receiver, QEvent::Type type, @@ -982,15 +991,6 @@ void QSymbianControl::FocusChanged(TDrawNow /* aDrawNow */) const TBool isFullscreen = qwidget->windowState() & Qt::WindowFullScreen; const TBool cbaVisibilityHint = qwidget->windowFlags() & Qt::WindowSoftkeysVisibleHint; buttonGroup->MakeVisible(visible || (isFullscreen && cbaVisibilityHint)); - - // Responsiviness - CEikCba *cba = static_cast<CEikCba *>( buttonGroup->ButtonGroup() ); // downcast from MEikButtonGroup - TUint cbaFlags = cba->ButtonGroupFlags(); - if(qwidget->windowFlags() & Qt::WindowSoftkeysRespondHint) - cbaFlags |= EAknCBAFlagRespondWhenInvisible; - else - cbaFlags &= ~EAknCBAFlagRespondWhenInvisible; - cba->SetButtonGroupFlags(cbaFlags); } #endif } else if (QApplication::activeWindow() == qwidget->window()) { diff --git a/src/gui/kernel/qsoftkeymanager_s60.cpp b/src/gui/kernel/qsoftkeymanager_s60.cpp index e4990b1..6325d95 100644 --- a/src/gui/kernel/qsoftkeymanager_s60.cpp +++ b/src/gui/kernel/qsoftkeymanager_s60.cpp @@ -79,6 +79,8 @@ bool QSoftKeyManagerPrivateS60::skipCbaUpdate() // Note: Cannot use IsDisplayingMenuOrDialog since CBA update can be triggered before // menu/dialog CBA is actually displayed i.e. it is being costructed. CEikButtonGroupContainer *appUiCba = S60->buttonGroupContainer(); + if (!appUiCba) + return true; // CEikButtonGroupContainer::Current returns 0 if CBA is not visible at all CEikButtonGroupContainer *currentCba = CEikButtonGroupContainer::Current(); // Check if softkey need to be update even they are not visible diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index 024c1fc..8cef03c 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -1299,6 +1299,17 @@ CGContextRef qt_mac_graphicsContextFor(QWidget *widget) return context; } +void qt_mac_dispatchPendingUpdateRequests(QWidget *widget) +{ + if (!widget) + return; +#ifndef QT_MAC_USE_COCOA + HIViewRender(qt_mac_nativeview_for(widget)); +#else + [qt_mac_nativeview_for(widget) displayIfNeeded]; +#endif +} + CGFloat qt_mac_get_scalefactor() { #ifndef QT_MAC_USE_COCOA diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index a714221..58da302 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -155,7 +155,7 @@ class QLongTapTimer; class QSymbianControl : public CCoeControl, public QAbstractLongTapObserver #ifdef Q_WS_S60 -, public MAknFadedComponent +, public MAknFadedComponent, public MEikStatusPaneObserver #endif { public: @@ -183,6 +183,7 @@ public: #ifdef Q_WS_S60 void FadeBehindPopup(bool fade){ popupFader.FadeBehindPopup( this, this, fade); } + void HandleStatusPaneSizeChange(); protected: // from MAknFadedComponent TInt CountFadedComponents() {return 1;} diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index bfa7050..a0429d3 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -387,16 +387,7 @@ void QWidgetPrivate::create_sys(WId window, bool /* initializeWindow */, bool de | EPointerFilterMove | EPointerFilterDrag, 0); drawableWindow->EnableVisibilityChangeEvents(); - if (!isOpaque) { - RWindow *const window = static_cast<RWindow *>(drawableWindow); -#ifdef Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE - window->SetSurfaceTransparency(true); -#else - const TDisplayMode displayMode = static_cast<TDisplayMode>(window->SetRequiredDisplayMode(EColor16MA)); - if (window->SetTransparencyAlphaChannel() == KErrNone) - window->SetBackgroundColor(TRgb(255, 255, 255, 0)); -#endif - } + s60UpdateIsOpaque(); } q->setAttribute(Qt::WA_WState_Created); @@ -488,6 +479,47 @@ void QWidgetPrivate::show_sys() QSymbianControl *id = static_cast<QSymbianControl *>(q->internalWinId()); +#ifdef Q_WS_S60 + // Lazily initialize the S60 screen furniture when the first window is shown. + if (!QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes) + && !S60->buttonGroupContainer() && !S60->statusPane()) { + + bool isFullscreen = q->windowState() & Qt::WindowFullScreen; + bool cbaRequested = q->windowFlags() & Qt::WindowSoftkeysVisibleHint; + + // If the window is fullscreen and has not explicitly requested that the CBA be visible + // we delay the creation even more. + if ((!isFullscreen || cbaRequested) && !q->testAttribute(Qt::WA_DontShowOnScreen)) { + + // Create the status pane and CBA here + CEikAppUi *ui = static_cast<CEikAppUi *>(S60->appUi()); + MEikAppUiFactory *factory = CEikonEnv::Static()->AppUiFactory(); + TRAP_IGNORE(factory->ReadAppInfoResourceL(0, ui)); + if (S60->buttonGroupContainer()) + S60->buttonGroupContainer()->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS); + + if (S60->statusPane()) { + // Use QDesktopWidget as the status pane observer to proxy for the AppUi. + // Can't use AppUi directly because it privately inherits from MEikStatusPaneObserver. + QSymbianControl *desktopControl = static_cast<QSymbianControl *>(QApplication::desktop()->winId()); + S60->statusPane()->SetObserver(desktopControl); + + // Hide the status pane if fullscreen OR + // Fill client area if maximized OR + // Put window below status pane unless the window has an explicit position. + if (isFullscreen) { + S60->statusPane()->MakeVisible(false); + } else if (q->windowState() & Qt::WindowMaximized) { + TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect(); + id->SetExtent(r.iTl, r.Size()); + } else if (!q->testAttribute(Qt::WA_Moved)) { + id->SetPosition(static_cast<CEikAppUi*>(S60->appUi())->ClientRect().iTl); + } + } + } + } +#endif + id->MakeVisible(true); if(q->isWindow()) @@ -1063,6 +1095,9 @@ void QWidget::setWindowState(Qt::WindowStates newstate) return; if (isWindow()) { + createWinId(); + Q_ASSERT(testAttribute(Qt::WA_WState_Created)); + const bool wasResized = testAttribute(Qt::WA_Resized); const bool wasMoved = testAttribute(Qt::WA_Moved); @@ -1088,35 +1123,35 @@ void QWidget::setWindowState(Qt::WindowStates newstate) if (buttonGroup) { // Visibility buttonGroup->MakeVisible(visible || (isFullscreen && cbaRequested)); - - // Responsiviness - CEikCba *cba = static_cast<CEikCba *>( buttonGroup->ButtonGroup() ); // downcast from MEikButtonGroup - TUint cbaFlags = cba->ButtonGroupFlags(); - if(windowFlags() & Qt::WindowSoftkeysRespondHint) - cbaFlags |= EAknCBAFlagRespondWhenInvisible; - else - cbaFlags &= ~EAknCBAFlagRespondWhenInvisible; - cba->SetButtonGroupFlags(cbaFlags); } #endif // Q_WS_S60 - createWinId(); - Q_ASSERT(testAttribute(Qt::WA_WState_Created)); // Ensure the initial size is valid, since we store it as normalGeometry below. if (!wasResized && !isVisible()) adjustSize(); QTLWExtra *top = d->topData(); - const QRect normalGeometry = (top->normalGeometry.width() < 0) ? geometry() : top->normalGeometry; - + QRect normalGeometry = (top->normalGeometry.width() < 0) ? geometry() : top->normalGeometry; const bool cbaVisibilityHint = windowFlags() & Qt::WindowSoftkeysVisibleHint; - if (newstate & Qt::WindowFullScreen && !cbaVisibilityHint) - setGeometry(qApp->desktop()->screenGeometry(this)); - else if (newstate & Qt::WindowMaximized || ((newstate & Qt::WindowFullScreen) && cbaVisibilityHint)) - setGeometry(qApp->desktop()->availableGeometry(this)); - else + if (newstate & Qt::WindowFullScreen && !cbaVisibilityHint) { + window->SetExtentToWholeScreen(); + } else if (newstate & Qt::WindowMaximized || ((newstate & Qt::WindowFullScreen) && cbaVisibilityHint)) { + TRect maxExtent = qt_QRect2TRect(qApp->desktop()->availableGeometry(this)); + window->SetExtent(maxExtent.iTl, maxExtent.Size()); + } else { +#ifdef Q_WS_S60 + // With delayed creation of S60 app panes, the normalGeometry calculated above is not + // accurate because it did not consider the status pane. This means that when returning + // normal mode after showing the status pane, the geometry would overlap so we should + // move it if it never had an explicit position. + if (!wasMoved && statusPane && visible) { + TPoint tl = static_cast<CEikAppUi*>(S60->appUi())->ClientRect().iTl; + normalGeometry.setTopLeft(QPoint(tl.iX, tl.iY)); + } +#endif setGeometry(normalGeometry); + } //restore normal geometry top->normalGeometry = normalGeometry; diff --git a/src/gui/painting/qprintengine_ps.cpp b/src/gui/painting/qprintengine_ps.cpp index ac94de3..28e9a7a 100644 --- a/src/gui/painting/qprintengine_ps.cpp +++ b/src/gui/painting/qprintengine_ps.cpp @@ -485,7 +485,6 @@ void QPSPrintEnginePrivate::emitHeader(bool finished) QByteArray header; QPdf::ByteStream s(&header); - s << "%!PS-Adobe-1.0"; qreal scale = 72. / ((qreal) q->metric(QPaintDevice::PdmDpiY)); QRect pageRect = this->pageRect(); @@ -497,28 +496,32 @@ void QPSPrintEnginePrivate::emitHeader(bool finished) int width = pageRect.width(); int height = pageRect.height(); if (finished && pageCount == 1 && copies == 1 && - ((fullPage && qt_gen_epsf) || (outputFileName.endsWith(QLatin1String(".eps")))) - ) { + ((fullPage && qt_gen_epsf) || (outputFileName.endsWith(QLatin1String(".eps"))))) + { + // According to the EPSF 3.0 spec it is required that the PS + // version is PS-Adobe-3.0 + s << "%!PS-Adobe-3.0"; if (!boundingBox.isValid()) boundingBox.setRect(0, 0, width, height); if (orientation == QPrinter::Landscape) { if (!fullPage) boundingBox.translate(-mleft, -mtop); s << " EPSF-3.0\n%%BoundingBox: " - << (int)(printer->height() - boundingBox.bottom())*scale // llx - << (int)(printer->width() - boundingBox.right())*scale - 1 // lly - << (int)(printer->height() - boundingBox.top())*scale + 1 // urx - << (int)(printer->width() - boundingBox.left())*scale; // ury + << int((printer->height() - boundingBox.bottom())*scale) // llx + << int((printer->width() - boundingBox.right())*scale - 1) // lly + << int((printer->height() - boundingBox.top())*scale + 1) // urx + << int((printer->width() - boundingBox.left())*scale); // ury } else { if (!fullPage) boundingBox.translate(mleft, -mtop); s << " EPSF-3.0\n%%BoundingBox: " - << (int)(boundingBox.left())*scale - << (int)(printer->height() - boundingBox.bottom())*scale - 1 - << (int)(boundingBox.right())*scale + 1 - << (int)(printer->height() - boundingBox.top())*scale; + << int((boundingBox.left())*scale) + << int((printer->height() - boundingBox.bottom())*scale - 1) + << int((boundingBox.right())*scale + 1) + << int((printer->height() - boundingBox.top())*scale); } } else { + s << "%!PS-Adobe-1.0"; int w = width + (fullPage ? 0 : mleft + mright); int h = height + (fullPage ? 0 : mtop + mbottom); w = (int)(w*scale); diff --git a/src/gui/painting/qprintengine_win.cpp b/src/gui/painting/qprintengine_win.cpp index ea9dc5d..dd4de99 100644 --- a/src/gui/painting/qprintengine_win.cpp +++ b/src/gui/painting/qprintengine_win.cpp @@ -965,12 +965,13 @@ void QWin32PrintEnginePrivate::queryDefault() return; QStringList info = output.split(QLatin1Char(',')); - if (info.size() > 0) { + int infoSize = info.size(); + if (infoSize > 0) { if (name.isEmpty()) name = info.at(0); - if (program.isEmpty()) + if (program.isEmpty() && infoSize > 1) program = info.at(1); - if (port.isEmpty()) + if (port.isEmpty() && infoSize > 2) port = info.at(2); } } diff --git a/src/gui/s60framework/qs60mainappui.cpp b/src/gui/s60framework/qs60mainappui.cpp index 3b5b9d3..feffc9f 100644 --- a/src/gui/s60framework/qs60mainappui.cpp +++ b/src/gui/s60framework/qs60mainappui.cpp @@ -112,16 +112,10 @@ void QS60MainAppUi::ConstructL() // ENoAppResourceFile and ENonStandardResourceFile makes UI to work without // resource files in most SDKs. S60 3rd FP1 public seems to require resource file // even these flags are defined - TInt flags = CAknAppUi::EAknEnableSkin; - if (QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes)) { - flags |= CAknAppUi::ENoScreenFurniture | CAknAppUi::ENonStandardResourceFile; - } + TInt flags = CAknAppUi::EAknEnableSkin + | CAknAppUi::ENoScreenFurniture + | CAknAppUi::ENonStandardResourceFile; BaseConstructL(flags); - - if (!QApplication::testAttribute(Qt::AA_S60DontConstructApplicationPanes)) { - CEikButtonGroupContainer* nativeContainer = Cba(); - nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS); - } } /*! diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 7587343..90b8be3 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -92,10 +92,10 @@ static const qreal goldenRatio = 1.618; const layoutHeader QS60StylePrivate::m_layoutHeaders[] = { // *** generated layout data *** -{240,320,1,17,"QVGA Landscape"}, -{320,240,1,17,"QVGA Portrait"}, -{360,640,1,17,"NHD Landscape"}, -{640,360,1,17,"NHD Portrait"}, +{240,320,1,18,"QVGA Landscape"}, +{320,240,1,18,"QVGA Portrait"}, +{360,640,1,18,"NHD Landscape"}, +{640,360,1,18,"NHD Portrait"}, {352,800,1,12,"E90 Landscape"} // *** End of generated data *** }; @@ -104,11 +104,11 @@ const int QS60StylePrivate::m_numberOfLayouts = const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = { // *** generated pixel metrics *** -{5,0,-909,0,0,2,0,0,-1,7,12,19,13,13,6,200,-909,-909,-909,20,13,2,0,0,21,7,18,0,3,3,1,-909,-909,0,1,0,0,12,20,15,15,18,18,1,115,18,0,-909,-909,-909,-909,0,0,16,2,-909,0,0,-909,16,-909,-909,-909,-909,32,18,55,24,55,4,4,4,9,13,-909,5,51,11,5,0,3,3,6,8,3,3,-909,2,-909,-909,-909,-909,5,5,3,1, 106}, -{5,0,-909,0,0,1,0,0,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,8,27,0,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,3,3,5,10,15,-909,5,58,13,5,0,4,4,7,9,4,4,-909,2,-909,-909,-909,-909,6,6,3,1, 106}, -{7,0,-909,0,0,2,0,0,-1,25,69,28,19,19,9,258,-909,-909,-909,23,19,26,0,0,32,25,72,0,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,13,13,6,8,19,-909,7,74,19,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1, 135}, -{7,0,-909,0,0,2,0,0,-1,25,68,28,19,19,9,258,-909,-909,-909,31,19,6,0,0,32,25,60,0,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,96,35,96,12,12,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1, 135}, -{7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,7,32,0,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1, 106} +{5,0,-909,0,0,2,0,0,-1,7,12,19,13,13,6,200,-909,-909,-909,20,13,2,0,0,21,7,18,30,3,3,1,-909,-909,0,1,0,0,12,20,15,15,18,18,1,115,18,0,-909,-909,-909,-909,0,0,16,2,-909,0,0,-909,16,-909,-909,-909,-909,32,18,55,24,55,4,4,4,9,13,-909,5,51,11,5,0,3,3,6,8,3,3,-909,2,-909,-909,-909,-909,5,5,3,1, 106}, +{5,0,-909,0,0,1,0,0,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,8,27,28,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,3,3,5,10,15,-909,5,58,13,5,0,4,4,7,9,4,4,-909,2,-909,-909,-909,-909,6,6,3,1, 106}, +{7,0,-909,0,0,2,0,0,-1,25,69,28,19,19,9,258,-909,-909,-909,23,19,26,0,0,32,25,72,44,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,13,13,6,8,19,-909,7,74,19,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1, 135}, +{7,0,-909,0,0,2,0,0,-1,25,68,28,19,19,9,258,-909,-909,-909,31,19,6,0,0,32,25,60,52,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,96,35,96,12,12,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1, 135}, +{7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,7,32,30,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1, 106} // *** End of generated data *** }; @@ -651,6 +651,8 @@ void QS60StylePrivate::setFont(QWidget *widget) const fontCategory = QS60StyleEnums::FC_Title; } else if (qobject_cast<QMessageBox *>(widget)){ fontCategory = QS60StyleEnums::FC_Primary; + } else if (qobject_cast<QMenu *>(widget)){ + fontCategory = QS60StyleEnums::FC_Primary; } if (fontCategory != QS60StyleEnums::FC_Undefined) { const bool resolveFontSize = widget->testAttribute(Qt::WA_SetFont) @@ -1744,6 +1746,9 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, optionCheckBox.QStyleOptionMenuItem::operator=(*menuItem); optionCheckBox.rect.setWidth(pixelMetric(PM_IndicatorWidth)); optionCheckBox.rect.setHeight(pixelMetric(PM_IndicatorHeight)); + optionCheckBox.rect.moveCenter(QPoint( + optionCheckBox.rect.center().x(), + menuItem->rect.center().y())); const int moveByX = optionCheckBox.rect.width() + vSpacing; if (optionMenuItem.direction == Qt::LeftToRight) { textRect.translate(moveByX, 0); @@ -2424,6 +2429,10 @@ int QS60Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const if (metricValue == KNotFound) metricValue = QCommonStyle::pixelMetric(metric, option, widget); + // Menu scrollers should be set to zero height for combobox popups + if (metric == PM_MenuScrollerHeight && !qobject_cast<const QMenu *>(widget)) + metricValue = 0; + //if layout direction is mirrored, switch left and right border margins if (option && option->direction == Qt::RightToLeft) { if (metric == PM_LayoutLeftMargin) @@ -2483,7 +2492,14 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, sz.setHeight(naviPaneSize.height()); } break; + case CT_MenuItem: case CT_ItemViewItem: + if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) { + if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { + sz = QSize(); + break; + } + } sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); if (QS60StylePrivate::isTouchSupported()) //Make itemview easier to use in touch devices @@ -2564,6 +2580,9 @@ int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w case SH_Menu_SelectionWrap: retValue = true; break; + case SH_Menu_MouseTracking: + retValue = true; + break; case SH_ItemView_ShowDecorationSelected: retValue = true; break; @@ -3150,6 +3169,12 @@ bool QS60Style::event(QEvent *e) #ifdef QT_KEYPAD_NAVIGATION case QEvent::FocusIn: if (QWidget *focusWidget = QApplication::focusWidget()) { + + // Menus and combobox popups do not draw focus frame around them + if (qobject_cast<QComboBoxListView *>(focusWidget) || + qobject_cast<QMenu *>(focusWidget)) + break; + if (!d->m_focusFrame) d->m_focusFrame = new QFocusFrame(focusWidget); d->m_focusFrame->setWidget(focusWidget); diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp index 58a7159..55aa6b0 100644 --- a/src/gui/styles/qs60style_s60.cpp +++ b/src/gui/styles/qs60style_s60.cpp @@ -310,7 +310,7 @@ const partMapEntry QS60StyleModeSpecifics::m_partMap[] = { /* SP_QsnFrPopupSideB */ {KAknsIIDQsnFrPopupSideB, ENoDraw, ES60_All, -1,-1}, /* SP_QsnFrPopupSideL */ {KAknsIIDQsnFrPopupSideL, ENoDraw, ES60_All, -1,-1}, /* SP_QsnFrPopupSideR */ {KAknsIIDQsnFrPopupSideR, ENoDraw, ES60_All, -1,-1}, - /* SP_QsnFrPopupCenter */ {KAknsIIDQsnFrPopupCenter, ENoDraw, ES60_All, -1,-1}, + /* SP_QsnFrPopupCenter */ {KAknsIIDQsnFrPopupCenterSubmenu, ENoDraw, ES60_All, -1,-1}, // ToolTip graphics different in 3.1 vs. 3.2+. /* SP_QsnFrPopupPreviewCornerTl */ {KAknsIIDQsnFrPopupCornerTl, ENoDraw, ES60_3_1, EAknsMajorSkin, 0x19c5}, /* KAknsIIDQsnFrPopupPreviewCornerTl */ @@ -919,7 +919,7 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsLX(QS60StylePrivate::SkinFr result = fromFbsBitmap(frame, NULL, flags, targetSize); } } else { - TDisplayMode maskDepth = EGray2; + TDisplayMode maskDepth = EGray256; // Query the skin item for possible frame graphics mask details. if (skinInstance) { CAknsMaskedBitmapItemData* skinMaskedBmp = static_cast<CAknsMaskedBitmapItemData*>( @@ -983,6 +983,10 @@ void QS60StyleModeSpecifics::frameIdAndCenterId(QS60StylePrivate::SkinFrameEleme frameId.Set(KAknsIIDQsnFrPopupSub); } break; + case QS60StylePrivate::SF_PopupBackground: + centerId.Set(KAknsIIDQsnFrPopupCenterSubmenu); + frameId.Set(KAknsIIDQsnFrPopupSub); + break; case QS60StylePrivate::SF_PanelBackground: // remove center piece for panel graphics, so that only border is drawn centerId.Set(KAknsIIDNone); diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 81b923b..515b6c7 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -1539,7 +1539,9 @@ QVector<QCss::StyleRule> QStyleSheetStyle::styleRules(const QWidget *w) const QHash<const void *, StyleSheet>::const_iterator defaultCacheIt = styleSheetCache->constFind(baseStyle()); if (defaultCacheIt == styleSheetCache->constEnd()) { defaultSs = getDefaultStyleSheet(); - styleSheetCache->insert(baseStyle(), defaultSs); + QStyle *bs = baseStyle(); + styleSheetCache->insert(bs, defaultSs); + QObject::connect(bs, SIGNAL(destroyed(QObject*)), this, SLOT(styleDestroyed(QObject*)), Qt::UniqueConnection); } else { defaultSs = defaultCacheIt.value(); } @@ -2666,6 +2668,11 @@ void QStyleSheetStyle::widgetDestroyed(QObject *o) autoFillDisabledWidgets->remove((const QWidget *)o); } +void QStyleSheetStyle::styleDestroyed(QObject *o) +{ + styleSheetCache->remove(o); +} + /*! * Make sure that the cache will be clean by connecting destroyed if needed. * return false if the widget is not stylable; diff --git a/src/gui/styles/qstylesheetstyle_p.h b/src/gui/styles/qstylesheetstyle_p.h index 50abef9..fd81437 100644 --- a/src/gui/styles/qstylesheetstyle_p.h +++ b/src/gui/styles/qstylesheetstyle_p.h @@ -147,6 +147,7 @@ protected: private Q_SLOTS: void widgetDestroyed(QObject *); + void styleDestroyed(QObject *); private: int refcount; diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 24887b5..21a31a3 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -2616,10 +2616,8 @@ void QFontCache::cleanup() } QT_CATCH (const std::bad_alloc &) { // no cache - just ignore } - if (cache && cache->hasLocalData()) { - cache->localData()->clear(); + if (cache && cache->hasLocalData()) cache->setLocalData(0); - } } #endif // QT_NO_THREAD @@ -2631,6 +2629,7 @@ QFontCache::QFontCache() QFontCache::~QFontCache() { + clear(); { EngineDataCache::ConstIterator it = engineDataCache.constBegin(), end = engineDataCache.constEnd(); diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index ae5e9ca..ff29462 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -598,10 +598,10 @@ static QList<QFontDatabase::WritingSystem> determineWritingSystemsFromTrueTypeBi #if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE) // class with virtual destructor, derived in qfontdatabase_s60.cpp -class QFontDatabaseS60Store +class QSymbianFontDatabaseExtras { public: - virtual ~QFontDatabaseS60Store() {} + virtual ~QSymbianFontDatabaseExtras() {} }; #endif @@ -614,7 +614,7 @@ public: , stream(0) #endif #if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE) - , s60Store(0) + , symbianExtras(0) #endif { } ~QFontDatabasePrivate() { @@ -628,9 +628,9 @@ public: families = 0; count = 0; #if defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE) - if (s60Store) { - delete s60Store; - s60Store = 0; + if (symbianExtras) { + delete symbianExtras; + symbianExtras = 0; } #endif // don't clear the memory fonts! @@ -675,7 +675,7 @@ public: QDataStream *stream; QStringList fallbackFamilies; #elif defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE) - const QFontDatabaseS60Store *s60Store; + const QSymbianFontDatabaseExtras *symbianExtras; #endif }; diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp index ef5e0c4..3ad0806 100644 --- a/src/gui/text/qfontdatabase_s60.cpp +++ b/src/gui/text/qfontdatabase_s60.cpp @@ -92,22 +92,22 @@ QFileInfoList alternativeFilePaths(const QString &path, const QStringList &nameF } #if defined(QT_NO_FREETYPE) -class QFontDatabaseS60StoreImplementation : public QFontDatabaseS60Store +class QSymbianFontDatabaseExtrasImplementation : public QSymbianFontDatabaseExtras { public: - QFontDatabaseS60StoreImplementation(); - ~QFontDatabaseS60StoreImplementation(); + QSymbianFontDatabaseExtrasImplementation(); + ~QSymbianFontDatabaseExtrasImplementation(); - const QFontEngineS60Extensions *extension(const QString &typeface) const; + const QSymbianTypeFaceExtras *extras(const QString &typeface) const; private: RHeap* m_heap; CFontStore *m_store; COpenFontRasterizer *m_rasterizer; - mutable QHash<QString, const QFontEngineS60Extensions *> m_extensions; + mutable QHash<QString, const QSymbianTypeFaceExtras *> m_extras; }; -QFontDatabaseS60StoreImplementation::QFontDatabaseS60StoreImplementation() +QSymbianFontDatabaseExtrasImplementation::QSymbianFontDatabaseExtrasImplementation() { m_heap = User::ChunkHeap(NULL, 0x1000, 0x100000); QT_TRAP_THROWING( @@ -127,10 +127,10 @@ QFontDatabaseS60StoreImplementation::QFontDatabaseS60StoreImplementation() QT_TRAP_THROWING(m_store->AddFileL(fontFilePtr)); } } -QFontDatabaseS60StoreImplementation::~QFontDatabaseS60StoreImplementation() +QSymbianFontDatabaseExtrasImplementation::~QSymbianFontDatabaseExtrasImplementation() { - typedef QHash<QString, const QFontEngineS60Extensions *>::iterator iterator; - for (iterator p = m_extensions.begin(); p != m_extensions.end(); ++p) { + typedef QHash<QString, const QSymbianTypeFaceExtras *>::iterator iterator; + for (iterator p = m_extras.begin(); p != m_extras.end(); ++p) { m_store->ReleaseFont((*p)->fontOwner()); delete *p; } @@ -156,9 +156,9 @@ COpenFont* OpenFontFromBitmapFont(const CBitmapFont* aBitmapFont) } #endif // FNTSTORE_H_INLINES_SUPPORT_FMM -const QFontEngineS60Extensions *QFontDatabaseS60StoreImplementation::extension(const QString &typeface) const +const QSymbianTypeFaceExtras *QSymbianFontDatabaseExtrasImplementation::extras(const QString &typeface) const { - if (!m_extensions.contains(typeface)) { + if (!m_extras.contains(typeface)) { CFont* font = NULL; TFontSpec spec(qt_QString2TPtrC(typeface), 1); spec.iHeight = 1; @@ -171,9 +171,9 @@ const QFontEngineS60Extensions *QFontDatabaseS60StoreImplementation::extension(c #else OpenFontFromBitmapFont(bitmapFont); #endif // FNTSTORE_H_INLINES_SUPPORT_FMM - m_extensions.insert(typeface, new QFontEngineS60Extensions(font, openFont)); + m_extras.insert(typeface, new QSymbianTypeFaceExtras(font, openFont)); } - return m_extensions.value(typeface); + return m_extras.value(typeface); } #else class QFontEngineFTS60 : public QFontEngineFT @@ -240,14 +240,14 @@ static void initializeDb() return; #if defined(QT_NO_FREETYPE) - if (!db->s60Store) - db->s60Store = new QFontDatabaseS60StoreImplementation; + if (!db->symbianExtras) + db->symbianExtras = new QSymbianFontDatabaseExtrasImplementation; QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); const int numTypeFaces = QS60Data::screenDevice()->NumTypefaces(); - const QFontDatabaseS60StoreImplementation *store = - static_cast<const QFontDatabaseS60StoreImplementation*>(db->s60Store); + const QSymbianFontDatabaseExtrasImplementation *dbExtras = + static_cast<const QSymbianFontDatabaseExtrasImplementation*>(db->symbianExtras); bool fontAdded = false; for (int i = 0; i < numTypeFaces; i++) { TTypefaceSupport typefaceSupport; @@ -273,8 +273,8 @@ static void initializeDb() style->smoothScalable = typefaceSupport.iIsScalable; style->pixelSize(0, true); - const QFontEngineS60Extensions *extension = store->extension(familyName); - const QByteArray os2Table = extension->getSfntTable(MAKE_TAG('O', 'S', '/', '2')); + const QSymbianTypeFaceExtras *typeFaceExtras = dbExtras->extras(familyName); + const QByteArray os2Table = typeFaceExtras->getSfntTable(MAKE_TAG('O', 'S', '/', '2')); const unsigned char* data = reinterpret_cast<const unsigned char*>(os2Table.constData()); const unsigned char* ulUnicodeRange = data + 42; quint32 unicodeRange[4] = { @@ -394,10 +394,10 @@ QFontEngine *QFontDatabase::findFont(int script, const QFontPrivate *, const QFo QFontDef request = req; request.family = fontFamily; #if defined(QT_NO_FREETYPE) - const QFontDatabaseS60StoreImplementation *store = - static_cast<const QFontDatabaseS60StoreImplementation*>(db->s60Store); - const QFontEngineS60Extensions *extension = store->extension(fontFamily); - fe = new QFontEngineS60(request, extension); + const QSymbianFontDatabaseExtrasImplementation *dbExtras = + static_cast<const QSymbianFontDatabaseExtrasImplementation*>(db->symbianExtras); + const QSymbianTypeFaceExtras *typeFaceExtras = dbExtras->extras(fontFamily); + fe = new QFontEngineS60(request, typeFaceExtras); #else QFontEngine::FaceId faceId; const QtFontFamily * const reqQtFontFamily = db->family(fontFamily); diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp index c9ff661..a9960e4 100644 --- a/src/gui/text/qfontengine_s60.cpp +++ b/src/gui/text/qfontengine_s60.cpp @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE -QFontEngineS60Extensions::QFontEngineS60Extensions(CFont* fontOwner, COpenFont *font) +QSymbianTypeFaceExtras::QSymbianTypeFaceExtras(CFont* fontOwner, COpenFont *font) : m_font(font) , m_cmap(0) , m_symbolCMap(false) @@ -68,7 +68,7 @@ QFontEngineS60Extensions::QFontEngineS60Extensions(CFont* fontOwner, COpenFont * Q_ASSERT(m_shapingExtension && m_trueTypeExtension); } -QByteArray QFontEngineS60Extensions::getSfntTable(uint tag) const +QByteArray QSymbianTypeFaceExtras::getSfntTable(uint tag) const { Q_ASSERT(m_trueTypeExtension->HasTrueTypeTable(tag)); TInt error = KErrNone; @@ -79,7 +79,7 @@ QByteArray QFontEngineS60Extensions::getSfntTable(uint tag) const return result; } -bool QFontEngineS60Extensions::getSfntTableData(uint tag, uchar *buffer, uint *length) const +bool QSymbianTypeFaceExtras::getSfntTableData(uint tag, uchar *buffer, uint *length) const { if (!m_trueTypeExtension->HasTrueTypeTable(tag)) return false; @@ -104,7 +104,7 @@ bool QFontEngineS60Extensions::getSfntTableData(uint tag, uchar *buffer, uint *l return result; } -const unsigned char *QFontEngineS60Extensions::cmap() const +const unsigned char *QSymbianTypeFaceExtras::cmap() const { if (!m_cmap) { m_cmapTable = getSfntTable(MAKE_TAG('c', 'm', 'a', 'p')); @@ -114,7 +114,7 @@ const unsigned char *QFontEngineS60Extensions::cmap() const return m_cmap; } -QPainterPath QFontEngineS60Extensions::glyphOutline(glyph_t glyph) const +QPainterPath QSymbianTypeFaceExtras::glyphOutline(glyph_t glyph) const { QPainterPath result; QPolygonF polygon; @@ -134,7 +134,7 @@ QPainterPath QFontEngineS60Extensions::glyphOutline(glyph_t glyph) const return result; } -CFont *QFontEngineS60Extensions::fontOwner() const +CFont *QSymbianTypeFaceExtras::fontOwner() const { return m_fontOwner; } @@ -192,8 +192,8 @@ void QFontEngineS60::releaseFont(CFont *&font) } } -QFontEngineS60::QFontEngineS60(const QFontDef &request, const QFontEngineS60Extensions *extensions) - : m_extensions(extensions) +QFontEngineS60::QFontEngineS60(const QFontDef &request, const QSymbianTypeFaceExtras *extras) + : m_extras(extras) , m_originalFont(0) , m_originalFontSizeInPixels((request.pixelSize >= 0)? request.pixelSize:pointsToPixels(request.pointSize)) @@ -220,10 +220,12 @@ bool QFontEngineS60::stringToCMap(const QChar *characters, int len, QGlyphLayout } HB_Glyph *g = glyphs->glyphs; - const unsigned char* cmap = m_extensions->cmap(); + const unsigned char* cmap = m_extras->cmap(); + const bool isRtl = (flags & QTextEngine::RightToLeft); for (int i = 0; i < len; ++i) { const unsigned int uc = getChar(characters, i, len); - *g++ = QFontEngine::getTrueTypeGlyphIndex(cmap, uc); + *g++ = QFontEngine::getTrueTypeGlyphIndex(cmap, + isRtl ? QChar::mirroredChar(uc) : uc); } glyphs->numGlyphs = g - glyphs->glyphs; @@ -241,8 +243,8 @@ void QFontEngineS60::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFla Q_UNUSED(flags); for (int i = 0; i < glyphs->numGlyphs; i++) { const glyph_metrics_t bbox = boundingBox_const(glyphs->glyphs[i]); - glyphs->advances_x[i] = glyphs->offsets[i].x = bbox.xoff; - glyphs->advances_y[i] = glyphs->offsets[i].y = bbox.yoff; + glyphs->advances_x[i] = bbox.xoff; + glyphs->advances_y[i] = bbox.yoff; } } @@ -337,7 +339,7 @@ const char *QFontEngineS60::name() const bool QFontEngineS60::canRender(const QChar *string, int len) { - const unsigned char *cmap = m_extensions->cmap(); + const unsigned char *cmap = m_extras->cmap(); for (int i = 0; i < len; ++i) { const unsigned int uc = getChar(string, i, len); if (QFontEngine::getTrueTypeGlyphIndex(cmap, uc) == 0) @@ -348,12 +350,12 @@ bool QFontEngineS60::canRender(const QChar *string, int len) QByteArray QFontEngineS60::getSfntTable(uint tag) const { - return m_extensions->getSfntTable(tag); + return m_extras->getSfntTable(tag); } bool QFontEngineS60::getSfntTableData(uint tag, uchar *buffer, uint *length) const { - return m_extensions->getSfntTableData(tag, buffer, length); + return m_extras->getSfntTableData(tag, buffer, length); } QFontEngine::Type QFontEngineS60::type() const diff --git a/src/gui/text/qfontengine_s60_p.h b/src/gui/text/qfontengine_s60_p.h index a80af4d..b6b117f 100644 --- a/src/gui/text/qfontengine_s60_p.h +++ b/src/gui/text/qfontengine_s60_p.h @@ -63,10 +63,10 @@ class CFont; QT_BEGIN_NAMESPACE // ..gives us access to truetype tables, UTF-16<->GlyphID mapping, and glyph outlines -class QFontEngineS60Extensions +class QSymbianTypeFaceExtras { public: - QFontEngineS60Extensions(CFont* fontOwner, COpenFont *font); + QSymbianTypeFaceExtras(CFont* fontOwner, COpenFont *font); QByteArray getSfntTable(uint tag) const; bool getSfntTableData(uint tag, uchar *buffer, uint *length) const; @@ -87,7 +87,7 @@ private: class QFontEngineS60 : public QFontEngine { public: - QFontEngineS60(const QFontDef &fontDef, const QFontEngineS60Extensions *extensions); + QFontEngineS60(const QFontDef &fontDef, const QSymbianTypeFaceExtras *extras); ~QFontEngineS60(); bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const; @@ -128,7 +128,7 @@ private: CFont *fontWithSize(qreal size) const; static void releaseFont(CFont *&font); - const QFontEngineS60Extensions *m_extensions; + const QSymbianTypeFaceExtras *m_extras; CFont* m_originalFont; const qreal m_originalFontSizeInPixels; CFont* m_scaledFont; diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 655fc61..c1c4abf 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -740,8 +740,14 @@ bool QLineEdit::validateAndSet(const QString &newText, int newPos, setText(oldText); return false; } - setCursorPosition(newPos); - setSelection(qMin(newMarkAnchor, newMarkDrag), qAbs(newMarkAnchor - newMarkDrag)); + int selstart = qMin(newMarkAnchor, newMarkDrag); + int sellength = qAbs(newMarkAnchor - newMarkDrag); + if (selstart == newPos) { + selstart = qMax(newMarkAnchor, newMarkDrag); + sellength = -sellength; + } + //setSelection also set the position + setSelection(selstart, sellength); return true; } #endif //QT3_SUPPORT diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 907dd14..f84059d 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -2803,7 +2803,9 @@ void QMenu::mouseMoveEvent(QMouseEvent *e) QAction *action = d->actionAt(e->pos()); if (!action) { - if (d->hasHadMouse) + if (d->hasHadMouse + && (!d->currentAction + || !(d->currentAction->menu() && d->currentAction->menu()->isVisible()))) d->setCurrentAction(0); return; } else if(e->buttons()) { diff --git a/src/multimedia/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/multimedia/audio/qaudioinput_alsa_p.cpp index 6b15008..c9a8b71 100644 --- a/src/multimedia/multimedia/audio/qaudioinput_alsa_p.cpp +++ b/src/multimedia/multimedia/audio/qaudioinput_alsa_p.cpp @@ -58,8 +58,6 @@ QT_BEGIN_NAMESPACE //#define DEBUG_AUDIO 1 -static const int minimumIntervalTime = 50; - QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFormat& audioFormat): settings(audioFormat) { @@ -594,10 +592,7 @@ int QAudioInputPrivate::periodSize() const void QAudioInputPrivate::setNotifyInterval(int ms) { - if(ms >= minimumIntervalTime) - intervalTime = ms; - else - intervalTime = minimumIntervalTime; + intervalTime = qMax(0, ms); } int QAudioInputPrivate::notifyInterval() const @@ -649,7 +644,7 @@ bool QAudioInputPrivate::deviceReady() if(deviceState != QAudio::ActiveState) return true; - if((timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { + if(intervalTime && (timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { emit notify(); elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; timeStamp.restart(); diff --git a/src/multimedia/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/multimedia/audio/qaudioinput_win32_p.cpp index b5d673e..14a1cf3 100644 --- a/src/multimedia/multimedia/audio/qaudioinput_win32_p.cpp +++ b/src/multimedia/multimedia/audio/qaudioinput_win32_p.cpp @@ -57,8 +57,6 @@ QT_BEGIN_NAMESPACE //#define DEBUG_AUDIO 1 -static const int minimumIntervalTime = 50; - QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFormat& audioFormat): settings(audioFormat) { @@ -74,16 +72,11 @@ QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFor pullMode = true; resuming = false; finished = false; - - connect(this,SIGNAL(processMore()),SLOT(deviceReady())); - - InitializeCriticalSection(&waveInCriticalSection); } QAudioInputPrivate::~QAudioInputPrivate() { stop(); - DeleteCriticalSection(&waveInCriticalSection); } void QT_WIN_CALLBACK QAudioInputPrivate::waveInProc( HWAVEIN hWaveIn, UINT uMsg, @@ -98,20 +91,18 @@ void QT_WIN_CALLBACK QAudioInputPrivate::waveInProc( HWAVEIN hWaveIn, UINT uMsg, if(!qAudio) return; + QMutexLocker(&qAudio->mutex); + switch(uMsg) { case WIM_OPEN: break; case WIM_DATA: - EnterCriticalSection(&qAudio->waveInCriticalSection); if(qAudio->waveFreeBlockCount > 0) qAudio->waveFreeBlockCount--; qAudio->feedback(); - LeaveCriticalSection(&qAudio->waveInCriticalSection); break; case WIM_CLOSE: - EnterCriticalSection(&qAudio->waveInCriticalSection); qAudio->finished = true; - LeaveCriticalSection(&qAudio->waveInCriticalSection); break; default: return; @@ -156,7 +147,7 @@ void QAudioInputPrivate::freeBlocks(WAVEHDR* blockArray) int count = buffer_size/period_size; for(int i = 0; i < count; i++) { - waveInUnprepareHeader(hWaveIn,&blocks[i], sizeof(WAVEHDR)); + waveInUnprepareHeader(hWaveIn,blocks, sizeof(WAVEHDR)); blocks+=sizeof(WAVEHDR); } HeapFree(GetProcessHeap(), 0, blockArray); @@ -283,9 +274,9 @@ bool QAudioInputPrivate::open() return false; } - EnterCriticalSection(&waveInCriticalSection); + mutex.lock(); waveFreeBlockCount = buffer_size/period_size; - LeaveCriticalSection(&waveInCriticalSection); + mutex.unlock(); waveCurrentBlock = 0; @@ -329,13 +320,11 @@ void QAudioInputPrivate::close() Sleep(10); } - EnterCriticalSection(&waveInCriticalSection); - for(int i=0; i<waveFreeBlockCount; i++) { - if(waveBlocks[i].dwFlags & WHDR_PREPARED) - waveInUnprepareHeader(hWaveIn,&waveBlocks[i],sizeof(WAVEHDR)); - } - LeaveCriticalSection(&waveInCriticalSection); + mutex.lock(); + for(int i=0; i<waveFreeBlockCount; i++) + waveInUnprepareHeader(hWaveIn,&waveBlocks[i],sizeof(WAVEHDR)); freeBlocks(waveBlocks); + mutex.unlock(); } int QAudioInputPrivate::bytesReady() const @@ -406,9 +395,10 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) waveInUnprepareHeader(hWaveIn,&waveBlocks[header], sizeof(WAVEHDR)); - EnterCriticalSection(&waveInCriticalSection); + mutex.lock(); waveFreeBlockCount++; - LeaveCriticalSection(&waveInCriticalSection); + mutex.unlock(); + waveBlocks[header].dwBytesRecorded=0; waveBlocks[header].dwFlags = 0L; result = waveInPrepareHeader(hWaveIn,&waveBlocks[header], sizeof(WAVEHDR)); @@ -416,18 +406,22 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) result = waveInPrepareHeader(hWaveIn,&waveBlocks[header], sizeof(WAVEHDR)); qWarning("QAudioInput: failed to prepare block %d,err=%d",header,result); errorState = QAudio::IOError; - EnterCriticalSection(&waveInCriticalSection); + + mutex.lock(); waveFreeBlockCount--; - LeaveCriticalSection(&waveInCriticalSection); + mutex.unlock(); + return 0; } result = waveInAddBuffer(hWaveIn, &waveBlocks[header], sizeof(WAVEHDR)); if(result != MMSYSERR_NOERROR) { qWarning("QAudioInput: failed to setup block %d,err=%d",header,result); errorState = QAudio::IOError; - EnterCriticalSection(&waveInCriticalSection); + + mutex.lock(); waveFreeBlockCount--; - LeaveCriticalSection(&waveInCriticalSection); + mutex.unlock(); + return 0; } header++; @@ -435,7 +429,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) header = 0; p+=l; - EnterCriticalSection(&waveInCriticalSection); + mutex.lock(); if(!pullMode) { if(l+period_size > len && waveFreeBlockCount == buffer_size/period_size) done = true; @@ -443,7 +437,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) if(waveFreeBlockCount == buffer_size/period_size) done = true; } - LeaveCriticalSection(&waveInCriticalSection); + mutex.unlock(); written+=l; } @@ -467,9 +461,10 @@ void QAudioInputPrivate::resume() return; } } - EnterCriticalSection(&waveInCriticalSection); + + mutex.lock(); waveFreeBlockCount = buffer_size/period_size; - LeaveCriticalSection(&waveInCriticalSection); + mutex.unlock(); waveCurrentBlock = 0; header = 0; @@ -497,10 +492,7 @@ int QAudioInputPrivate::periodSize() const void QAudioInputPrivate::setNotifyInterval(int ms) { - if(ms >= minimumIntervalTime) - intervalTime = ms; - else - intervalTime = minimumIntervalTime; + intervalTime = qMax(0, ms); } int QAudioInputPrivate::notifyInterval() const @@ -534,14 +526,13 @@ void QAudioInputPrivate::feedback() QTime now(QTime::currentTime()); qDebug()<<now.second()<<"s "<<now.msec()<<"ms :feedback() INPUT "<<this; #endif - bytesAvailable = bytesReady(); - if(!(deviceState==QAudio::StoppedState||deviceState==QAudio::SuspendedState)) - emit processMore(); + QMetaObject::invokeMethod(this, "deviceReady", Qt::QueuedConnection); } bool QAudioInputPrivate::deviceReady() { + bytesAvailable = bytesReady(); #ifdef DEBUG_AUDIO QTime now(QTime::currentTime()); qDebug()<<now.second()<<"s "<<now.msec()<<"ms :deviceReady() INPUT"; @@ -558,7 +549,7 @@ bool QAudioInputPrivate::deviceReady() a->trigger(); } - if((timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { + if(intervalTime && (timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { emit notify(); elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; timeStamp.restart(); diff --git a/src/multimedia/multimedia/audio/qaudioinput_win32_p.h b/src/multimedia/multimedia/audio/qaudioinput_win32_p.h index 66c2535..8a9b02b 100644 --- a/src/multimedia/multimedia/audio/qaudioinput_win32_p.h +++ b/src/multimedia/multimedia/audio/qaudioinput_win32_p.h @@ -62,6 +62,7 @@ #include <QtCore/qstring.h> #include <QtCore/qstringlist.h> #include <QtCore/qdatetime.h> +#include <QtCore/qmutex.h> #include <QtMultimedia/qaudio.h> #include <QtMultimedia/qaudiodeviceinfo.h> @@ -122,7 +123,7 @@ private: volatile int waveFreeBlockCount; int waveCurrentBlock; - CRITICAL_SECTION waveInCriticalSection; + QMutex mutex; static void QT_WIN_CALLBACK waveInProc( HWAVEIN hWaveIn, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ); diff --git a/src/multimedia/multimedia/audio/qaudiooutput_alsa_p.cpp b/src/multimedia/multimedia/audio/qaudiooutput_alsa_p.cpp index cf3726b..49b32c0 100644 --- a/src/multimedia/multimedia/audio/qaudiooutput_alsa_p.cpp +++ b/src/multimedia/multimedia/audio/qaudiooutput_alsa_p.cpp @@ -58,8 +58,6 @@ QT_BEGIN_NAMESPACE //#define DEBUG_AUDIO 1 -static const int minimumIntervalTime = 50; - QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioFormat& audioFormat): settings(audioFormat) { @@ -84,8 +82,7 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioF resuming = false; opened = false; - QStringList list1 = QString(QLatin1String(device)).split(QLatin1String(":")); - m_device = QByteArray(list1.at(0).toLocal8Bit().constData()); + m_device = device; timer = new QTimer(this); connect(timer,SIGNAL(timeout()),SLOT(userFeed())); @@ -282,11 +279,11 @@ bool QAudioOutputPrivate::open() int count=0; unsigned int freakuency=settings.frequency(); - QString dev = QLatin1String(m_device.constData()); + QString dev = QString(QLatin1String(m_device.constData())); QList<QByteArray> devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioOutput); if(dev.compare(QLatin1String("default")) == 0) { #if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) - dev = QLatin1String(devices.first().constData()); + dev = QLatin1String(devices.first()); #else dev = QLatin1String("hw:0,0"); #endif @@ -574,10 +571,7 @@ int QAudioOutputPrivate::bufferSize() const void QAudioOutputPrivate::setNotifyInterval(int ms) { - if(ms >= minimumIntervalTime) - intervalTime = ms; - else - intervalTime = minimumIntervalTime; + intervalTime = qMax(0, ms); } int QAudioOutputPrivate::notifyInterval() const @@ -719,7 +713,7 @@ bool QAudioOutputPrivate::deviceReady() if(deviceState != QAudio::ActiveState) return true; - if((timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { + if(intervalTime && (timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { emit notify(); elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; timeStamp.restart(); diff --git a/src/multimedia/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/multimedia/audio/qaudiooutput_win32_p.cpp index 13bce58..a8aeb41 100644 --- a/src/multimedia/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/multimedia/audio/qaudiooutput_win32_p.cpp @@ -56,8 +56,6 @@ QT_BEGIN_NAMESPACE -static const int minimumIntervalTime = 50; - QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioFormat& audioFormat): settings(audioFormat) { @@ -73,17 +71,15 @@ QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioF audioSource = 0; pullMode = true; finished = false; - InitializeCriticalSection(&waveOutCriticalSection); } QAudioOutputPrivate::~QAudioOutputPrivate() { - EnterCriticalSection(&waveOutCriticalSection); + mutex.lock(); finished = true; - LeaveCriticalSection(&waveOutCriticalSection); + mutex.unlock(); close(); - DeleteCriticalSection(&waveOutCriticalSection); } void CALLBACK QAudioOutputPrivate::waveOutProc( HWAVEOUT hWaveOut, UINT uMsg, @@ -98,6 +94,8 @@ void CALLBACK QAudioOutputPrivate::waveOutProc( HWAVEOUT hWaveOut, UINT uMsg, if(!qAudio) return; + QMutexLocker(&qAudio->mutex); + switch(uMsg) { case WOM_OPEN: qAudio->feedback(); @@ -105,16 +103,13 @@ void CALLBACK QAudioOutputPrivate::waveOutProc( HWAVEOUT hWaveOut, UINT uMsg, case WOM_CLOSE: return; case WOM_DONE: - EnterCriticalSection(&qAudio->waveOutCriticalSection); if(qAudio->finished || qAudio->buffer_size == 0 || qAudio->period_size == 0) { - LeaveCriticalSection(&qAudio->waveOutCriticalSection); return; } qAudio->waveFreeBlockCount++; if(qAudio->waveFreeBlockCount >= qAudio->buffer_size/qAudio->period_size) qAudio->waveFreeBlockCount = qAudio->buffer_size/qAudio->period_size; qAudio->feedback(); - LeaveCriticalSection(&qAudio->waveOutCriticalSection); break; default: return; @@ -150,7 +145,7 @@ void QAudioOutputPrivate::freeBlocks(WAVEHDR* blockArray) int count = buffer_size/period_size; for(int i = 0; i < count; i++) { - waveOutUnprepareHeader(hWaveOut,&blocks[i], sizeof(WAVEHDR)); + waveOutUnprepareHeader(hWaveOut,blocks, sizeof(WAVEHDR)); blocks+=sizeof(WAVEHDR); } HeapFree(GetProcessHeap(), 0, blockArray); @@ -225,9 +220,9 @@ bool QAudioOutputPrivate::open() } waveBlocks = allocateBlocks(period_size, buffer_size/period_size); - EnterCriticalSection(&waveOutCriticalSection); + mutex.lock(); waveFreeBlockCount = buffer_size/period_size; - LeaveCriticalSection(&waveOutCriticalSection); + mutex.unlock(); waveCurrentBlock = 0; @@ -333,10 +328,7 @@ int QAudioOutputPrivate::bufferSize() const void QAudioOutputPrivate::setNotifyInterval(int ms) { - if(ms >= minimumIntervalTime) - intervalTime = ms; - else - intervalTime = minimumIntervalTime; + intervalTime = qMax(0, ms); } int QAudioOutputPrivate::notifyInterval() const @@ -368,12 +360,12 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) int remain; current = &waveBlocks[waveCurrentBlock]; while(l > 0) { - EnterCriticalSection(&waveOutCriticalSection); + mutex.lock(); if(waveFreeBlockCount==0) { - LeaveCriticalSection(&waveOutCriticalSection); + mutex.unlock(); break; } - LeaveCriticalSection(&waveOutCriticalSection); + mutex.unlock(); if(current->dwFlags & WHDR_PREPARED) waveOutUnprepareHeader(hWaveOut, current, sizeof(WAVEHDR)); @@ -390,15 +382,13 @@ qint64 QAudioOutputPrivate::write( const char *data, qint64 len ) waveOutPrepareHeader(hWaveOut, current, sizeof(WAVEHDR)); waveOutWrite(hWaveOut, current, sizeof(WAVEHDR)); - EnterCriticalSection(&waveOutCriticalSection); + mutex.lock(); waveFreeBlockCount--; - LeaveCriticalSection(&waveOutCriticalSection); #ifdef DEBUG_AUDIO - EnterCriticalSection(&waveOutCriticalSection); qDebug("write out l=%d, waveFreeBlockCount=%d", current->dwBufferLength,waveFreeBlockCount); - LeaveCriticalSection(&waveOutCriticalSection); #endif + mutex.unlock(); totalTimeValue += current->dwBufferLength; waveCurrentBlock++; waveCurrentBlock %= buffer_size/period_size; @@ -453,7 +443,7 @@ void QAudioOutputPrivate::feedback() bool QAudioOutputPrivate::deviceReady() { - if(deviceState == QAudio::StoppedState) + if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState) return false; if(pullMode) { @@ -467,14 +457,16 @@ bool QAudioOutputPrivate::deviceReady() startup = true; bool full=false; - EnterCriticalSection(&waveOutCriticalSection); + + mutex.lock(); if(waveFreeBlockCount==0) full = true; - LeaveCriticalSection(&waveOutCriticalSection); + mutex.unlock(); + if (full){ #ifdef DEBUG_AUDIO qDebug() << "Skipping data as unable to write"; #endif - if((timeStamp.elapsed() + elapsedTimeOffset) > intervalTime ) { + if(intervalTime && (timeStamp.elapsed() + elapsedTimeOffset) > intervalTime ) { emit notify(); elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; timeStamp.restart(); @@ -504,12 +496,14 @@ bool QAudioOutputPrivate::deviceReady() bytesAvailable = bytesFree(); int check = 0; - EnterCriticalSection(&waveOutCriticalSection); + + mutex.lock(); check = waveFreeBlockCount; - LeaveCriticalSection(&waveOutCriticalSection); + mutex.unlock(); + if(check == buffer_size/period_size) { - errorState = QAudio::UnderrunError; if (deviceState != QAudio::IdleState) { + errorState = QAudio::UnderrunError; deviceState = QAudio::IdleState; emit stateChanged(deviceState); } @@ -521,19 +515,23 @@ bool QAudioOutputPrivate::deviceReady() } } else { int buffered; - EnterCriticalSection(&waveOutCriticalSection); + + mutex.lock(); buffered = waveFreeBlockCount; - LeaveCriticalSection(&waveOutCriticalSection); - errorState = QAudio::UnderrunError; + mutex.unlock(); + if (buffered >= buffer_size/period_size && deviceState == QAudio::ActiveState) { - deviceState = QAudio::IdleState; - emit stateChanged(deviceState); + if (deviceState != QAudio::IdleState) { + errorState = QAudio::UnderrunError; + deviceState = QAudio::IdleState; + emit stateChanged(deviceState); + } } } if(deviceState != QAudio::ActiveState && deviceState != QAudio::IdleState) return true; - if((timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { + if(intervalTime && (timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { emit notify(); elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; timeStamp.restart(); diff --git a/src/multimedia/multimedia/audio/qaudiooutput_win32_p.h b/src/multimedia/multimedia/audio/qaudiooutput_win32_p.h index 68a40f7..2d19225 100644 --- a/src/multimedia/multimedia/audio/qaudiooutput_win32_p.h +++ b/src/multimedia/multimedia/audio/qaudiooutput_win32_p.h @@ -61,6 +61,7 @@ #include <QtCore/qstring.h> #include <QtCore/qstringlist.h> #include <QtCore/qdatetime.h> +#include <QtCore/qmutex.h> #include <QtMultimedia/qaudio.h> #include <QtMultimedia/qaudiodeviceinfo.h> @@ -119,7 +120,7 @@ private: static void QT_WIN_CALLBACK waveOutProc( HWAVEOUT hWaveOut, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ); - CRITICAL_SECTION waveOutCriticalSection; + QMutex mutex; WAVEHDR* allocateBlocks(int size, int count); void freeBlocks(WAVEHDR* blockArray); diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index a6322a3..559124f 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -489,7 +489,11 @@ void QHttpNetworkConnectionPrivate::fillPipeline(QAbstractSocket *socket) int i = indexOf(socket); - if (! (defaultPipelineLength - channels[i].alreadyPipelinedRequests.length() >= 2)) { + // return fast if there was no reply right now processed + if (channels[i].reply == 0) + return; + + if (! (defaultPipelineLength - channels[i].alreadyPipelinedRequests.length() >= defaultRePipelineLength)) { return; } diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index f9a6de8..3b7bc9e 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -317,6 +317,13 @@ void QHttpNetworkConnectionChannel::_q_receiveReply() return; } + // only run when the QHttpNetworkConnection is not currently being destructed, e.g. + // this function is called from _q_disconnected which is called because + // of ~QHttpNetworkConnectionPrivate + if (!qobject_cast<QHttpNetworkConnection*>(connection)) { + return; + } + qint64 bytes = 0; QAbstractSocket::SocketState socketState = socket->state(); @@ -384,7 +391,7 @@ void QHttpNetworkConnectionChannel::_q_receiveReply() if (!replyPrivate->expectContent()) { replyPrivate->state = QHttpNetworkReplyPrivate::AllDoneState; allDone(); - return; + break; } } break; diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index 7a48c2b..3154ed6 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -726,8 +726,7 @@ void QNetworkAccessHttpBackend::readFromHttp() QByteDataBuffer list; while (httpReply->bytesAvailable() != 0 && nextDownstreamBlockSize() != 0 && nextDownstreamBlockSize() > list.byteAmount()) { - QByteArray data = httpReply->readAny(); - list.append(data); + list.append(httpReply->readAny()); } if (!list.isEmpty()) diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index c3dc168..128d18f 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -478,6 +478,37 @@ qint64 QNetworkReplyImplPrivate::nextDownstreamBlockSize() const return qMax<qint64>(0, readBufferMaxSize - readBuffer.byteAmount()); } +void QNetworkReplyImplPrivate::initCacheSaveDevice() +{ + Q_Q(QNetworkReplyImpl); + + // save the meta data + QNetworkCacheMetaData metaData; + metaData.setUrl(url); + metaData = backend->fetchCacheMetaData(metaData); + + // save the redirect request also in the cache + QVariant redirectionTarget = q->attribute(QNetworkRequest::RedirectionTargetAttribute); + if (redirectionTarget.isValid()) { + QNetworkCacheMetaData::AttributesMap attributes = metaData.attributes(); + attributes.insert(QNetworkRequest::RedirectionTargetAttribute, redirectionTarget); + metaData.setAttributes(attributes); + } + + cacheSaveDevice = networkCache()->prepare(metaData); + + if (!cacheSaveDevice || (cacheSaveDevice && !cacheSaveDevice->isOpen())) { + if (cacheSaveDevice && !cacheSaveDevice->isOpen()) + qCritical("QNetworkReplyImpl: network cache returned a device that is not open -- " + "class %s probably needs to be fixed", + networkCache()->metaObject()->className()); + + networkCache()->remove(url); + cacheSaveDevice = 0; + cacheEnabled = false; + } +} + // we received downstream data and send this to the cache // and to our readBuffer (which in turn gets read by the user of QNetworkReply) void QNetworkReplyImplPrivate::appendDownstreamData(QByteDataBuffer &data) @@ -487,36 +518,12 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QByteDataBuffer &data) return; if (cacheEnabled && !cacheSaveDevice) { - // save the meta data - QNetworkCacheMetaData metaData; - metaData.setUrl(url); - metaData = backend->fetchCacheMetaData(metaData); - - // save the redirect request also in the cache - QVariant redirectionTarget = q->attribute(QNetworkRequest::RedirectionTargetAttribute); - if (redirectionTarget.isValid()) { - QNetworkCacheMetaData::AttributesMap attributes = metaData.attributes(); - attributes.insert(QNetworkRequest::RedirectionTargetAttribute, redirectionTarget); - metaData.setAttributes(attributes); - } - - cacheSaveDevice = networkCache()->prepare(metaData); - - if (!cacheSaveDevice || (cacheSaveDevice && !cacheSaveDevice->isOpen())) { - if (cacheSaveDevice && !cacheSaveDevice->isOpen()) - qCritical("QNetworkReplyImpl: network cache returned a device that is not open -- " - "class %s probably needs to be fixed", - networkCache()->metaObject()->className()); - - networkCache()->remove(url); - cacheSaveDevice = 0; - cacheEnabled = false; - } + initCacheSaveDevice(); } qint64 bytesWritten = 0; for (int i = 0; i < data.bufferCount(); i++) { - QByteArray item = data[i]; + QByteArray const &item = data[i]; if (cacheSaveDevice) cacheSaveDevice->write(item.constData(), item.size()); @@ -529,6 +536,13 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QByteDataBuffer &data) bytesDownloaded += bytesWritten; lastBytesDownloaded = bytesDownloaded; + appendDownstreamDataSignalEmissions(); +} + +void QNetworkReplyImplPrivate::appendDownstreamDataSignalEmissions() +{ + Q_Q(QNetworkReplyImpl); + QPointer<QNetworkReplyImpl> qq = q; QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader); @@ -572,6 +586,15 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data) _q_copyReadyRead(); } +void QNetworkReplyImplPrivate::appendDownstreamData(const QByteArray &data) +{ + // TODO implement + + // TODO call + + qFatal("QNetworkReplyImplPrivate::appendDownstreamData not implemented"); +} + void QNetworkReplyImplPrivate::finished() { Q_Q(QNetworkReplyImpl); @@ -689,8 +712,13 @@ QNetworkReplyImpl::QNetworkReplyImpl(QObject *parent) QNetworkReplyImpl::~QNetworkReplyImpl() { Q_D(QNetworkReplyImpl); + + // This code removes the data from the cache if it was prematurely aborted. + // See QNetworkReplyImplPrivate::completeCacheSave(), we disable caching there after the cache + // save had been properly finished. So if it is still enabled it means we got deleted/aborted. if (d->isCachingEnabled()) d->networkCache()->remove(url()); + if (d->outgoingDataBuffer) delete d->outgoingDataBuffer; } diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h index bc7e408..38084bd 100644 --- a/src/network/access/qnetworkreplyimpl_p.h +++ b/src/network/access/qnetworkreplyimpl_p.h @@ -156,8 +156,13 @@ public: void consume(qint64 count); void emitUploadProgress(qint64 bytesSent, qint64 bytesTotal); qint64 nextDownstreamBlockSize() const; + + void initCacheSaveDevice(); + void appendDownstreamDataSignalEmissions(); void appendDownstreamData(QByteDataBuffer &data); void appendDownstreamData(QIODevice *data); + void appendDownstreamData(const QByteArray &data); + void finished(); void error(QNetworkReply::NetworkError code, const QString &errorString); void metaDataChanged(); diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 72ed6be..bf77eda 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1637,7 +1637,14 @@ static void convertFromGLImage(QImage &img, int w, int h, bool alpha_format, boo uint *q = (uint*)img.scanLine(y); for (int x=0; x < w; ++x) { const uint pixel = *q; - *q = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) | (pixel & 0xff00ff00); + if (alpha_format && include_alpha) { + *q = ((pixel << 16) & 0xff0000) | ((pixel >> 16) & 0xff) + | (pixel & 0xff00ff00); + } else { + *q = 0xff000000 | ((pixel << 16) & 0xff0000) + | ((pixel >> 16) & 0xff) | (pixel & 0x00ff00); + } + q++; } } @@ -1648,7 +1655,8 @@ static void convertFromGLImage(QImage &img, int w, int h, bool alpha_format, boo QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha) { - QImage img(size, alpha_format ? QImage::Format_ARGB32 : QImage::Format_RGB32); + QImage img(size, (alpha_format && include_alpha) ? QImage::Format_ARGB32 + : QImage::Format_RGB32); int w = size.width(); int h = size.height(); glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, img.bits()); diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index 5ae69cd..f602c73 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -182,7 +182,6 @@ public: qreal penScale; // Pen scaling factor from "transform". QTransform pathTransform; // Calculated VG path transformation. - QTransform glyphTransform; // Calculated VG glyph transformation. QTransform imageTransform; // Calculated VG image transformation. bool pathTransformSet; // True if path transform set in the VG context. @@ -507,24 +506,15 @@ void QVGPaintEnginePrivate::updateTransform(QPaintDevice *pdev) // | 1 0 0 | // | 0 -1 devh | // | 0 0 1 | - // The glyph transform uses a slightly different transformation: - // | 1 0 0 | | 1 0 0.5 | | 1 0 0.5 | - // | 0 -1 devh - 1 | * | 0 1 -0.5 | = | 0 -1 (devh - 0.5) | - // | 0 0 1 | | 0 0 1 | | 0 0 1 | // The full VG transform is effectively: // 1. Apply the user's transformation matrix. - // 2. Translate glyphs by an extra (0.5, -0.5). - // 3. Flip the co-ordinate system upside down. + // 2. Flip the co-ordinate system upside down. QTransform viewport(1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, devh, 1.0f); - QTransform gviewport(1.0f, 0.0f, 0.0f, - 0.0f, -1.0f, 0.0f, - 0.5f, devh - 0.5f, 1.0f); // Compute the path transform and determine if it is projective. pathTransform = transform * viewport; - glyphTransform = transform * gviewport; bool projective = (pathTransform.m13() != 0.0f || pathTransform.m23() != 0.0f || pathTransform.m33() != 1.0f); @@ -533,7 +523,6 @@ void QVGPaintEnginePrivate::updateTransform(QPaintDevice *pdev) // so we will have to convert the co-ordinates ourselves. // Change the matrix to just the viewport transformation. pathTransform = viewport; - glyphTransform = gviewport; simpleTransform = false; } else { simpleTransform = true; @@ -3242,10 +3231,10 @@ void QVGFontGlyphCache::cacheGlyphs(QVGPaintEnginePrivate *d, vgImageSubData(vgImage, img.constBits(), img.bytesPerLine(), VG_sARGB_8888_PRE, 0, 0, img.width(), img.height()); } } - origin[0] = -metrics.x.toReal() + 0.5f; - origin[1] = -metrics.y.toReal() + 0.5f; - escapement[0] = metrics.xoff.toReal(); - escapement[1] = metrics.yoff.toReal(); + origin[0] = -metrics.x.toReal(); + origin[1] = -metrics.y.toReal(); + escapement[0] = 0; + escapement[1] = 0; vgSetGlyphToImage(font, glyph, vgImage, origin, escapement); vgDestroyImage(vgImage); // Reduce reference count. #else @@ -3261,8 +3250,8 @@ void QVGFontGlyphCache::cacheGlyphs(QVGPaintEnginePrivate *d, } origin[0] = 0; origin[1] = 0; - escapement[0] = metrics.xoff.toReal(); - escapement[1] = metrics.yoff.toReal(); + escapement[0] = 0; + escapement[1] = 0; vgSetGlyphToPath(font, glyph, vgPath, VG_FALSE, origin, escapement); vgDestroyPath(vgPath); // Reduce reference count. #endif // !defined(QVG_NO_IMAGE_GLYPHS) @@ -3287,12 +3276,10 @@ void QVGPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem) // Get the glyphs and positions associated with the text item. QVarLengthArray<QFixedPoint> positions; QVarLengthArray<glyph_t> glyphs; - QTransform matrix = d->transform; - matrix.translate(p.x(), p.y()); - ti.fontEngine->getGlyphPositions - (ti.glyphs, matrix, ti.flags, glyphs, positions); + QTransform matrix; + ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); - if (!drawCachedGlyphs(glyphs.size(), glyphs.data(), ti.font(), ti.fontEngine, p)) + if (!drawCachedGlyphs(glyphs.size(), glyphs.data(), ti.font(), ti.fontEngine, p, positions.data())) QPaintEngineEx::drawTextItem(p, textItem); #else // OpenGL 1.0 does not have support for VGFont and glyphs, @@ -3304,11 +3291,12 @@ void QVGPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem) void QVGPaintEngine::drawStaticTextItem(QStaticTextItem *textItem) { drawCachedGlyphs(textItem->numGlyphs, textItem->glyphs, textItem->font, textItem->fontEngine, - QPointF(0, 0)); + QPointF(0, 0), textItem->glyphPositions); } bool QVGPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, const QFont &font, - QFontEngine *fontEngine, const QPointF &p) + QFontEngine *fontEngine, const QPointF &p, + const QFixedPoint *positions) { #if !defined(QVG_NO_DRAW_GLYPHS) Q_D(QVGPaintEngine); @@ -3334,7 +3322,7 @@ void QVGPaintEngine::drawStaticTextItem(QStaticTextItem *textItem) } // Set the transformation to use for drawing the current glyphs. - QTransform glyphTransform(d->glyphTransform); + QTransform glyphTransform(d->pathTransform); glyphTransform.translate(p.x(), p.y()); #if defined(QVG_NO_IMAGE_GLYPHS) glyphTransform.scale(glyphCache->scaleX, glyphCache->scaleY); @@ -3344,10 +3332,18 @@ void QVGPaintEngine::drawStaticTextItem(QStaticTextItem *textItem) // Add the glyphs from the text item into the glyph cache. glyphCache->cacheGlyphs(d, fontEngine, glyphs, numGlyphs); + // Create the array of adjustments between glyphs + QVarLengthArray<VGfloat> adjustments_x(numGlyphs); + QVarLengthArray<VGfloat> adjustments_y(numGlyphs); + for (int i = 1; i < numGlyphs; ++i) { + adjustments_x[i-1] = (positions[i].x - positions[i-1].x).toReal(); + adjustments_y[i-1] = (positions[i].y - positions[i-1].y).toReal(); + } + // Set the glyph drawing origin. VGfloat origin[2]; - origin[0] = 0; - origin[1] = 0; + origin[0] = positions[0].x.toReal(); + origin[1] = positions[0].y.toReal(); vgSetfv(VG_GLYPH_ORIGIN, 2, origin); // Fast anti-aliasing for paths, better for images. @@ -3362,8 +3358,7 @@ void QVGPaintEngine::drawStaticTextItem(QStaticTextItem *textItem) // the Qt pen, not the Qt brush. d->ensureBrush(state()->pen.brush()); vgDrawGlyphs(glyphCache->font, numGlyphs, (VGuint*)glyphs, - NULL, NULL, VG_FILL_PATH, VG_TRUE); - + adjustments_x.data(), adjustments_y.data(), VG_FILL_PATH, VG_TRUE); return true; #else Q_UNUSED(numGlyphs); @@ -3371,6 +3366,7 @@ void QVGPaintEngine::drawStaticTextItem(QStaticTextItem *textItem) Q_UNUSED(font); Q_UNUSED(fontEngine); Q_UNUSED(p); + Q_UNUSED(positions); return false; #endif } diff --git a/src/openvg/qpaintengine_vg_p.h b/src/openvg/qpaintengine_vg_p.h index 1e7e26c..33c49ba 100644 --- a/src/openvg/qpaintengine_vg_p.h +++ b/src/openvg/qpaintengine_vg_p.h @@ -58,6 +58,7 @@ QT_BEGIN_NAMESPACE +class QFixedPoint; class QVGPaintEnginePrivate; class QPixmapData; class QVGEGLWindowSurfacePrivate; @@ -143,7 +144,8 @@ public: void drawTextItem(const QPointF &p, const QTextItem &textItem); void drawStaticTextItem(QStaticTextItem *staticTextItem); bool drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, const QFont &font, - QFontEngine *fontEngine, const QPointF &p); + QFontEngine *fontEngine, const QPointF &p, + const QFixedPoint *positions); void setState(QPainterState *s); QVGPainterState *state() { return static_cast<QVGPainterState *>(QPaintEngineEx::state()); } diff --git a/src/script/bridge/qscriptqobject_p.h b/src/script/bridge/qscriptqobject_p.h index b82bcb7..412a784 100644 --- a/src/script/bridge/qscriptqobject_p.h +++ b/src/script/bridge/qscriptqobject_p.h @@ -303,7 +303,7 @@ public: } protected: - static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::OverridesMarkChildren | JSC::OverridesGetPropertyNames | JSObject::StructureFlags; + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::OverridesMarkChildren | JSC::OverridesGetPropertyNames | JSC::ImplementsHasInstance | JSObject::StructureFlags; Data *data; }; diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/sqlite/qsql_sqlite.cpp index 24dcad9..4344af4 100644 --- a/src/sql/drivers/sqlite/qsql_sqlite.cpp +++ b/src/sql/drivers/sqlite/qsql_sqlite.cpp @@ -259,6 +259,7 @@ bool QSQLiteResultPrivate::fetchNext(QSqlCachedResult::ValueCache &values, int i q->setAt(QSql::AfterLastRow); sqlite3_reset(stmt); return false; + case SQLITE_CONSTRAINT: case SQLITE_ERROR: // SQLITE_ERROR is a generic error code and we must call sqlite3_reset() // to get the specific error message. diff --git a/src/testlib/qtestlogger.cpp b/src/testlib/qtestlogger.cpp index 6c76388..f0be6be 100644 --- a/src/testlib/qtestlogger.cpp +++ b/src/testlib/qtestlogger.cpp @@ -211,10 +211,7 @@ void QTestLogger::addIncident(IncidentTypes type, const char *description, QTest::qt_snprintf(buf, sizeof(buf), "%i", line); failureElement->addAttribute(QTest::AI_Line, buf); failureElement->addAttribute(QTest::AI_Description, description); - const char* tag = QTestResult::currentDataTag(); - if (tag) { - failureElement->addAttribute(QTest::AI_Tag, tag); - } + addTag(failureElement); currentLogElement->addLogElement(failureElement); } @@ -279,6 +276,27 @@ void QTestLogger::addBenchmarkResult(const QBenchmarkResult &result) currentLogElement->addLogElement(benchmarkElement); } +void QTestLogger::addTag(QTestElement* element) +{ + const char *tag = QTestResult::currentDataTag(); + const char *gtag = QTestResult::currentGlobalDataTag(); + const char *filler = (tag && gtag) ? ":" : ""; + if ((!tag || !tag[0]) && (!gtag || !gtag[0])) { + return; + } + + if (!tag) { + tag = ""; + } + if (!gtag) { + gtag = ""; + } + + QTestCharBuffer buf; + QTest::qt_asprintf(&buf, "%s%s%s", gtag, filler, tag); + element->addAttribute(QTest::AI_Tag, buf.constData()); +} + void QTestLogger::addMessage(MessageTypes type, const char *message, const char *file, int line) { QTestElement *errorElement = new QTestElement(QTest::LET_Error); @@ -299,7 +317,7 @@ void QTestLogger::addMessage(MessageTypes type, const char *message, const char break; case QAbstractTestLogger::QWarning: ++qwarnCounter; - typeBuf = "qwarning"; + typeBuf = "qwarn"; break; case QAbstractTestLogger::QFatal: ++qfatalCounter; @@ -320,6 +338,7 @@ void QTestLogger::addMessage(MessageTypes type, const char *message, const char errorElement->addAttribute(QTest::AI_Type, typeBuf); errorElement->addAttribute(QTest::AI_Description, message); + addTag(errorElement); if(file) errorElement->addAttribute(QTest::AI_File, file); diff --git a/src/testlib/qtestlogger_p.h b/src/testlib/qtestlogger_p.h index 31f7d55..bb7a358 100644 --- a/src/testlib/qtestlogger_p.h +++ b/src/testlib/qtestlogger_p.h @@ -83,6 +83,7 @@ class QTestLogger : public QAbstractTestLogger void addIncident(IncidentTypes type, const char *description, const char *file = 0, int line = 0); void addBenchmarkResult(const QBenchmarkResult &result); + void addTag(QTestElement* element); void addMessage(MessageTypes type, const char *message, const char *file = 0, int line = 0); diff --git a/src/testlib/qtestxmlstreamer.cpp b/src/testlib/qtestxmlstreamer.cpp index b9946e5..f63c221 100644 --- a/src/testlib/qtestxmlstreamer.cpp +++ b/src/testlib/qtestxmlstreamer.cpp @@ -111,12 +111,20 @@ void QTestXmlStreamer::formatStart(const QTestElement *element, QTestCharBuffer QXmlTestLogger::xmlQuote("edFile, element->attributeValue(QTest::AI_File)); QXmlTestLogger::xmlCdata(&cdataDesc, element->attributeValue(QTest::AI_Description)); - QTest::qt_asprintf(formatted, "<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n <Description><![CDATA[%s]]></Description>\n</Message>\n", + QTestCharBuffer tagbuf; + if (element->attribute(QTest::AI_Tag)) { + QTestCharBuffer cdataTag; + QXmlTestLogger::xmlCdata(&cdataTag, element->attributeValue(QTest::AI_Tag)); + QTest::qt_asprintf(&tagbuf, " <DataTag><![CDATA[%s]]></DataTag>\n", cdataTag.constData()); + } + + QTest::qt_asprintf(formatted, "<Message type=\"%s\" %s=\"%s\" %s=\"%s\">\n%s <Description><![CDATA[%s]]></Description>\n</Message>\n", element->attributeValue(QTest::AI_Type), element->attributeName(QTest::AI_File), quotedFile.constData(), element->attributeName(QTest::AI_Line), element->attributeValue(QTest::AI_Line), + tagbuf.constData(), cdataDesc.constData()); break; } @@ -149,7 +157,29 @@ void QTestXmlStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *f return; if (element->elementType() == QTest::LET_TestCase) { - QTest::qt_asprintf(formatted, "</TestFunction>\n"); + bool failed = false; + for (QTestElement* child = element->childElements(); child; child = child->nextElement()) { + if ( child->elementType() == QTest::LET_Failure + && child->attribute(QTest::AI_Result) + && ( !strcmp(child->attributeValue(QTest::AI_Result), "fail") + || !strcmp(child->attributeValue(QTest::AI_Result), "xpass")) + ) + { + failed = true; + break; + } + } + + // For passing functions, no Incident has been output yet. + // For failing functions, we already output one. + // Please note: we are outputting "pass" even if there was an xfail etc. + // This is by design (arguably bad design, but dangerous to change now!) + if (element->attribute(QTest::AI_Result) && !failed) { + QTest::qt_asprintf(formatted, "<Incident type=\"pass\" file=\"\" line=\"0\" />\n</TestFunction>\n"); + } + else { + QTest::qt_asprintf(formatted, "</TestFunction>\n"); + } } else { formatted->data()[0] = '\0'; } @@ -157,29 +187,11 @@ void QTestXmlStreamer::formatEnd(const QTestElement *element, QTestCharBuffer *f void QTestXmlStreamer::formatBeforeAttributes(const QTestElement *element, QTestCharBuffer *formatted) const { - if(!element || !formatted) + Q_UNUSED(element); + if (!formatted) return; - if (element->elementType() == QTest::LET_TestCase && element->attribute(QTest::AI_Result)){ - QTestCharBuffer buf; - QTestCharBuffer quotedFile; - QXmlTestLogger::xmlQuote("edFile, element->attributeValue(QTest::AI_File)); - - QTest::qt_asprintf(&buf, "%s=\"%s\" %s=\"%s\"", - element->attributeName(QTest::AI_File), - quotedFile.constData(), - element->attributeName(QTest::AI_Line), - element->attributeValue(QTest::AI_Line)); - - if( !element->childElements() ) { - QTest::qt_asprintf(formatted, "<Incident type=\"%s\" %s/>\n", - element->attributeValue(QTest::AI_Result), buf.constData()); - } else { - formatted->data()[0] = '\0'; - } - } else { - formatted->data()[0] = '\0'; - } + formatted->data()[0] = '\0'; } void QTestXmlStreamer::output(QTestElement *element) const diff --git a/src/testlib/qxmltestlogger.cpp b/src/testlib/qxmltestlogger.cpp index 2236666..07e8ef0 100644 --- a/src/testlib/qxmltestlogger.cpp +++ b/src/testlib/qxmltestlogger.cpp @@ -244,7 +244,7 @@ void QXmlTestLogger::addBenchmarkResult(const QBenchmarkResult &result) QTestCharBuffer quotedTag; xmlQuote("edMetric, - benchmarkMetricUnit(result.metric)); + benchmarkMetricName(result.metric)); xmlQuote("edTag, result.context.tag.toAscii().constData()); QTest::qt_asprintf( diff --git a/src/xmlpatterns/schema/qxsdschemaresolver.cpp b/src/xmlpatterns/schema/qxsdschemaresolver.cpp index 34eb12c..f3d1ed0 100644 --- a/src/xmlpatterns/schema/qxsdschemaresolver.cpp +++ b/src/xmlpatterns/schema/qxsdschemaresolver.cpp @@ -632,7 +632,14 @@ void XsdSchemaResolver::resolveSimpleContentComplexTypes(const XsdComplexType::P } else { // 1.2 const XsdSimpleType::Ptr anonType(new XsdSimpleType()); - anonType->setCategory(complexBaseType->contentType()->simpleType()->category()); + XsdSimpleType::TypeCategory baseCategory = complexBaseType->contentType()->simpleType()->category(); + anonType->setCategory(baseCategory); + + if (baseCategory == XsdSimpleType::SimpleTypeList) { + const XsdSimpleType::Ptr baseSimpleType = complexBaseType->contentType()->simpleType(); + anonType->setItemType(baseSimpleType->itemType()); + } + anonType->setDerivationMethod(XsdSimpleType::DerivationRestriction); anonType->setWxsSuperType(complexBaseType->contentType()->simpleType()); anonType->setFacets(complexTypeFacets(complexType)); diff --git a/src/xmlpatterns/xmlpatterns.pro b/src/xmlpatterns/xmlpatterns.pro index a224762..e50d184 100644 --- a/src/xmlpatterns/xmlpatterns.pro +++ b/src/xmlpatterns/xmlpatterns.pro @@ -24,13 +24,14 @@ include($$PWD/schema/schema.pri) include($$PWD/type/type.pri) include($$PWD/utils/utils.pri) include($$PWD/qobjectmodel/qobjectmodel.pri, "", true) -wince*:# The Microsoft MIPS compiler crashes if /Og is specified -: -# -O2/1 expands to /Og plus additional arguments. -contains(DEFINES, MIPS): { - QMAKE_CXXFLAGS_RELEASE ~= s/-O2/-Oi -Ot -Oy -Ob2/ - QMAKE_CXXFLAGS_RELEASE ~= s/-O1/-Os -Oy -Ob2/ +wince* { + # The Microsoft MIPS compiler crashes if /Og is specified. + # -O2/1 expands to /Og plus additional arguments. + contains(DEFINES, MIPS) { + QMAKE_CXXFLAGS_RELEASE ~= s/-O2/-Oi -Ot -Oy -Ob2/ + QMAKE_CXXFLAGS_RELEASE ~= s/-O1/-Os -Oy -Ob2/ + } } + symbian:TARGET.UID3 = 0x2001E62B -HEADERS += |