diff options
Diffstat (limited to 'src')
29 files changed, 376 insertions, 269 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/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/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index c9a79eb..5f7813b 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -991,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/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index c30814b..a0429d3 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -1123,15 +1123,6 @@ 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 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/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 6f05908..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 *** }; @@ -2429,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) @@ -2490,6 +2494,12 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, 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 @@ -2570,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; 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 e557f56..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,7 +220,7 @@ 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); @@ -339,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) @@ -350,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/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 260110e..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,8 +147,7 @@ void QAudioInputPrivate::freeBlocks(WAVEHDR* blockArray) int count = buffer_size/period_size; for(int i = 0; i < count; i++) { - if (blocks->dwFlags & WHDR_PREPARED) - waveInUnprepareHeader(hWaveIn,blocks, sizeof(WAVEHDR)); + waveInUnprepareHeader(hWaveIn,blocks, sizeof(WAVEHDR)); blocks+=sizeof(WAVEHDR); } HeapFree(GetProcessHeap(), 0, blockArray); @@ -284,9 +274,9 @@ bool QAudioInputPrivate::open() return false; } - EnterCriticalSection(&waveInCriticalSection); + mutex.lock(); waveFreeBlockCount = buffer_size/period_size; - LeaveCriticalSection(&waveInCriticalSection); + mutex.unlock(); waveCurrentBlock = 0; @@ -330,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 @@ -407,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)); @@ -417,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++; @@ -436,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; @@ -444,7 +437,7 @@ qint64 QAudioInputPrivate::read(char* data, qint64 len) if(waveFreeBlockCount == buffer_size/period_size) done = true; } - LeaveCriticalSection(&waveInCriticalSection); + mutex.unlock(); written+=l; } @@ -468,9 +461,10 @@ void QAudioInputPrivate::resume() return; } } - EnterCriticalSection(&waveInCriticalSection); + + mutex.lock(); waveFreeBlockCount = buffer_size/period_size; - LeaveCriticalSection(&waveInCriticalSection); + mutex.unlock(); waveCurrentBlock = 0; header = 0; @@ -498,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 @@ -535,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"; @@ -559,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 afae8b7..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) { @@ -573,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 @@ -718,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 ced8c32..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,8 +145,7 @@ void QAudioOutputPrivate::freeBlocks(WAVEHDR* blockArray) int count = buffer_size/period_size; for(int i = 0; i < count; i++) { - if (blocks->dwFlags & WHDR_PREPARED) - waveOutUnprepareHeader(hWaveOut,blocks, sizeof(WAVEHDR)); + waveOutUnprepareHeader(hWaveOut,blocks, sizeof(WAVEHDR)); blocks+=sizeof(WAVEHDR); } HeapFree(GetProcessHeap(), 0, blockArray); @@ -226,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; @@ -334,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 @@ -369,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)); @@ -391,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; @@ -454,7 +443,7 @@ void QAudioOutputPrivate::feedback() bool QAudioOutputPrivate::deviceReady() { - if(deviceState == QAudio::StoppedState) + if(deviceState == QAudio::StoppedState || deviceState == QAudio::SuspendedState) return false; if(pullMode) { @@ -468,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(); @@ -505,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); } @@ -522,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/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 57d995a..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(); 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 07a5bf3..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); 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/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)); |