From 3e5d7444b883778663d1e31e54afffae65921da3 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 13 Jul 2009 17:45:53 +0200 Subject: Updated WebKit from /home/shausman/src/webkit/trunk to origin/qtwebkit-4.5 ( a3e05ad8acdead3b534d0cef772b85f002e80b8d ) Changes in WebKit since the last update: ++ b/LayoutTests/ChangeLog 2009-06-18 Chris Evans Reviewed by Adam Barth. Added test for bug 26454 (broken 8-digit hex entities). https://bugs.webkit.org/show_bug.cgi?id=26454 * fast/parser/eightdigithexentity-expected.txt: Added. * fast/parser/eightdigithexentity.html: Added. 2009-06-20 Sam Weinig Reviewed by Adam Barth. Test for https://bugs.webkit.org/show_bug.cgi?id=26554 Test writing to parent and top. * http/tests/security/cross-frame-access-put-expected.txt: * http/tests/security/cross-frame-access-put.html: * http/tests/security/resources/cross-frame-iframe-for-put-test.html: ++ b/WebCore/ChangeLog 2009-06-18 Chris Evans Reviewed by Adam Barth. Fix 8-digit long hex entities. Fixes bug 26454 https://bugs.webkit.org/show_bug.cgi?id=26454 Test: fast/parser/eightdigithexentity.html * html/HTMLTokenizer.cpp: fix off-by-ones. 2009-06-20 Sam Weinig Reviewed by Adam Barth. Fix for https://bugs.webkit.org/show_bug.cgi?id=26554 Shadowing of top and parent * page/DOMWindow.idl: --- src/3rdparty/webkit/VERSION | 4 ++-- src/3rdparty/webkit/WebCore/ChangeLog | 20 ++++++++++++++++++++ .../webkit/WebCore/generated/JSDOMWindow.cpp | 4 ++++ src/3rdparty/webkit/WebCore/html/HTMLTokenizer.cpp | 8 ++++++-- src/3rdparty/webkit/WebCore/page/DOMWindow.idl | 4 ++-- 5 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 368d2b5..88f32d9 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -1,6 +1,6 @@ This is a snapshot of the Qt port of WebKit from - git://code.staikos.net/webkit + git://gitorious.org/qtwebkit/qtwebkit.git The commit imported was from the @@ -8,4 +8,4 @@ The commit imported was from the and has the sha1 checksum - eb4957a561d3f85d4cd5602832375c66f378b521 + a3e05ad8acdead3b534d0cef772b85f002e80b8d diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index be6922f..19bb36a 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,23 @@ +2009-06-18 Chris Evans + + Reviewed by Adam Barth. + + Fix 8-digit long hex entities. Fixes bug 26454 + https://bugs.webkit.org/show_bug.cgi?id=26454 + + Test: fast/parser/eightdigithexentity.html + + * html/HTMLTokenizer.cpp: fix off-by-ones. + +2009-06-20 Sam Weinig + + Reviewed by Adam Barth. + + Fix for https://bugs.webkit.org/show_bug.cgi?id=26554 + Shadowing of top and parent + + * page/DOMWindow.idl: + 2008-12-18 Bernhard Rosenkraenzer Reviewed by Darin Adler. diff --git a/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.cpp b/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.cpp index c6906b6..d692150 100644 --- a/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.cpp +++ b/src/3rdparty/webkit/WebCore/generated/JSDOMWindow.cpp @@ -2496,11 +2496,15 @@ void setJSDOMWindowOpener(ExecState* exec, JSObject* thisObject, JSValuePtr valu void setJSDOMWindowParent(ExecState* exec, JSObject* thisObject, JSValuePtr value) { + if (!static_cast(thisObject)->allowsAccessFrom(exec)) + return; static_cast(thisObject)->putDirect(Identifier(exec, "parent"), value); } void setJSDOMWindowTop(ExecState* exec, JSObject* thisObject, JSValuePtr value) { + if (!static_cast(thisObject)->allowsAccessFrom(exec)) + return; static_cast(thisObject)->putDirect(Identifier(exec, "top"), value); } diff --git a/src/3rdparty/webkit/WebCore/html/HTMLTokenizer.cpp b/src/3rdparty/webkit/WebCore/html/HTMLTokenizer.cpp index 6de9951..b6a5418 100644 --- a/src/3rdparty/webkit/WebCore/html/HTMLTokenizer.cpp +++ b/src/3rdparty/webkit/WebCore/html/HTMLTokenizer.cpp @@ -867,7 +867,9 @@ HTMLTokenizer::State HTMLTokenizer::parseEntity(SegmentedString& src, UChar*& de } } else { // FIXME: We should eventually colorize entities by sending them as a special token. - checkBuffer(11); + // 12 bytes required: up to 10 bytes in m_cBuffer plus the + // leading '&' and trailing ';' + checkBuffer(12); *dest++ = '&'; for (unsigned i = 0; i < cBufferPos; i++) dest[i] = m_cBuffer[i]; @@ -878,7 +880,9 @@ HTMLTokenizer::State HTMLTokenizer::parseEntity(SegmentedString& src, UChar*& de } } } else { - checkBuffer(10); + // 11 bytes required: up to 10 bytes in m_cBuffer plus the + // leading '&' + checkBuffer(11); // ignore the sequence, add it to the buffer as plaintext *dest++ = '&'; for (unsigned i = 0; i < cBufferPos; i++) diff --git a/src/3rdparty/webkit/WebCore/page/DOMWindow.idl b/src/3rdparty/webkit/WebCore/page/DOMWindow.idl index d0114e6..71c3137 100644 --- a/src/3rdparty/webkit/WebCore/page/DOMWindow.idl +++ b/src/3rdparty/webkit/WebCore/page/DOMWindow.idl @@ -121,8 +121,8 @@ module window { attribute [Replaceable, DoNotCheckDomainSecurityOnGet] DOMWindow frames; attribute [Replaceable, DoNotCheckDomainSecurityOnGet] DOMWindow opener; - attribute [Replaceable, DoNotCheckDomainSecurity] DOMWindow parent; - attribute [Replaceable, DoNotCheckDomainSecurity] DOMWindow top; + attribute [Replaceable, DoNotCheckDomainSecurityOnGet] DOMWindow parent; + attribute [Replaceable, DoNotCheckDomainSecurityOnGet] DOMWindow top; // DOM Level 2 AbstractView Interface readonly attribute Document document; -- cgit v0.12 From 46df9f83cb64541f7d9ecd34645ef1558ce1c0c6 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Mon, 13 Jul 2009 17:53:34 +0200 Subject: Fixed a potential memory leak on XP Calling OpenThemeData directly causes a leak when changing the style as we do not call the corresponding CloseThemeData. Task-number:257916 Reviewed-by:prasanth --- src/gui/styles/qwindowsxpstyle.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp index 2abf3bc..1b8ceae 100644 --- a/src/gui/styles/qwindowsxpstyle.cpp +++ b/src/gui/styles/qwindowsxpstyle.cpp @@ -1202,7 +1202,8 @@ QRect QWindowsXPStyle::subElementRect(SubElement sr, const QStyleOption *option, if (const QStyleOptionButton *btn = qstyleoption_cast(option)) { MARGINS borderSize; if (widget) { - HTHEME theme = pOpenThemeData(QWindowsXPStylePrivate::winId(widget), L"Button"); + XPThemeData buttontheme(widget, 0, QLatin1String("Button")); + HTHEME theme = buttontheme.handle(); if (theme) { int stateId; if (!(option->state & State_Enabled)) @@ -3611,7 +3612,8 @@ QSize QWindowsXPStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt case CT_LineEdit: case CT_ComboBox: { - HTHEME theme = pOpenThemeData(QWindowsXPStylePrivate::winId(widget), L"Button"); + XPThemeData buttontheme(widget, 0, QLatin1String("Button")); + HTHEME theme = buttontheme.handle(); MARGINS borderSize; if (theme) { int result = pGetThemeMargins(theme, -- cgit v0.12 From 8e186f42278c7033a2df08f4a986419087457efc Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 13 Jul 2009 11:42:07 -0700 Subject: Clean up QDirectFBPaintEngine code - Remove unnecessary copy of QTransform - Fold matrixRotShear and scale into transformationFlags. Note that transformationFlags is not a proper bitset of the types of transform but rather set to the most complex operation (from QTransform::type()) and having NegativeScale added if qMin(transform.m11(), transform.m22()) < 0 - Fix a bug whereby setState didn't call setRenderHints - Make everything more readable - Don't initialize state in QDirectFBPaintEngine::begin() QDirectFBPaintEngine::setState will be called from QPainter::begin just before QDirectFBPaintEngine::begin Reviewed-by: Donald --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 137 +++++++++++---------- 1 file changed, 71 insertions(+), 66 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 27df0da..db08240 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -80,7 +80,7 @@ template inline const T *ptr(const T &t) { return &t; } template <> inline const bool* ptr(const bool &) { return 0; } template static void rasterFallbackWarn(const char *msg, const char *func, const device *dev, - int scale, bool matrixRotShear, bool simplePen, + uint transformationType, bool simplePen, bool dfbHandledClip, bool unsupportedCompositionMode, const char *nameOne, const T1 &one, const char *nameTwo, const T2 &two, @@ -95,8 +95,7 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device * dbg << dev << "of type" << dev->devType(); } - dbg << "scale" << scale - << "matrixRotShear" << matrixRotShear + dbg << QString("transformationType 0x%1").arg(transformationType, 3, 16, QLatin1Char('0')) << "simplePen" << simplePen << "dfbHandledClip" << dfbHandledClip << "unsupportedCompositionMode" << unsupportedCompositionMode; @@ -123,9 +122,10 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device * if (op & (QT_DIRECTFB_WARN_ON_RASTERFALLBACKS)) \ rasterFallbackWarn("Disabled raster engine operation", \ __FUNCTION__, state()->painter->device(), \ - d_func()->scale, d_func()->matrixRotShear, \ - d_func()->simplePen, d_func()->dfbCanHandleClip(), \ - d_func()->unsupportedCompositionMode, \ + d_func()->transformationType, \ + d_func()->simplePen, \ + d_func()->dfbCanHandleClip(), \ + d_func()->unsupportedCompositionMode, \ #one, one, #two, two, #three, three); \ if (op & (QT_DIRECTFB_DISABLE_RASTERFALLBACKS)) \ return; @@ -138,9 +138,10 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device * if (op & (QT_DIRECTFB_WARN_ON_RASTERFALLBACKS)) \ rasterFallbackWarn("Falling back to raster engine for", \ __FUNCTION__, state()->painter->device(), \ - d_func()->scale, d_func()->matrixRotShear, \ - d_func()->simplePen, d_func()->dfbCanHandleClip(), \ - d_func()->unsupportedCompositionMode, \ + d_func()->transformationType, \ + d_func()->simplePen, \ + d_func()->dfbCanHandleClip(), \ + d_func()->unsupportedCompositionMode, \ #one, one, #two, two, #three, three); #else #define RASTERFALLBACK(op, one, two, three) @@ -211,16 +212,19 @@ static QCache imageCache(4*1024*1024); // 4 MB class QDirectFBPaintEnginePrivate : public QRasterPaintEnginePrivate { public: - enum Scale { NoScale, Scaled, NegativeScale }; - + enum TransformationTypeFlags { + NegativeScale = 0x100, + RectsUnsupported = (QTransform::TxRotate|QTransform::TxShear|QTransform::TxProject), + BlitUnsupported = (NegativeScale|RectsUnsupported) + }; QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p); ~QDirectFBPaintEnginePrivate(); - void setTransform(const QTransform &m); - void setPen(const QPen &pen); + inline void setTransform(const QTransform &transforma); + inline void setPen(const QPen &pen); inline void setCompositionMode(QPainter::CompositionMode mode); inline void setOpacity(quint8 value); - void setRenderHints(QPainter::RenderHints hints); + inline void setRenderHints(QPainter::RenderHints hints); inline void setDFBColor(const QColor &color); @@ -263,11 +267,9 @@ private: bool simplePen; - bool matrixRotShear; - Scale scale; + uint transformationType; // this is QTransform::type() + NegativeScale if qMin(transform.m11(), transform.m22()) < 0 SurfaceCache *surfaceCache; - QTransform transform; int lastLockedHeight; IDirectFB *fb; @@ -288,6 +290,7 @@ private: friend class QDirectFBPaintEngine; }; + QDirectFBPaintEngine::QDirectFBPaintEngine(QPaintDevice *device) : QRasterPaintEngine(*(new QDirectFBPaintEnginePrivate(this)), device) { @@ -318,21 +321,11 @@ bool QDirectFBPaintEngine::begin(QPaintDevice *device) device->devType()); } d->lockedMemory = 0; - d->surface->GetSize(d->surface, &d->fbWidth, &d->fbHeight); - d->setTransform(QTransform()); - d->antialiased = false; - d->setOpacity(255); - d->setCompositionMode(state()->compositionMode()); - d->dirtyClip = true; - d->setPen(state()->pen); - const bool status = QRasterPaintEngine::begin(device); - // XXX: QRasterPaintEngine::begin() resets the capabilities gccaps |= PorterDuff; - return status; } @@ -389,30 +382,27 @@ void QDirectFBPaintEngine::renderHintsChanged() void QDirectFBPaintEngine::transformChanged() { Q_D(QDirectFBPaintEngine); - const QDirectFBPaintEnginePrivate::Scale old = d->scale; - d->setTransform(state()->transform()); - if (d->scale != old) { - d->setPen(state()->pen); - } + d->setTransform(state()->matrix); QRasterPaintEngine::transformChanged(); } -void QDirectFBPaintEngine::setState(QPainterState *s) +void QDirectFBPaintEngine::setState(QPainterState *state) { Q_D(QDirectFBPaintEngine); - QRasterPaintEngine::setState(s); + QRasterPaintEngine::setState(state); d->dirtyClip = true; - d->setPen(state()->pen); - d->setOpacity(quint8(state()->opacity * 255)); - d->setCompositionMode(state()->compositionMode()); - d->setTransform(state()->transform()); + d->setPen(state->pen); + d->setOpacity(quint8(state->opacity * 255)); + d->setCompositionMode(state->compositionMode()); + d->setTransform(state->transform()); + d->setRenderHints(state->renderHints); } void QDirectFBPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) { Q_D(QDirectFBPaintEngine); d->dirtyClip = true; - const QPoint bottom = d->transform.map(QPoint(0, int(path.controlPointRect().y2))); + const QPoint bottom = state()->matrix.map(QPoint(0, int(path.controlPointRect().y2))); if (bottom.y() > d->lastLockedHeight) d->lock(); QRasterPaintEngine::clip(path, op); @@ -423,7 +413,7 @@ void QDirectFBPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) Q_D(QDirectFBPaintEngine); d->dirtyClip = true; if (d->clip() && !d->clip()->hasRectClip && d->clip()->enabled) { - const QPoint bottom = d->transform.map(QPoint(0, rect.bottom())); + const QPoint bottom = state()->matrix.map(QPoint(0, rect.bottom())); if (bottom.y() > d->lastLockedHeight) d->lock(); } @@ -436,8 +426,11 @@ void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount) Q_D(QDirectFBPaintEngine); d->updateClip(); const QBrush &brush = state()->brush; - if (d->unsupportedCompositionMode || !d->dfbCanHandleClip() || d->matrixRotShear - || !d->simplePen || !d->isSimpleBrush(brush)) { + if (d->unsupportedCompositionMode + || (d->transformationType & QDirectFBPaintEnginePrivate::RectsUnsupported) + || !d->simplePen + || !d->dfbCanHandleClip() + || !d->isSimpleBrush(brush)) { RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawRects(rects, rectCount); @@ -461,8 +454,11 @@ void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount) Q_D(QDirectFBPaintEngine); d->updateClip(); const QBrush &brush = state()->brush; - if (d->unsupportedCompositionMode || !d->dfbCanHandleClip() || d->matrixRotShear - || !d->simplePen || !d->isSimpleBrush(brush)) { + if (d->unsupportedCompositionMode + || (d->transformationType & QDirectFBPaintEnginePrivate::RectsUnsupported) + || !d->simplePen + || !d->dfbCanHandleClip() + || !d->isSimpleBrush(brush)) { RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawRects(rects, rectCount); @@ -544,8 +540,7 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image, d->updateClip(); #if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE if (d->unsupportedCompositionMode - || d->matrixRotShear - || d->scale == QDirectFBPaintEnginePrivate::NegativeScale + || (d->transformationType & QDirectFBPaintEnginePrivate::BlitUnsupported) || !d->dfbCanHandleClip(r) #ifndef QT_DIRECTFB_IMAGECACHE || QDirectFBScreen::getSurfacePixelFormat(image.format()) == DSPF_UNKNOWN @@ -590,8 +585,9 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); d->lock(); QRasterPaintEngine::drawPixmap(r, pixmap, sr); - } else if (d->unsupportedCompositionMode || !d->dfbCanHandleClip(r) || d->matrixRotShear - || d->scale == QDirectFBPaintEnginePrivate::NegativeScale) { + } else if (d->unsupportedCompositionMode + || (d->transformationType & QDirectFBPaintEnginePrivate::BlitUnsupported) + || !d->dfbCanHandleClip(r)) { RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr); const QImage *img = static_cast(pixmap.pixmapData())->buffer(DSLF_READ); d->lock(); @@ -623,8 +619,9 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r, RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), offset); d->lock(); QRasterPaintEngine::drawTiledPixmap(r, pixmap, offset); - } else if (d->unsupportedCompositionMode || !d->dfbCanHandleClip(r) || d->matrixRotShear - || d->scale == QDirectFBPaintEnginePrivate::NegativeScale) { + } else if (d->unsupportedCompositionMode + || (d->transformationType & QDirectFBPaintEnginePrivate::BlitUnsupported) + || !d->dfbCanHandleClip(r)) { RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), offset); const QImage *img = static_cast(pixmap.pixmapData())->buffer(DSLF_READ); d->lock(); @@ -719,7 +716,9 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) { Q_D(QDirectFBPaintEngine); d->updateClip(); - if (!d->unsupportedCompositionMode && d->dfbCanHandleClip(rect) && !d->matrixRotShear) { + if (!d->unsupportedCompositionMode + && !(d->transformationType & (QDirectFBPaintEnginePrivate::RectsUnsupported)) + && d->dfbCanHandleClip(rect)) { switch (brush.style()) { case Qt::SolidPattern: { const QColor color = brush.color(); @@ -727,12 +726,12 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) return; d->unlock(); d->setDFBColor(color); - const QRect r = d->transform.mapRect(rect).toRect(); + const QRect r = state()->matrix.mapRect(rect).toRect(); d->surface->FillRectangle(d->surface, r.x(), r.y(), r.width(), r.height()); return; } case Qt::TexturePattern: { - if (d->scale == QDirectFBPaintEnginePrivate::NegativeScale) + if (d->transformationType & QDirectFBPaintEnginePrivate::NegativeScale) break; const QPixmap texture = brush.texture(); @@ -757,14 +756,16 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color) return; Q_D(QDirectFBPaintEngine); d->updateClip(); - if (d->unsupportedCompositionMode || !d->dfbCanHandleClip() || d->matrixRotShear) { + if (d->unsupportedCompositionMode + || (d->transformationType & QDirectFBPaintEnginePrivate::RectsUnsupported) + || !d->dfbCanHandleClip()) { RASTERFALLBACK(FILL_RECT, rect, color, VOID_ARG()); d->lock(); QRasterPaintEngine::fillRect(rect, color); } else { d->unlock(); d->setDFBColor(color); - const QRect r = d->transform.mapRect(rect).toRect(); + const QRect r = state()->matrix.mapRect(rect).toRect(); d->surface->FillRectangle(d->surface, r.x(), r.y(), r.width(), r.height()); } @@ -835,7 +836,7 @@ void QDirectFBPaintEngine::initImageCache(int size) QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p) : surface(0), antialiased(false), simplePen(false), - matrixRotShear(false), scale(NoScale), lastLockedHeight(-1), + transformationType(0), lastLockedHeight(-1), fbWidth(-1), fbHeight(-1), opacity(255), dirtyClip(true), dfbHandledClip(false), dfbDevice(0), lockedMemory(0), unsupportedCompositionMode(false), q(p) @@ -894,17 +895,13 @@ void QDirectFBPaintEnginePrivate::unlock() lockedMemory = 0; } -void QDirectFBPaintEnginePrivate::setTransform(const QTransform &m) +void QDirectFBPaintEnginePrivate::setTransform(const QTransform &transform) { - transform = m; - matrixRotShear = (transform.m12() != 0 || transform.m21() != 0); + transformationType = transform.type(); if (qMin(transform.m11(), transform.m22()) < 0) { - scale = NegativeScale; - } else if (transform.m11() != 1 || transform.m22() != 1) { - scale = Scaled; - } else { - scale = NoScale; + transformationType |= QDirectFBPaintEnginePrivate::NegativeScale; } + setPen(q->state()->pen); } void QDirectFBPaintEnginePrivate::setPen(const QPen &p) @@ -916,7 +913,7 @@ void QDirectFBPaintEnginePrivate::setPen(const QPen &p) && !antialiased && pen.brush().style() == Qt::SolidPattern && pen.widthF() <= 1.0 - && (scale == NoScale || pen.isCosmetic())) { + && (transformationType < QTransform::TxScale || pen.isCosmetic())) { simplePen = true; } else { simplePen = false; @@ -965,6 +962,7 @@ void QDirectFBPaintEnginePrivate::setDFBColor(const QColor &color) void QDirectFBPaintEnginePrivate::drawLines(const QLine *lines, int n) { + const QTransform &transform = q->state()->matrix; for (int i = 0; i < n; ++i) { const QLine l = transform.map(lines[i]); surface->DrawLine(surface, l.x1(), l.y1(), l.x2(), l.y2()); @@ -973,6 +971,7 @@ void QDirectFBPaintEnginePrivate::drawLines(const QLine *lines, int n) void QDirectFBPaintEnginePrivate::drawLines(const QLineF *lines, int n) { + const QTransform &transform = q->state()->matrix; for (int i = 0; i < n; ++i) { const QLine l = transform.map(lines[i]).toLine(); surface->DrawLine(surface, l.x1(), l.y1(), l.x2(), l.y2()); @@ -990,6 +989,7 @@ void QDirectFBPaintEnginePrivate::fillRegion(const QRegion ®ion) void QDirectFBPaintEnginePrivate::fillRects(const QRect *rects, int n) { + const QTransform &transform = q->state()->matrix; for (int i = 0; i < n; ++i) { const QRect r = transform.mapRect(rects[i]); surface->FillRectangle(surface, r.x(), r.y(), @@ -999,6 +999,7 @@ void QDirectFBPaintEnginePrivate::fillRects(const QRect *rects, int n) void QDirectFBPaintEnginePrivate::fillRects(const QRectF *rects, int n) { + const QTransform &transform = q->state()->matrix; for (int i = 0; i < n; ++i) { const QRect r = transform.mapRect(rects[i]).toRect(); surface->FillRectangle(surface, r.x(), r.y(), @@ -1008,6 +1009,7 @@ void QDirectFBPaintEnginePrivate::fillRects(const QRectF *rects, int n) void QDirectFBPaintEnginePrivate::drawRects(const QRect *rects, int n) { + const QTransform &transform = q->state()->matrix; for (int i = 0; i < n; ++i) { const QRect r = transform.mapRect(rects[i]); surface->DrawRectangle(surface, r.x(), r.y(), @@ -1017,6 +1019,7 @@ void QDirectFBPaintEnginePrivate::drawRects(const QRect *rects, int n) void QDirectFBPaintEnginePrivate::drawRects(const QRectF *rects, int n) { + const QTransform &transform = q->state()->matrix; for (int i = 0; i < n; ++i) { const QRect r = transform.mapRect(rects[i]).toRect(); surface->DrawRectangle(surface, r.x(), r.y(), @@ -1062,7 +1065,7 @@ IDirectFBSurface *QDirectFBPaintEnginePrivate::getSurface(const QImage &img, boo void QDirectFBPaintEnginePrivate::blit(const QRectF &dest, IDirectFBSurface *s, const QRectF &src) { const QRect sr = src.toRect(); - const QRect dr = transform.mapRect(dest).toRect(); + const QRect dr = q->state()->matrix.mapRect(dest).toRect(); if (dr.isEmpty()) return; const DFBRectangle sRect = { sr.x(), sr.y(), sr.width(), sr.height() }; @@ -1091,6 +1094,8 @@ static inline qreal fixCoord(qreal rect_pos, qreal pixmapSize, qreal offset) void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap, const QPointF &off) { Q_ASSERT(!dirtyClip); + Q_ASSERT(!(transformationType & BlitUnsupported)); + const QTransform &transform = q->state()->matrix; const QRect destinationRect = transform.mapRect(dest).toRect().normalized(); QRect newClip = destinationRect; if (!currentClip.isEmpty()) -- cgit v0.12 From 74c95015686ad5576b53fef5f653442ea2c4053a Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 13 Jul 2009 12:50:34 -0700 Subject: Code cleanup in QDirectFBPaintEngine Take out the QPen member. Reviewed-by: Donald --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index db08240..eda83b2 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -261,10 +261,7 @@ public: private: IDirectFBSurface *surface; - QPen pen; - bool antialiased; - bool simplePen; uint transformationType; // this is QTransform::type() + NegativeScale if qMin(transform.m11(), transform.m22()) < 0 @@ -443,8 +440,9 @@ void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount) d->setDFBColor(brush.color()); d->fillRects(rects, rectCount); } - if (d->pen != Qt::NoPen) { - d->setDFBColor(d->pen.color()); + const QPen &pen = state()->pen; + if (pen != Qt::NoPen) { + d->setDFBColor(pen.color()); d->drawRects(rects, rectCount); } } @@ -471,8 +469,9 @@ void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount) d->setDFBColor(brush.color()); d->fillRects(rects, rectCount); } - if (d->pen != Qt::NoPen) { - d->setDFBColor(d->pen.color()); + const QPen &pen = state()->pen; + if (pen != Qt::NoPen) { + d->setDFBColor(pen.color()); d->drawRects(rects, rectCount); } } @@ -488,9 +487,10 @@ void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount) return; } - if (d->pen != Qt::NoPen) { + const QPen &pen = state()->pen; + if (pen != Qt::NoPen) { d->unlock(); - d->setDFBColor(d->pen.color()); + d->setDFBColor(pen.color()); d->drawLines(lines, lineCount); } } @@ -506,9 +506,10 @@ void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount) return; } - if (d->pen != Qt::NoPen) { + const QPen &pen = state()->pen; + if (pen != Qt::NoPen) { d->unlock(); - d->setDFBColor(d->pen.color()); + d->setDFBColor(pen.color()); d->drawLines(lines, lineCount); } } @@ -904,9 +905,8 @@ void QDirectFBPaintEnginePrivate::setTransform(const QTransform &transform) setPen(q->state()->pen); } -void QDirectFBPaintEnginePrivate::setPen(const QPen &p) +void QDirectFBPaintEnginePrivate::setPen(const QPen &pen) { - pen = p; if (pen.style() == Qt::NoPen) { simplePen = true; } else if (pen.style() == Qt::SolidLine -- cgit v0.12 From 3f14a6f5bf06ffa2451226928a925f5d23e343c3 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 13 Jul 2009 11:44:24 -0700 Subject: Remove unused variables in QDirectFBPaintEngine fbWidth/fbHeight were never used for anything Reviewed-by: Donald --- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index eda83b2..4ede69a 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -270,8 +270,6 @@ private: int lastLockedHeight; IDirectFB *fb; - int fbWidth; - int fbHeight; quint8 opacity; @@ -318,7 +316,6 @@ bool QDirectFBPaintEngine::begin(QPaintDevice *device) device->devType()); } d->lockedMemory = 0; - d->surface->GetSize(d->surface, &d->fbWidth, &d->fbHeight); const bool status = QRasterPaintEngine::begin(device); // XXX: QRasterPaintEngine::begin() resets the capabilities @@ -838,7 +835,7 @@ void QDirectFBPaintEngine::initImageCache(int size) QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p) : surface(0), antialiased(false), simplePen(false), transformationType(0), lastLockedHeight(-1), - fbWidth(-1), fbHeight(-1), opacity(255), dirtyClip(true), + opacity(255), dirtyClip(true), dfbHandledClip(false), dfbDevice(0), lockedMemory(0), unsupportedCompositionMode(false), q(p) { -- cgit v0.12 From 815eec62128d9b971306d698c9beee52a604d455 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 13 Jul 2009 11:47:09 -0700 Subject: Remove QDirectFBPaintEnginePrivate::setOpacity The function only sets a variable anyway. Replace with: d->opacity = state()->opacity * 255 Reviewed-by: Donald --- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 4ede69a..1ea0325 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -223,7 +223,6 @@ public: inline void setTransform(const QTransform &transforma); inline void setPen(const QPen &pen); inline void setCompositionMode(QPainter::CompositionMode mode); - inline void setOpacity(quint8 value); inline void setRenderHints(QPainter::RenderHints hints); inline void setDFBColor(const QColor &color); @@ -355,7 +354,7 @@ void QDirectFBPaintEngine::penChanged() void QDirectFBPaintEngine::opacityChanged() { Q_D(QDirectFBPaintEngine); - d->setOpacity(quint8(state()->opacity * 255)); + d->opacity = quint8(state()->opacity * 255); QRasterPaintEngine::opacityChanged(); } @@ -386,7 +385,7 @@ void QDirectFBPaintEngine::setState(QPainterState *state) QRasterPaintEngine::setState(state); d->dirtyClip = true; d->setPen(state->pen); - d->setOpacity(quint8(state->opacity * 255)); + d->opacity = quint8(state->opacity * 255); d->setCompositionMode(state->compositionMode()); d->setTransform(state->transform()); d->setRenderHints(state->renderHints); @@ -922,12 +921,6 @@ void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode m unsupportedCompositionMode = (mode != QPainter::CompositionMode_SourceOver); } - -void QDirectFBPaintEnginePrivate::setOpacity(quint8 op) -{ - opacity = op; -} - void QDirectFBPaintEnginePrivate::setRenderHints(QPainter::RenderHints hints) { const bool old = antialiased; -- cgit v0.12 From afb4dfc7b9536b7e7f443a89e94f331f8946de07 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 13 Jul 2009 12:52:49 -0700 Subject: Move ALPHA_PREMULT It's only used once and I want to unclutter the top of qdirectfbpaintengine.cpp Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 1ea0325..605324e 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -147,13 +147,6 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device * #define RASTERFALLBACK(op, one, two, three) #endif -static inline uint ALPHA_MUL(uint x, uint a) -{ - uint t = x * a; - t = ((t + (t >> 8) + 0x80) >> 8) & 0xff; - return t; -} - class SurfaceCache { public: @@ -940,6 +933,13 @@ void QDirectFBPaintEnginePrivate::prepareForBlit(bool alpha) surface->SetBlittingFlags(surface, DFBSurfaceBlittingFlags(blittingFlags)); } +static inline uint ALPHA_MUL(uint x, uint a) +{ + uint t = x * a; + t = ((t + (t >> 8) + 0x80) >> 8) & 0xff; + return t; +} + void QDirectFBPaintEnginePrivate::setDFBColor(const QColor &color) { Q_ASSERT(surface); -- cgit v0.12 From b4b9e2908f74a61170d9d84597b90ed0d60f74fc Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 13 Jul 2009 13:03:26 -0700 Subject: Fix QDirectFBPixmap::toImage Preallocated surfaces can currently be copied to video memory behind our back. This means that we can not use this mechanism for toImage() In later versions of DirectFB this might be possible to toggle with a flag so I'll leave the code in there #if 0'ed Reviewed-by: Donald --- src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index ce3d6e4..c75cba6 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -329,6 +329,10 @@ QImage QDirectFBPixmapData::toImage() const if (!dfbSurface) return QImage(); +#if 0 + // In later versions of DirectFB one can set a flag to tell + // DirectFB not to move the surface to videomemory. When that + // happens we can use this (hopefully faster) codepath #ifndef QT_NO_DIRECTFB_PREALLOCATED QImage ret(size(), QDirectFBScreen::getImageFormat(dfbSurface)); if (IDirectFBSurface *imgSurface = screen->createDFBSurface(ret, QDirectFBScreen::DontTrackSurface)) { @@ -346,6 +350,7 @@ QImage QDirectFBPixmapData::toImage() const return ret; } #endif +#endif QDirectFBPixmapData *that = const_cast(this); const QImage *img = that->buffer(); -- cgit v0.12 From c22a0186b5255af45f0b36acbde600de0e614266 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Tue, 14 Jul 2009 15:47:10 +0200 Subject: Revert "QFileDialog: When passing an invalid path in static functions the native" This reverts commit a4c4f994fa51ff216f0d43098824617e14b8a284. --- src/gui/dialogs/qfiledialog.cpp | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index 9f050de..d18cc7f 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -1599,12 +1599,7 @@ QString QFileDialog::getOpenFileName(QWidget *parent, args.parent = parent; args.caption = caption; args.directory = QFileDialogPrivate::workingDirectory(dir); - //If workingDirectory returned a different path than the initial one, - //it means that the initial path was invalid. There is no point to try select a file - if (args.directory != QFileInfo(dir).path()) - args.selection = QString(); - else - args.selection = QFileDialogPrivate::initialSelection(dir); + args.selection = QFileDialogPrivate::initialSelection(dir); args.filter = filter; args.mode = ExistingFile; args.options = options; @@ -1688,12 +1683,7 @@ QStringList QFileDialog::getOpenFileNames(QWidget *parent, args.parent = parent; args.caption = caption; args.directory = QFileDialogPrivate::workingDirectory(dir); - //If workingDirectory returned a different path than the initial one, - //it means that the initial path was invalid. There is no point to try select a file - if (args.directory != QFileInfo(dir).path()) - args.selection = QString(); - else - args.selection = QFileDialogPrivate::initialSelection(dir); + args.selection = QFileDialogPrivate::initialSelection(dir); args.filter = filter; args.mode = ExistingFiles; args.options = options; @@ -1779,12 +1769,7 @@ QString QFileDialog::getSaveFileName(QWidget *parent, args.parent = parent; args.caption = caption; args.directory = QFileDialogPrivate::workingDirectory(dir); - //If workingDirectory returned a different path than the initial one, - //it means that the initial path was invalid. There is no point to try select a file - if (args.directory != QFileInfo(dir).path()) - args.selection = QString(); - else - args.selection = QFileDialogPrivate::initialSelection(dir); + args.selection = QFileDialogPrivate::initialSelection(dir); args.filter = filter; args.mode = AnyFile; args.options = options; -- cgit v0.12 From 6b9328056591af2c48bed67f372693f030ba8c20 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 15 Jul 2009 09:10:16 +0200 Subject: Don't cause a rebuild of the application when mocinclude.tmp is used Since the mocinclude.tmp file was a dependency of all the generated moc files, it would always cause a rebuild of the code when doing a make. Reviewed-by: Joerg --- mkspecs/features/moc.prf | 2 -- 1 file changed, 2 deletions(-) diff --git a/mkspecs/features/moc.prf b/mkspecs/features/moc.prf index 60508c8..40101de 100644 --- a/mkspecs/features/moc.prf +++ b/mkspecs/features/moc.prf @@ -65,7 +65,6 @@ moc_header.output = $$MOC_DIR/$${QMAKE_H_MOD_MOC}${QMAKE_FILE_BASE}$${first(QMAK moc_header.input = HEADERS moc_header.variable_out = SOURCES moc_header.name = MOC ${QMAKE_FILE_IN} -!isEmpty(INCLUDETEMP):moc_header.depends += $$INCLUDETEMP silent:moc_header.commands = @echo moc ${QMAKE_FILE_IN} && $$moc_header.commands QMAKE_EXTRA_COMPILERS += moc_header INCREDIBUILD_XGE += moc_header @@ -77,7 +76,6 @@ moc_source.commands = ${QMAKE_FUNC_mocCmd} moc_source.output = $$MOC_DIR/$${QMAKE_CPP_MOD_MOC}${QMAKE_FILE_BASE}$${QMAKE_EXT_CPP_MOC} moc_source.input = SOURCES OBJECTIVE_SOURCES moc_source.name = MOC ${QMAKE_FILE_IN} -!isEmpty(INCLUDETEMP):moc_source.depends += $$INCLUDETEMP silent:moc_source.commands = @echo moc ${QMAKE_FILE_IN} && $$moc_source.commands QMAKE_EXTRA_COMPILERS += moc_source INCREDIBUILD_XGE += moc_source -- cgit v0.12 From 503b5d00dae7e33ff7f6ac55aefc703bb8f92d5c Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Wed, 15 Jul 2009 11:24:10 +0200 Subject: QFileDialog static functions doesn't honor the DontUseNativeDialog flag. Just add a check before calling hooks. Task-number:258084 Reviewed-by:jbache --- src/gui/dialogs/qfiledialog.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index d18cc7f..c8ce162 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -1677,7 +1677,7 @@ QStringList QFileDialog::getOpenFileNames(QWidget *parent, QString *selectedFilter, Options options) { - if (qt_filedialog_open_filenames_hook) + if (qt_filedialog_open_filenames_hook && !(options & DontUseNativeDialog)) return qt_filedialog_open_filenames_hook(parent, caption, dir, filter, selectedFilter, options); QFileDialogArgs args; args.parent = parent; @@ -1763,7 +1763,7 @@ QString QFileDialog::getSaveFileName(QWidget *parent, QString *selectedFilter, Options options) { - if (qt_filedialog_save_filename_hook) + if (qt_filedialog_save_filename_hook && !(options & DontUseNativeDialog)) return qt_filedialog_save_filename_hook(parent, caption, dir, filter, selectedFilter, options); QFileDialogArgs args; args.parent = parent; @@ -1838,7 +1838,7 @@ QString QFileDialog::getExistingDirectory(QWidget *parent, const QString &dir, Options options) { - if (qt_filedialog_existing_directory_hook) + if (qt_filedialog_existing_directory_hook && !(options & DontUseNativeDialog)) return qt_filedialog_existing_directory_hook(parent, caption, dir, options); QFileDialogArgs args; args.parent = parent; -- cgit v0.12 From 4dde6dac24027a4dfede4f79077df3d91de11efa Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 15 Jul 2009 11:41:38 +0200 Subject: Revert 6b9328 and fix the original dependency problem again Reviewed-by: Joerg --- mkspecs/features/moc.prf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mkspecs/features/moc.prf b/mkspecs/features/moc.prf index 40101de..33a58ad 100644 --- a/mkspecs/features/moc.prf +++ b/mkspecs/features/moc.prf @@ -65,6 +65,9 @@ moc_header.output = $$MOC_DIR/$${QMAKE_H_MOD_MOC}${QMAKE_FILE_BASE}$${first(QMAK moc_header.input = HEADERS moc_header.variable_out = SOURCES moc_header.name = MOC ${QMAKE_FILE_IN} +if(!contains(TEMPLATE, "vc.*") & !contains(TEMPLATE_PREFIX, "vc")) { + !isEmpty(INCLUDETEMP):moc_header.depends += $$INCLUDETEMP +} silent:moc_header.commands = @echo moc ${QMAKE_FILE_IN} && $$moc_header.commands QMAKE_EXTRA_COMPILERS += moc_header INCREDIBUILD_XGE += moc_header @@ -76,6 +79,9 @@ moc_source.commands = ${QMAKE_FUNC_mocCmd} moc_source.output = $$MOC_DIR/$${QMAKE_CPP_MOD_MOC}${QMAKE_FILE_BASE}$${QMAKE_EXT_CPP_MOC} moc_source.input = SOURCES OBJECTIVE_SOURCES moc_source.name = MOC ${QMAKE_FILE_IN} +if(!contains(TEMPLATE, "vc.*") & !contains(TEMPLATE_PREFIX, "vc")) { + !isEmpty(INCLUDETEMP):moc_source.depends += $$INCLUDETEMP +} silent:moc_source.commands = @echo moc ${QMAKE_FILE_IN} && $$moc_source.commands QMAKE_EXTRA_COMPILERS += moc_source INCREDIBUILD_XGE += moc_source -- cgit v0.12 From 4ce8c7af12cf9349beb692304808934f6de9cb83 Mon Sep 17 00:00:00 2001 From: Antonio Aloisio Date: Wed, 15 Jul 2009 12:49:54 +0200 Subject: Designer fails to compile if Qt is compiled without size grip support Reviewed-by: Friedemann Kleint --- tools/designer/src/lib/shared/widgetfactory.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/designer/src/lib/shared/widgetfactory.cpp b/tools/designer/src/lib/shared/widgetfactory.cpp index 6fabe18..37c7677 100644 --- a/tools/designer/src/lib/shared/widgetfactory.cpp +++ b/tools/designer/src/lib/shared/widgetfactory.cpp @@ -838,9 +838,11 @@ bool WidgetFactory::isPassiveInteractor(QWidget *widget) if (isTabBarInteractor(tabBar)) m_lastWasAPassiveInteractor = true; return m_lastWasAPassiveInteractor; - } else if (qobject_cast(widget)) +#ifndef QT_NO_SIZEGRIP + } else if (qobject_cast(widget)) { return (m_lastWasAPassiveInteractor = true); - else if (qobject_cast(widget)) +#endif + } else if (qobject_cast(widget)) return (m_lastWasAPassiveInteractor = true); else if (qobject_cast(widget) && (qobject_cast(widget->parent()) || qobject_cast(widget->parent()))) return (m_lastWasAPassiveInteractor = true); -- cgit v0.12 From 81049e49971a9f285f36204d6013c3172866718c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 15 Jul 2009 19:35:40 +0200 Subject: Add a "User-Agent" line to our HTTP proxy requests. Apparently some proxy servers can be configured to deny requests based on User-Agent, even for CONNECT connections. See https://bugs.kde.org/show_bug.cgi?id=155707#c155 for an example (packet dump in #c157, analysis in #c158). So send a User-Agent header with value "Mozilla/5.0", hoping that this will be enough to allow the connection. I hope it will, because other tools like libtool send something completely different: User-Agent: curl/7.19.5 (i586-mandriva-linux-gnu) libcurl/7.19.5 GnuTLS/2.8.1 zlib/1.2.3 c-ares/1.6.0 libidn/1.15 libssh2/1.0 Reviewed-by: TrustMe --- src/network/socket/qhttpsocketengine.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp index 7bac1f2..156a9f4 100644 --- a/src/network/socket/qhttpsocketengine.cpp +++ b/src/network/socket/qhttpsocketengine.cpp @@ -454,6 +454,7 @@ void QHttpSocketEngine::slotSocketConnected() data += path; data += " HTTP/1.1\r\n"; data += "Proxy-Connection: keep-alive\r\n" + "User-Agent: Mozilla/5.0\r\n" "Host: " + peerAddress + "\r\n"; QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(d->authenticator); //qDebug() << "slotSocketConnected: priv=" << priv << (priv ? (int)priv->method : -1); -- cgit v0.12 From 1c9bb00bf6adb1f76dbcfb151a7b95a0e517ee3c Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 15 Jul 2009 10:13:03 -0700 Subject: Fix off by one bug in dfbpe::drawTiledPixmap The drawTiledPixmap code iterated while x < right and y < bottom. This should be x <= right and y <= bottom. Reviewed-by: Donald --- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 605324e..49fc5f8 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -1119,9 +1119,9 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPix const QSizeF mappedSize(pixmapSize.width() * transform.m11(), pixmapSize.height() * transform.m22()); qreal y = ::fixCoord(destinationRect.y(), mappedSize.height(), offset.y()); const qreal startX = ::fixCoord(destinationRect.x(), mappedSize.width(), offset.x()); - while (y < destinationRect.bottom()) { + while (y <= destinationRect.bottom()) { qreal x = startX; - while (x < destinationRect.right()) { + while (x <= destinationRect.right()) { const DFBRectangle destination = { qRound(x), qRound(y), mappedSize.width(), mappedSize.height() }; surface->StretchBlit(surface, sourceSurface, 0, &destination); x += mappedSize.width(); @@ -1143,10 +1143,10 @@ void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPix QVarLengthArray points(maxCount); int i = 0; - while (y < destinationRect.bottom()) { + while (y <= destinationRect.bottom()) { Q_ASSERT(i < maxCount); qreal x = startX; - while (x < destinationRect.right()) { + while (x <= destinationRect.right()) { points[i].x = qRound(x); points[i].y = qRound(y); sourceRects[i].x = 0; -- cgit v0.12 From bd6ad2c54ea9bd60ab8dbd5771821ab0e374488e Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 15 Jul 2009 09:32:17 -0700 Subject: Clean up rect/line drawing in dfb paintengine Slight optimization by using the pluralized functions when possible. Also make templatized helper functions to avoid near-duplication of code for the float/int cases. Reviewed-by: Donald --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 145 +++++++++------------ 1 file changed, 63 insertions(+), 82 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 49fc5f8..de7c3e5 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -228,15 +228,6 @@ public: inline bool dfbCanHandleClip() const; inline bool isSimpleBrush(const QBrush &brush) const; - void drawLines(const QLine *lines, int count); - void drawLines(const QLineF *lines, int count); - - void fillRegion(const QRegion &r); - void fillRects(const QRect *rects, int count); - void drawRects(const QRect *rects, int count); - void fillRects(const QRectF *rects, int count); - void drawRects(const QRectF *rects, int count); - void drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap, const QPointF &pos); void blit(const QRectF &dest, IDirectFBSurface *surface, const QRectF &src); @@ -277,6 +268,12 @@ private: friend class QDirectFBPaintEngine; }; +template +static inline void drawLines(const T *lines, int n, const QTransform &transform, IDirectFBSurface *surface); +template +static inline void fillRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface); +template +static inline void drawRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface); QDirectFBPaintEngine::QDirectFBPaintEngine(QPaintDevice *device) : QRasterPaintEngine(*(new QDirectFBPaintEnginePrivate(this)), device) @@ -427,12 +424,12 @@ void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount) if (brush != Qt::NoBrush) { d->setDFBColor(brush.color()); - d->fillRects(rects, rectCount); + ::fillRects(rects, rectCount, state()->matrix, d->surface); } const QPen &pen = state()->pen; if (pen != Qt::NoPen) { d->setDFBColor(pen.color()); - d->drawRects(rects, rectCount); + ::drawRects(rects, rectCount, state()->matrix, d->surface); } } @@ -456,12 +453,12 @@ void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount) if (brush != Qt::NoBrush) { d->setDFBColor(brush.color()); - d->fillRects(rects, rectCount); + ::fillRects(rects, rectCount, state()->matrix, d->surface); } const QPen &pen = state()->pen; if (pen != Qt::NoPen) { d->setDFBColor(pen.color()); - d->drawRects(rects, rectCount); + ::drawRects(rects, rectCount, state()->matrix, d->surface); } } @@ -480,7 +477,7 @@ void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount) if (pen != Qt::NoPen) { d->unlock(); d->setDFBColor(pen.color()); - d->drawLines(lines, lineCount); + ::drawLines(lines, lineCount, state()->matrix, d->surface); } } @@ -499,7 +496,7 @@ void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount) if (pen != Qt::NoPen) { d->unlock(); d->setDFBColor(pen.color()); - d->drawLines(lines, lineCount); + ::drawLines(lines, lineCount, state()->matrix, d->surface); } } @@ -950,73 +947,6 @@ void QDirectFBPaintEnginePrivate::setDFBColor(const QColor &color) surface->SetDrawingFlags(surface, alpha == 255 ? DSDRAW_NOFX : DSDRAW_BLEND); } -void QDirectFBPaintEnginePrivate::drawLines(const QLine *lines, int n) -{ - const QTransform &transform = q->state()->matrix; - for (int i = 0; i < n; ++i) { - const QLine l = transform.map(lines[i]); - surface->DrawLine(surface, l.x1(), l.y1(), l.x2(), l.y2()); - } -} - -void QDirectFBPaintEnginePrivate::drawLines(const QLineF *lines, int n) -{ - const QTransform &transform = q->state()->matrix; - for (int i = 0; i < n; ++i) { - const QLine l = transform.map(lines[i]).toLine(); - surface->DrawLine(surface, l.x1(), l.y1(), l.x2(), l.y2()); - } -} - -void QDirectFBPaintEnginePrivate::fillRegion(const QRegion ®ion) -{ - Q_ASSERT(isSimpleBrush(q->state()->brush)); - setDFBColor(q->state()->brush.color()); - const QVector rects = region.rects(); - const int n = rects.size(); - fillRects(rects.constData(), n); -} - -void QDirectFBPaintEnginePrivate::fillRects(const QRect *rects, int n) -{ - const QTransform &transform = q->state()->matrix; - for (int i = 0; i < n; ++i) { - const QRect r = transform.mapRect(rects[i]); - surface->FillRectangle(surface, r.x(), r.y(), - r.width(), r.height()); - } -} - -void QDirectFBPaintEnginePrivate::fillRects(const QRectF *rects, int n) -{ - const QTransform &transform = q->state()->matrix; - for (int i = 0; i < n; ++i) { - const QRect r = transform.mapRect(rects[i]).toRect(); - surface->FillRectangle(surface, r.x(), r.y(), - r.width(), r.height()); - } -} - -void QDirectFBPaintEnginePrivate::drawRects(const QRect *rects, int n) -{ - const QTransform &transform = q->state()->matrix; - for (int i = 0; i < n; ++i) { - const QRect r = transform.mapRect(rects[i]); - surface->DrawRectangle(surface, r.x(), r.y(), - r.width() + 1, r.height() + 1); - } -} - -void QDirectFBPaintEnginePrivate::drawRects(const QRectF *rects, int n) -{ - const QTransform &transform = q->state()->matrix; - for (int i = 0; i < n; ++i) { - const QRect r = transform.mapRect(rects[i]).toRect(); - surface->DrawRectangle(surface, r.x(), r.y(), - r.width() + 1, r.height() + 1); - } -} - IDirectFBSurface *QDirectFBPaintEnginePrivate::getSurface(const QImage &img, bool *release) { #ifndef QT_DIRECTFB_IMAGECACHE @@ -1210,4 +1140,55 @@ void QDirectFBPaintEnginePrivate::systemStateChanged() QRasterPaintEnginePrivate::systemStateChanged(); } +static inline QRect mapRect(const QTransform &transform, const QRect &rect) { return transform.mapRect(rect); } +static inline QRect mapRect(const QTransform &transform, const QRectF &rect) { return transform.mapRect(rect).toRect(); } +static inline QLine map(const QTransform &transform, const QLine &line) { return transform.map(line); } +static inline QLine map(const QTransform &transform, const QLineF &line) { return transform.map(line).toLine(); } +template +static inline void drawLines(const T *lines, int n, const QTransform &transform, IDirectFBSurface *surface) +{ + if (n == 1) { + const QLine l = ::map(transform, lines[0]); + surface->DrawLine(surface, l.x1(), l.y1(), l.x2(), l.y2()); + } else { + QVarLengthArray lineArray(n); + for (int i=0; iDrawLines(surface, lineArray.constData(), n); + } +} + +template +static inline void fillRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface) +{ + if (n == 1) { + const QRect r = ::mapRect(transform, rects[0]); + surface->FillRectangle(surface, r.x(), r.y(), r.width(), r.height()); + } else { + QVarLengthArray rectArray(n); + for (int i=0; iFillRectangles(surface, rectArray.constData(), n); + } +} + +template +static inline void drawRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface) +{ + for (int i=0; iDrawRectangle(surface, r.x(), r.y(), r.width(), r.height()); + } +} + #endif // QT_NO_DIRECTFB -- cgit v0.12 From c413ae69ae4dc41075f3391fe4838073af657ffb Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 15 Jul 2009 10:23:18 -0700 Subject: Don't force a lock in QDirectFBPaintEngine::clip Pretty much every paint operation on DirectFB surfaces starts with a clipping operations which until now would always cause a IDirectFBSurface->Lock(). This was to make sure QRasterBuffer::prepare had been called so QClipData::initialize() would allocate a big enough array for its spans. We can safely not make QDirectFBPaintDevice::memory() return 0 until we actually fall back. Reviewed-By: Donald --- .../gfxdrivers/directfb/qdirectfbpaintdevice.cpp | 5 ---- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 27 ++++------------------ 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp index 52f6a37..178dbae 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp @@ -89,11 +89,6 @@ void QDirectFBPaintDevice::unlockDirectFB() void *QDirectFBPaintDevice::memory() const { - if (lock != (DSLF_READ|DSLF_WRITE)) { - QDirectFBPaintDevice *that = const_cast(this); - that->lockDirectFB(DSLF_READ|DSLF_WRITE); - Q_ASSERT(that->lockedImage); - } return mem; } diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index de7c3e5..58443d4 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -250,7 +250,6 @@ private: uint transformationType; // this is QTransform::type() + NegativeScale if qMin(transform.m11(), transform.m22()) < 0 SurfaceCache *surfaceCache; - int lastLockedHeight; IDirectFB *fb; @@ -260,7 +259,6 @@ private: bool dfbHandledClip; bool ignoreSystemClip; QDirectFBPaintDevice *dfbDevice; - void *lockedMemory; bool unsupportedCompositionMode; QDirectFBPaintEngine *q; @@ -287,7 +285,6 @@ QDirectFBPaintEngine::~QDirectFBPaintEngine() bool QDirectFBPaintEngine::begin(QPaintDevice *device) { Q_D(QDirectFBPaintEngine); - d->lastLockedHeight = -1; if (device->devType() == QInternal::CustomRaster) { d->dfbDevice = static_cast(device); } else if (device->devType() == QInternal::Pixmap) { @@ -304,11 +301,11 @@ bool QDirectFBPaintEngine::begin(QPaintDevice *device) qFatal("QDirectFBPaintEngine used on an invalid device: 0x%x", device->devType()); } - d->lockedMemory = 0; const bool status = QRasterPaintEngine::begin(device); // XXX: QRasterPaintEngine::begin() resets the capabilities gccaps |= PorterDuff; + d->prepare(d->dfbDevice); return status; } @@ -385,9 +382,6 @@ void QDirectFBPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) { Q_D(QDirectFBPaintEngine); d->dirtyClip = true; - const QPoint bottom = state()->matrix.map(QPoint(0, int(path.controlPointRect().y2))); - if (bottom.y() > d->lastLockedHeight) - d->lock(); QRasterPaintEngine::clip(path, op); } @@ -395,12 +389,6 @@ void QDirectFBPaintEngine::clip(const QRect &rect, Qt::ClipOperation op) { Q_D(QDirectFBPaintEngine); d->dirtyClip = true; - if (d->clip() && !d->clip()->hasRectClip && d->clip()->enabled) { - const QPoint bottom = state()->matrix.map(QPoint(0, rect.bottom())); - if (bottom.y() > d->lastLockedHeight) - d->lock(); - } - QRasterPaintEngine::clip(rect, op); } @@ -823,9 +811,8 @@ void QDirectFBPaintEngine::initImageCache(int size) QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p) : surface(0), antialiased(false), simplePen(false), - transformationType(0), lastLockedHeight(-1), - opacity(255), dirtyClip(true), - dfbHandledClip(false), dfbDevice(0), lockedMemory(0), + transformationType(0), opacity(255), dirtyClip(true), + dfbHandledClip(false), dfbDevice(0), unsupportedCompositionMode(false), q(p) { fb = QDirectFBScreen::instance()->dfb(); @@ -866,12 +853,9 @@ void QDirectFBPaintEnginePrivate::lock() // lock so we need to call the base implementation of prepare so // it updates its rasterBuffer to point to the new buffer address. Q_ASSERT(dfbDevice); - if (dfbDevice->lockFlags() != (DSLF_WRITE|DSLF_READ) - || dfbDevice->height() != lastLockedHeight - || dfbDevice->memory() != lockedMemory) { + if (dfbDevice->lockFlags() != (DSLF_WRITE|DSLF_READ)) { + dfbDevice->lockDirectFB(DSLF_READ|DSLF_WRITE); prepare(dfbDevice); - lastLockedHeight = dfbDevice->height(); - lockedMemory = dfbDevice->memory(); } } @@ -879,7 +863,6 @@ void QDirectFBPaintEnginePrivate::unlock() { Q_ASSERT(dfbDevice); dfbDevice->unlockDirectFB(); - lockedMemory = 0; } void QDirectFBPaintEnginePrivate::setTransform(const QTransform &transform) -- cgit v0.12 From a4b88269aae0e546580a7ad6a20866cc582afd41 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 15 Jul 2009 09:42:46 -0700 Subject: Clean up qdirectfbpaintengine.cpp - Move implementation of debug functions to the bottom of the file. - Move ImageCache stuff to under QDirectFBPaintEnginePrivate - Move SurfaceCache stuff to under QDirectFBPaintEnginePrivate Reviewed-by: Shane McLaughlin --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 299 +++++++++++---------- 1 file changed, 150 insertions(+), 149 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 58443d4..9aaae62 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -54,154 +54,7 @@ #include #include -#if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS || defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS -#define VOID_ARG() static_cast(false) -enum PaintOperation { - DRAW_RECTS = 0x0001, - DRAW_LINES = 0x0002, - DRAW_IMAGE = 0x0004, - DRAW_PIXMAP = 0x0008, - DRAW_TILED_PIXMAP = 0x0010, - STROKE_PATH = 0x0020, - DRAW_PATH = 0x0040, - DRAW_POINTS = 0x0080, - DRAW_ELLIPSE = 0x0100, - DRAW_POLYGON = 0x0200, - DRAW_TEXT = 0x0400, - FILL_PATH = 0x0800, - FILL_RECT = 0x1000, - DRAW_COLORSPANS = 0x2000, - ALL = 0xffff -}; -#endif - -#ifdef QT_DIRECTFB_WARN_ON_RASTERFALLBACKS -template inline const T *ptr(const T &t) { return &t; } -template <> inline const bool* ptr(const bool &) { return 0; } -template -static void rasterFallbackWarn(const char *msg, const char *func, const device *dev, - uint transformationType, bool simplePen, - bool dfbHandledClip, bool unsupportedCompositionMode, - const char *nameOne, const T1 &one, - const char *nameTwo, const T2 &two, - const char *nameThree, const T3 &three) -{ - QString out; - QDebug dbg(&out); - dbg << msg << (QByteArray(func) + "()") << "painting on"; - if (dev->devType() == QInternal::Widget) { - dbg << static_cast(dev); - } else { - dbg << dev << "of type" << dev->devType(); - } - - dbg << QString("transformationType 0x%1").arg(transformationType, 3, 16, QLatin1Char('0')) - << "simplePen" << simplePen - << "dfbHandledClip" << dfbHandledClip - << "unsupportedCompositionMode" << unsupportedCompositionMode; - - const T1 *t1 = ptr(one); - const T2 *t2 = ptr(two); - const T3 *t3 = ptr(three); - - if (t1) { - dbg << nameOne << *t1; - if (t2) { - dbg << nameTwo << *t2; - if (t3) { - dbg << nameThree << *t3; - } - } - } - qWarning("%s", qPrintable(out)); -} -#endif - -#if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS && defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS -#define RASTERFALLBACK(op, one, two, three) \ - if (op & (QT_DIRECTFB_WARN_ON_RASTERFALLBACKS)) \ - rasterFallbackWarn("Disabled raster engine operation", \ - __FUNCTION__, state()->painter->device(), \ - d_func()->transformationType, \ - d_func()->simplePen, \ - d_func()->dfbCanHandleClip(), \ - d_func()->unsupportedCompositionMode, \ - #one, one, #two, two, #three, three); \ - if (op & (QT_DIRECTFB_DISABLE_RASTERFALLBACKS)) \ - return; -#elif defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS -#define RASTERFALLBACK(op, one, two, three) \ - if (op & (QT_DIRECTFB_DISABLE_RASTERFALLBACKS)) \ - return; -#elif defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS -#define RASTERFALLBACK(op, one, two, three) \ - if (op & (QT_DIRECTFB_WARN_ON_RASTERFALLBACKS)) \ - rasterFallbackWarn("Falling back to raster engine for", \ - __FUNCTION__, state()->painter->device(), \ - d_func()->transformationType, \ - d_func()->simplePen, \ - d_func()->dfbCanHandleClip(), \ - d_func()->unsupportedCompositionMode, \ - #one, one, #two, two, #three, three); -#else -#define RASTERFALLBACK(op, one, two, three) -#endif - -class SurfaceCache -{ -public: - SurfaceCache() : surface(0), buffer(0), bufsize(0) {} - ~SurfaceCache() { clear(); } - - - IDirectFBSurface *getSurface(const uint *buf, int size) - { - if (buffer == buf && bufsize == size) - return surface; - - clear(); - - const DFBSurfaceDescription description = QDirectFBScreen::getSurfaceDescription(buf, size); - surface = QDirectFBScreen::instance()->createDFBSurface(description, QDirectFBScreen::TrackSurface); - if (!surface) - qWarning("QDirectFBPaintEngine: SurfaceCache: Unable to create surface"); - - buffer = const_cast(buf); - bufsize = size; - - return surface; - } - - void clear() - { - if (surface && QDirectFBScreen::instance()) - QDirectFBScreen::instance()->releaseDFBSurface(surface); - surface = 0; - buffer = 0; - bufsize = 0; - } -private: - IDirectFBSurface *surface; - uint *buffer; - int bufsize; -}; - - -#ifdef QT_DIRECTFB_IMAGECACHE -#include -struct CachedImage -{ - IDirectFBSurface *surface; - ~CachedImage() - { - if (surface && QDirectFBScreen::instance()) { - QDirectFBScreen::instance()->releaseDFBSurface(surface); - } - } -}; -static QCache imageCache(4*1024*1024); // 4 MB -#endif - +class SurfaceCache; class QDirectFBPaintEnginePrivate : public QRasterPaintEnginePrivate { public: @@ -232,7 +85,7 @@ public: void blit(const QRectF &dest, IDirectFBSurface *surface, const QRectF &src); inline void updateClip(); - void systemStateChanged(); + virtual void systemStateChanged(); static IDirectFBSurface *getSurface(const QImage &img, bool *release); @@ -266,6 +119,83 @@ private: friend class QDirectFBPaintEngine; }; +class SurfaceCache +{ +public: + SurfaceCache() : surface(0), buffer(0), bufsize(0) {} + ~SurfaceCache() { clear(); } + IDirectFBSurface *getSurface(const uint *buf, int size); + void clear(); +private: + IDirectFBSurface *surface; + uint *buffer; + int bufsize; +}; + + +#ifdef QT_DIRECTFB_IMAGECACHE +#include +struct CachedImage +{ + IDirectFBSurface *surface; + ~CachedImage() + { + if (surface && QDirectFBScreen::instance()) { + QDirectFBScreen::instance()->releaseDFBSurface(surface); + } + } +}; +static QCache imageCache(4*1024*1024); // 4 MB +#endif + +#if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS || defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS +#define VOID_ARG() static_cast(false) +enum PaintOperation { + DRAW_RECTS = 0x0001, DRAW_LINES = 0x0002, DRAW_IMAGE = 0x0004, + DRAW_PIXMAP = 0x0008, DRAW_TILED_PIXMAP = 0x0010, STROKE_PATH = 0x0020, + DRAW_PATH = 0x0040, DRAW_POINTS = 0x0080, DRAW_ELLIPSE = 0x0100, + DRAW_POLYGON = 0x0200, DRAW_TEXT = 0x0400, FILL_PATH = 0x0800, + FILL_RECT = 0x1000, DRAW_COLORSPANS = 0x2000, ALL = 0xffff +}; +#endif + +#ifdef QT_DIRECTFB_WARN_ON_RASTERFALLBACKS +template +static void rasterFallbackWarn(const char *msg, const char *, const device *, uint, bool, bool, bool, + const char *, const T1 &, const char *, const T2 &, const char *, const T3 &); +#endif + +#if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS && defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS +#define RASTERFALLBACK(op, one, two, three) \ + if (op & (QT_DIRECTFB_WARN_ON_RASTERFALLBACKS)) \ + rasterFallbackWarn("Disabled raster engine operation", \ + __FUNCTION__, state()->painter->device(), \ + d_func()->transformationType, \ + d_func()->simplePen, \ + d_func()->dfbCanHandleClip(), \ + d_func()->unsupportedCompositionMode, \ + #one, one, #two, two, #three, three); \ + if (op & (QT_DIRECTFB_DISABLE_RASTERFALLBACKS)) \ + return; +#elif defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS +#define RASTERFALLBACK(op, one, two, three) \ + if (op & (QT_DIRECTFB_DISABLE_RASTERFALLBACKS)) \ + return; +#elif defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS +#define RASTERFALLBACK(op, one, two, three) \ + if (op & (QT_DIRECTFB_WARN_ON_RASTERFALLBACKS)) \ + rasterFallbackWarn("Falling back to raster engine for", \ + __FUNCTION__, state()->painter->device(), \ + d_func()->transformationType, \ + d_func()->simplePen, \ + d_func()->dfbCanHandleClip(), \ + d_func()->unsupportedCompositionMode, \ + #one, one, #two, two, #three, three); +#else +#define RASTERFALLBACK(op, one, two, three) +#endif + + template static inline void drawLines(const T *lines, int n, const QTransform &transform, IDirectFBSurface *surface); template @@ -1123,6 +1053,34 @@ void QDirectFBPaintEnginePrivate::systemStateChanged() QRasterPaintEnginePrivate::systemStateChanged(); } +IDirectFBSurface *SurfaceCache::getSurface(const uint *buf, int size) +{ + if (buffer == buf && bufsize == size) + return surface; + + clear(); + + const DFBSurfaceDescription description = QDirectFBScreen::getSurfaceDescription(buf, size); + surface = QDirectFBScreen::instance()->createDFBSurface(description, QDirectFBScreen::TrackSurface); + if (!surface) + qWarning("QDirectFBPaintEngine: SurfaceCache: Unable to create surface"); + + buffer = const_cast(buf); + bufsize = size; + + return surface; +} + +void SurfaceCache::clear() +{ + if (surface && QDirectFBScreen::instance()) + QDirectFBScreen::instance()->releaseDFBSurface(surface); + surface = 0; + buffer = 0; + bufsize = 0; +} + + static inline QRect mapRect(const QTransform &transform, const QRect &rect) { return transform.mapRect(rect); } static inline QRect mapRect(const QTransform &transform, const QRectF &rect) { return transform.mapRect(rect).toRect(); } static inline QLine map(const QTransform &transform, const QLine &line) { return transform.map(line); } @@ -1174,4 +1132,47 @@ static inline void drawRects(const T *rects, int n, const QTransform &transform, } } +#ifdef QT_DIRECTFB_WARN_ON_RASTERFALLBACKS +template inline const T *ptr(const T &t) { return &t; } +template <> inline const bool* ptr(const bool &) { return 0; } +template +static void rasterFallbackWarn(const char *msg, const char *func, const device *dev, + uint transformationType, bool simplePen, + bool dfbHandledClip, bool unsupportedCompositionMode, + const char *nameOne, const T1 &one, + const char *nameTwo, const T2 &two, + const char *nameThree, const T3 &three) +{ + QString out; + QDebug dbg(&out); + dbg << msg << (QByteArray(func) + "()") << "painting on"; + if (dev->devType() == QInternal::Widget) { + dbg << static_cast(dev); + } else { + dbg << dev << "of type" << dev->devType(); + } + + dbg << QString("transformationType 0x%1").arg(transformationType, 3, 16, QLatin1Char('0')) + << "simplePen" << simplePen + << "dfbHandledClip" << dfbHandledClip + << "unsupportedCompositionMode" << unsupportedCompositionMode; + + const T1 *t1 = ptr(one); + const T2 *t2 = ptr(two); + const T3 *t3 = ptr(three); + + if (t1) { + dbg << nameOne << *t1; + if (t2) { + dbg << nameTwo << *t2; + if (t3) { + dbg << nameThree << *t3; + } + } + } + qWarning("%s", qPrintable(out)); +} +#endif + + #endif // QT_NO_DIRECTFB -- cgit v0.12 From 8734464e27b7a3fadb1adeefc3971d8a1e5103bd Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Thu, 16 Jul 2009 09:37:39 +0200 Subject: Better caching of file system icon providers. It turns out that we weren't doing any caching of icons provided by the file system. We now use the similar trick that's used on Windows which does some caching on the file extension. We do fill up the cache needlessly with extra information (16, 32, 64, and 128) icons. We probably could be better with a iconRef engine that generates these sizes on demand. Still performance is 100% better with this which means using it in itemviews works. Reviewed-by: Jens Bache-Wiig --- src/gui/itemviews/qfileiconprovider.cpp | 37 ++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qfileiconprovider.cpp b/src/gui/itemviews/qfileiconprovider.cpp index ed663b3..6338e49 100644 --- a/src/gui/itemviews/qfileiconprovider.cpp +++ b/src/gui/itemviews/qfileiconprovider.cpp @@ -45,11 +45,11 @@ #include #include #include +#include #if defined(Q_WS_WIN) #define _WIN32_IE 0x0500 #include #include -#include #elif defined(Q_WS_MAC) #include #endif @@ -316,6 +316,31 @@ QIcon QFileIconProviderPrivate::getWinIcon(const QFileInfo &fileInfo) const QIcon QFileIconProviderPrivate::getMacIcon(const QFileInfo &fi) const { QIcon retIcon; + QString fileExtension = fi.suffix().toUpper(); + fileExtension.prepend(QLatin1String(".")); + + const QString keyBase = QLatin1String("qt_") + fileExtension; + + QPixmap pixmap; + if (fi.isFile() && !fi.isExecutable() && !fi.isSymLink()) { + QPixmapCache::find(keyBase + QLatin1String("16"), pixmap); + } + + if (!pixmap.isNull()) { + retIcon.addPixmap(pixmap); + if (QPixmapCache::find(keyBase + QLatin1String("32"), pixmap)) { + retIcon.addPixmap(pixmap); + if (QPixmapCache::find(keyBase + QLatin1String("64"), pixmap)) { + retIcon.addPixmap(pixmap); + if (QPixmapCache::find(keyBase + QLatin1String("128"), pixmap)) { + retIcon.addPixmap(pixmap); + return retIcon; + } + } + } + } + + FSRef macRef; OSStatus status = FSPathMakeRef(reinterpret_cast(fi.canonicalFilePath().toUtf8().constData()), &macRef, 0); @@ -334,6 +359,16 @@ QIcon QFileIconProviderPrivate::getMacIcon(const QFileInfo &fi) const extern void qt_mac_constructQIconFromIconRef(const IconRef, const IconRef, QIcon*, QStyle::StandardPixmap = QStyle::SP_CustomBase); // qmacstyle_mac.cpp qt_mac_constructQIconFromIconRef(iconRef, 0, &retIcon); ReleaseIconRef(iconRef); + + pixmap = retIcon.pixmap(16); + QPixmapCache::insert(keyBase + QLatin1String("16"), pixmap); + pixmap = retIcon.pixmap(32); + QPixmapCache::insert(keyBase + QLatin1String("32"), pixmap); + pixmap = retIcon.pixmap(64); + QPixmapCache::insert(keyBase + QLatin1String("64"), pixmap); + pixmap = retIcon.pixmap(128); + QPixmapCache::insert(keyBase + QLatin1String("128"), pixmap); + return retIcon; } #endif -- cgit v0.12 From 21a10dba28f6abc2659929ce8bbaf0e0fd32d3f5 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 16 Jul 2009 14:58:34 +0200 Subject: Phonon: fixed a big memory leak on Windows If you had deleted a VideoWidget, it could not free the memory taken because we still had a reference on it. Task-number: 258202 --- src/3rdparty/phonon/ds9/backendnode.cpp | 2 ++ src/3rdparty/phonon/ds9/qpin.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/phonon/ds9/backendnode.cpp b/src/3rdparty/phonon/ds9/backendnode.cpp index 7e0b3cd..855357a 100644 --- a/src/3rdparty/phonon/ds9/backendnode.cpp +++ b/src/3rdparty/phonon/ds9/backendnode.cpp @@ -57,6 +57,8 @@ namespace Phonon BackendNode::~BackendNode() { + //this will remove the filter from the graph + mediaObjectDestroyed(); } void BackendNode::setMediaObject(MediaObject *mo) diff --git a/src/3rdparty/phonon/ds9/qpin.cpp b/src/3rdparty/phonon/ds9/qpin.cpp index 37fe48d..f652502 100644 --- a/src/3rdparty/phonon/ds9/qpin.cpp +++ b/src/3rdparty/phonon/ds9/qpin.cpp @@ -456,8 +456,8 @@ namespace Phonon HRESULT QPin::checkOutputMediaTypesConnection(IPin *pin) { - IEnumMediaTypes *emt = 0; - HRESULT hr = pin->EnumMediaTypes(&emt); + ComPointer emt; + HRESULT hr = pin->EnumMediaTypes(emt.pparam()); if (hr != S_OK) { return hr; } -- cgit v0.12 From 2883cf47431c9d944ccd40785b079d8625df14f1 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Thu, 16 Jul 2009 16:24:03 +0200 Subject: Fixed bug where line widths were rounded to integers in the GL engine. Regression from Qt 4.4. Task-number: 257990 Reviewed-by: Tom --- src/opengl/qpaintengine_opengl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index 84151ee..de11da7 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -4171,7 +4171,7 @@ void QOpenGLPaintEnginePrivate::strokePath(const QPainterPath &path, bool use_ca QPen pen = cpen; if (txscale != 1) - pen.setWidthF(pen.width() * txscale); + pen.setWidthF(pen.widthF() * txscale); if (use_cache) fillPath(qt_opengl_stroke_cache()->getStrokedPath(temp.map(path), pen)); else -- cgit v0.12 From 86ea4dbb5a748491656d9621ecd58238bc3e3d82 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Thu, 16 Jul 2009 17:35:59 -0700 Subject: Don't assume that raster can do porter duff in dfb PorterDuff should only be enabled if the raster engine says it is. E.g. if we're painting on a format with alpha. Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 9aaae62..305d5be 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -232,11 +232,7 @@ bool QDirectFBPaintEngine::begin(QPaintDevice *device) device->devType()); } - const bool status = QRasterPaintEngine::begin(device); - // XXX: QRasterPaintEngine::begin() resets the capabilities - gccaps |= PorterDuff; - d->prepare(d->dfbDevice); - return status; + return QRasterPaintEngine::begin(device); } bool QDirectFBPaintEngine::end() -- cgit v0.12 From 28c7798752b35d68eaa6f0dfe1cad91965f90729 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Fri, 17 Jul 2009 09:44:45 +0200 Subject: Update the example TrafficInfo for GCC 3.3 The example TrafficInfo did not compile on GCC 3.3 due to a bug in the parser of GCC. Task-number: 258208 --- examples/xmlpatterns/trafficinfo/mainwindow.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/xmlpatterns/trafficinfo/mainwindow.cpp b/examples/xmlpatterns/trafficinfo/mainwindow.cpp index 428ed76..c6bd313 100644 --- a/examples/xmlpatterns/trafficinfo/mainwindow.cpp +++ b/examples/xmlpatterns/trafficinfo/mainwindow.cpp @@ -111,7 +111,9 @@ void MainWindow::mousePressEvent(QMouseEvent *event) void MainWindow::paintEvent(QPaintEvent*) { - QLinearGradient gradient(QPoint(width()/2, 0), QPoint(width()/2, height())); + const QPoint start(width()/2, 0); + const QPoint finalStop(width()/2, height()); + QLinearGradient gradient(start, finalStop); const QColor qtGreen(102, 176, 54); gradient.setColorAt(0, qtGreen.dark()); gradient.setColorAt(0.5, qtGreen); -- cgit v0.12 From 57e3851401b1098ad760073cdbc5d215b791475a Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Fri, 17 Jul 2009 10:47:50 +0200 Subject: Enhanced QDirModel documentation Reviewed-by: Volker Hilsheimer --- src/gui/itemviews/qdirmodel.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qdirmodel.cpp b/src/gui/itemviews/qdirmodel.cpp index d75aa6a..c3a080c 100644 --- a/src/gui/itemviews/qdirmodel.cpp +++ b/src/gui/itemviews/qdirmodel.cpp @@ -227,7 +227,10 @@ void QDirModelPrivate::invalidate() \note QDirModel requires an instance of a GUI application. - \sa nameFilters(), setFilter(), filter(), QListView, QTreeView, + \note The usage of QDirModel is not recommended anymore. The + QFileSystemModel class is a more performant alternative. + + \sa nameFilters(), setFilter(), filter(), QListView, QTreeView, QFileSystemModel {Dir View Example}, {Model Classes} */ -- cgit v0.12 From d302a3f4738226afd1f3985fe5cb0a75c87da369 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Fri, 17 Jul 2009 10:53:06 +0200 Subject: Removed outdated information from QNetworkRequest documentation Reviewed-by: TrustMe --- src/network/access/qnetworkrequest.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index 7e73d58..645cd52 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -153,9 +153,7 @@ QT_BEGIN_NAMESPACE future uses. If the value is false, the data obtained will not be automatically cached. If true, data may be cached, provided it is cacheable (what is cacheable depends on the protocol - being used). Note that the default QNetworkAccessManager - implementation does not support caching, so it will ignore - this attribute. + being used). \value SourceIsFromCacheAttribute Replies only, type: QVariant::Bool (default: false) -- cgit v0.12 From 11e010c1b72c5309cff4123a6835414283530d74 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Fri, 17 Jul 2009 11:00:26 +0200 Subject: tst_qnetworkreply: Removed warning Reviewed-by: TrustMe --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index ff315de..842befb 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -3124,6 +3124,7 @@ public slots: } void bytesWrittenSlot(qint64 amount) { + Q_UNUSED(amount); if (dataSent == dataSize && client) { // close eventually -- cgit v0.12 From 4652f0e0a03083b5baa1488237084333b134c516 Mon Sep 17 00:00:00 2001 From: mae Date: Thu, 18 Jun 2009 11:52:54 +0200 Subject: Fix accidental selection of popup items under the mouse in QComboBox If the widget under mouse is hidden, Qt can generate a synthetic mouse move event which gets delivered to the already hidden widget. This can then result in the wrong item being selected. Workaround: in QListView, ignore mouse move events when the widget is hidden. Reviewed-by: Denis --- src/gui/itemviews/qlistview.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index d410a57..cc6277e 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -827,6 +827,8 @@ void QListView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int e */ void QListView::mouseMoveEvent(QMouseEvent *e) { + if (!isVisible()) + return; Q_D(QListView); QAbstractItemView::mouseMoveEvent(e); if (state() == DragSelectingState -- cgit v0.12 From bb5692384aef0b87362966609b8fd58c0974e4b5 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 17 Jul 2009 03:09:10 -0700 Subject: Clean up directfb bit flipping DirectFB declares variables that are bit fields as enums. E.g. DFBSurfaceCapabilities caps; caps |= DSCAPS_LOCK; // doesn't compile in C++ Work around this problem by declaring operators for these operations. This greatly improves the readability of the code. Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp | 2 +- .../gfxdrivers/directfb/qdirectfbpaintdevice.cpp | 19 +++---- .../gfxdrivers/directfb/qdirectfbpaintdevice.h | 18 +++---- .../gfxdrivers/directfb/qdirectfbpixmap.cpp | 2 +- src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h | 2 +- .../gfxdrivers/directfb/qdirectfbscreen.cpp | 62 +++++++++------------- src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 18 ++++++- .../gfxdrivers/directfb/qdirectfbwindowsurface.cpp | 12 ++--- 8 files changed, 66 insertions(+), 69 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp index 15fb6f4..694ba51 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp @@ -101,7 +101,7 @@ QDirectFBMouseHandlerPrivate::QDirectFBMouseHandlerPrivate(QDirectFBMouseHandler #endif DFBInputDeviceCapabilities caps; - caps = DFBInputDeviceCapabilities(DICAPS_BUTTONS | DICAPS_AXES); + caps = DICAPS_BUTTONS | DICAPS_AXES; result = fb->CreateInputEventBuffer(fb, caps, DFB_TRUE, &eventBuffer); if (result != DFB_OK) { DirectFBError("QDirectFBMouseHandler: " diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp index 178dbae..8ad5264 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp @@ -56,20 +56,17 @@ IDirectFBSurface *QDirectFBPaintDevice::directFBSurface() const } -void QDirectFBPaintDevice::lockDirectFB(uint flags) +void QDirectFBPaintDevice::lockDirectFB(DFBSurfaceLockFlags flags) { if (!(lock & flags)) { if (lock) unlockDirectFB(); - if ((mem = QDirectFBScreen::lockSurface(dfbSurface, flags, &bpl))) { - const QSize s = size(); - lockedImage = new QImage(mem, s.width(), s.height(), bpl, - QDirectFBScreen::getImageFormat(dfbSurface)); - lock = flags; - Q_ASSERT(mem); - } else { - lock = 0; - } + mem = QDirectFBScreen::lockSurface(dfbSurface, flags, &bpl); + Q_ASSERT(mem); + const QSize s = size(); + lockedImage = new QImage(mem, s.width(), s.height(), bpl, + QDirectFBScreen::getImageFormat(dfbSurface)); + lock = flags; } } @@ -83,7 +80,7 @@ void QDirectFBPaintDevice::unlockDirectFB() delete lockedImage; lockedImage = 0; mem = 0; - lock = 0; + lock = DFBSurfaceLockFlags(0); } diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h index 32c49bb..248a15b 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h @@ -51,14 +51,14 @@ QT_BEGIN_HEADER QT_MODULE(Gui) // Inherited by both window surface and pixmap -class QDirectFBPaintDevice : public QCustomRasterPaintDevice + class QDirectFBPaintDevice : public QCustomRasterPaintDevice { public: ~QDirectFBPaintDevice(); IDirectFBSurface *directFBSurface() const; - void lockDirectFB(uint flags); + void lockDirectFB(DFBSurfaceLockFlags lock); void unlockDirectFB(); // Reimplemented from QCustomRasterPaintDevice: @@ -67,16 +67,12 @@ public: int bytesPerLine() const; QSize size() const; int metric(QPaintDevice::PaintDeviceMetric metric) const; - uint lockFlags() const { return lock; } + DFBSurfaceLockFlags lockFlags() const { return lock; } protected: // Shouldn't create QDirectFBPaintDevice by itself but only sub-class it: QDirectFBPaintDevice(QDirectFBScreen *scr = QDirectFBScreen::instance()) - : QCustomRasterPaintDevice(0), - dfbSurface(0), - lockedImage(0), - screen(scr), - lock(0), - mem(0) + : QCustomRasterPaintDevice(0), dfbSurface(0), lockedImage(0), screen(scr), + lock(DFBSurfaceLockFlags(0)), mem(0) {} inline int dotsPerMeterX() const @@ -92,11 +88,11 @@ protected: QImage *lockedImage; QDirectFBScreen *screen; int bpl; - uint lock; + DFBSurfaceLockFlags lock; uchar *mem; private: Q_DISABLE_COPY(QDirectFBPaintDevice) -}; + }; QT_END_HEADER diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index c75cba6..dd7faf3 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -374,7 +374,7 @@ QImage *QDirectFBPixmapData::buffer() return lockedImage; } -QImage * QDirectFBPixmapData::buffer(uint lockFlags) +QImage * QDirectFBPixmapData::buffer(DFBSurfaceLockFlags lockFlags) { lockDirectFB(lockFlags); return lockedImage; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h index ad6c38e..8f3ce41 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h @@ -70,7 +70,7 @@ public: QImage toImage() const; QPaintEngine* paintEngine() const; virtual QImage *buffer(); - QImage *buffer(uint lockFlags); + QImage *buffer(DFBSurfaceLockFlags lockFlags); // Pure virtual in QPixmapData, so re-implement here and delegate to QDirectFBPaintDevice int metric(QPaintDevice::PaintDeviceMetric m) const {return QDirectFBPaintDevice::metric(m);} diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index b2e424c..ecead0b 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -208,7 +208,7 @@ IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QSize &size, { DFBSurfaceDescription desc; memset(&desc, 0, sizeof(DFBSurfaceDescription)); - desc.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH|DSDESC_HEIGHT); + desc.flags |= DSDESC_WIDTH|DSDESC_HEIGHT; if (!QDirectFBScreen::initSurfaceDescriptionPixelFormat(&desc, format)) return 0; desc.width = size.width(); @@ -230,9 +230,9 @@ IDirectFBSurface *QDirectFBScreen::createDFBSurface(DFBSurfaceDescription desc, // Add the video only capability. This means the surface will be created in video ram if (!(desc.flags & DSDESC_CAPS)) { desc.caps = DSCAPS_VIDEOONLY; - desc.flags = DFBSurfaceDescriptionFlags(desc.flags | DSDESC_CAPS); + desc.flags |= DSDESC_CAPS; } else { - desc.caps = DFBSurfaceCapabilities(desc.caps | DSCAPS_VIDEOONLY); + desc.caps |= DSCAPS_VIDEOONLY; } result = d_ptr->dfb->CreateSurface(d_ptr->dfb, &desc, &newSurface); if (result != DFB_OK @@ -247,11 +247,11 @@ IDirectFBSurface *QDirectFBScreen::createDFBSurface(DFBSurfaceDescription desc, desc.preallocated[0].data, desc.preallocated[0].pitch, DirectFBErrorString(result)); } - desc.caps = DFBSurfaceCapabilities(desc.caps & ~DSCAPS_VIDEOONLY); + desc.caps &= ~DSCAPS_VIDEOONLY; } if (d_ptr->directFBFlags & SystemOnly) - desc.caps = DFBSurfaceCapabilities(desc.caps | DSCAPS_SYSTEMONLY); + desc.caps |= DSCAPS_SYSTEMONLY; if (!newSurface) result = d_ptr->dfb->CreateSurface(d_ptr->dfb, &desc, &newSurface); @@ -459,20 +459,16 @@ DFBSurfaceDescription QDirectFBScreen::getSurfaceDescription(const QImage &image const DFBSurfacePixelFormat format = getSurfacePixelFormat(image.format()); if (format == DSPF_UNKNOWN || image.isNull()) { - description.flags = DFBSurfaceDescriptionFlags(0); + description.flags = DSDESC_NONE; return description; } - description.flags = DFBSurfaceDescriptionFlags(DSDESC_WIDTH - | DSDESC_HEIGHT -#ifndef QT_NO_DIRECTFB_PREALLOCATED - | DSDESC_PREALLOCATED -#endif - | DSDESC_PIXELFORMAT); + description.flags = DSDESC_WIDTH|DSDESC_HEIGHT|DSDESC_PIXELFORMAT; QDirectFBScreen::initSurfaceDescriptionPixelFormat(&description, image.format()); description.width = image.width(); description.height = image.height(); #ifndef QT_NO_DIRECTFB_PREALLOCATED + description.flags |= DSDESC_PREALLOCATED; description.preallocated[0].data = (void*)(image.bits()); description.preallocated[0].pitch = image.bytesPerLine(); description.preallocated[1].data = 0; @@ -491,11 +487,7 @@ DFBSurfaceDescription QDirectFBScreen::getSurfaceDescription(const uint *buffer, DFBSurfaceDescription description; memset(&description, 0, sizeof(DFBSurfaceDescription)); - description.flags = DFBSurfaceDescriptionFlags(DSDESC_CAPS - | DSDESC_WIDTH - | DSDESC_HEIGHT - | DSDESC_PIXELFORMAT - | DSDESC_PREALLOCATED); + description.flags = DSDESC_CAPS|DSDESC_WIDTH|DSDESC_HEIGHT|DSDESC_PIXELFORMAT|DSDESC_PREALLOCATED; description.caps = DSCAPS_PREMULTIPLIED; description.width = length; description.height = 1; @@ -504,8 +496,7 @@ DFBSurfaceDescription QDirectFBScreen::getSurfaceDescription(const uint *buffer, description.preallocated[0].pitch = length * sizeof(uint); description.preallocated[1].data = 0; description.preallocated[1].pitch = 0; - - return description; +return description; } #ifndef QT_NO_DIRECTFB_PALETTE @@ -727,19 +718,19 @@ void QDirectFBScreenPrivate::setFlipFlags(const QStringList &args) flipFlags = DSFLIP_NONE; foreach(const QString &flip, flips) { if (flip == QLatin1String("wait")) - flipFlags = DFBSurfaceFlipFlags(flipFlags | DSFLIP_WAIT); + flipFlags |= DSFLIP_WAIT; else if (flip == QLatin1String("blit")) - flipFlags = DFBSurfaceFlipFlags(flipFlags | DSFLIP_BLIT); + flipFlags |= DSFLIP_BLIT; else if (flip == QLatin1String("onsync")) - flipFlags = DFBSurfaceFlipFlags(flipFlags | DSFLIP_ONSYNC); + flipFlags |= DSFLIP_ONSYNC; else if (flip == QLatin1String("pipeline")) - flipFlags = DFBSurfaceFlipFlags(flipFlags | DSFLIP_PIPELINE); + flipFlags |= DSFLIP_PIPELINE; else qWarning("QDirectFBScreen: Unknown flip argument: %s", qPrintable(flip)); } } else { - flipFlags = DFBSurfaceFlipFlags(DSFLIP_BLIT); + flipFlags = DSFLIP_BLIT; } } @@ -933,13 +924,13 @@ bool QDirectFBScreen::connect(const QString &displaySpec) DFBSurfaceDescription description; memset(&description, 0, sizeof(DFBSurfaceDescription)); - description.flags = DFBSurfaceDescriptionFlags(DSDESC_CAPS); + description.flags = DSDESC_CAPS; if (::setIntOption(displayArgs, QLatin1String("width"), &description.width)) - description.flags = DFBSurfaceDescriptionFlags(description.flags | DSDESC_WIDTH); + description.flags |= DSDESC_WIDTH; if (::setIntOption(displayArgs, QLatin1String("height"), &description.height)) - description.flags = DFBSurfaceDescriptionFlags(description.flags | DSDESC_HEIGHT); + description.flags |= DSDESC_HEIGHT; - uint caps = DSCAPS_PRIMARY|DSCAPS_DOUBLE; + description.caps = DSCAPS_PRIMARY|DSCAPS_DOUBLE; struct { const char *name; const DFBSurfaceCapabilities cap; @@ -953,14 +944,13 @@ bool QDirectFBScreen::connect(const QString &displaySpec) }; for (int i=0; capabilities[i].name; ++i) { if (displayArgs.contains(QString::fromLatin1(capabilities[i].name), Qt::CaseInsensitive)) - caps |= capabilities[i].cap; + description.caps |= capabilities[i].cap; } if (displayArgs.contains(QLatin1String("forcepremultiplied"), Qt::CaseInsensitive)) { - caps |= DSCAPS_PREMULTIPLIED; + description.caps |= DSCAPS_PREMULTIPLIED; } - description.caps = DFBSurfaceCapabilities(caps); // We don't track the primary surface as it's released in disconnect d_ptr->dfbSurface = createDFBSurface(description, DontTrackSurface); if (!d_ptr->dfbSurface) { @@ -1218,10 +1208,10 @@ void QDirectFBScreen::compose(const QRegion ®ion) DFBSurfaceBlittingFlags flags = DSBLIT_NOFX; if (!win->isOpaque()) { - flags = DFBSurfaceBlittingFlags(flags | DSBLIT_BLEND_ALPHACHANNEL); + flags |= DSBLIT_BLEND_ALPHACHANNEL; const uint opacity = win->opacity(); if (opacity < 255) { - flags = DFBSurfaceBlittingFlags(flags | DSBLIT_BLEND_COLORALPHA); + flags |= DSBLIT_BLEND_COLORALPHA; d_ptr->dfbSurface->SetColor(d_ptr->dfbSurface, 0xff, 0xff, 0xff, opacity); } } @@ -1361,14 +1351,14 @@ bool QDirectFBScreen::initSurfaceDescriptionPixelFormat(DFBSurfaceDescription *d const DFBSurfacePixelFormat pixelformat = QDirectFBScreen::getSurfacePixelFormat(format); if (pixelformat == DSPF_UNKNOWN) return false; - description->flags = DFBSurfaceDescriptionFlags(description->flags | DSDESC_PIXELFORMAT); + description->flags |= DSDESC_PIXELFORMAT; description->pixelformat = pixelformat; if (QDirectFBScreen::isPremultiplied(format)) { if (!(description->flags & DSDESC_CAPS)) { description->caps = DSCAPS_PREMULTIPLIED; - description->flags = DFBSurfaceDescriptionFlags(description->flags | DSDESC_CAPS); + description->flags |= DSDESC_CAPS; } else { - description->caps = DFBSurfaceCapabilities(description->caps | DSCAPS_PREMULTIPLIED); + description->caps |= DSCAPS_PREMULTIPLIED; } } return true; diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index c2c9a59..9d1e670 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -51,8 +51,24 @@ QT_MODULE(Gui) #define Q_DIRECTFB_VERSION ((DIRECTFB_MAJOR_VERSION << 16) | (DIRECTFB_MINOR_VERION << 8) | DIRECTFB_MICRO_VERSION) -class QDirectFBScreenPrivate; +#include +#define DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(F) \ + static inline F operator~(F f) { return F(~int(f)); } \ + static inline F operator&(F left, F right) { return F(int(left) & int(right)); } \ + static inline F operator|(F left, F right) { return F(int(left) | int(right)); } \ + static inline F &operator|=(F &left, F right) { left = (left | right); return left; } \ + static inline F &operator&=(F &left, F right) { left = (left & right); return left; } + +DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBInputDeviceCapabilities); +DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBWindowDescriptionFlags); +DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceDescriptionFlags); +DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceCapabilities); +DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceLockFlags); +DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceBlittingFlags); +DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceDrawingFlags); +DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceFlipFlags); +class QDirectFBScreenPrivate; class Q_GUI_EXPORT QDirectFBScreen : public QScreen { public: diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp index 86ee62c..7dcf398 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp @@ -106,18 +106,16 @@ void QDirectFBWindowSurface::createWindow() qFatal("QDirectFBWindowSurface: Unable to get primary display layer!"); DFBWindowDescription description; - description.caps = DFBWindowCapabilities(DWCAPS_NODECORATION); - description.flags = DFBWindowDescriptionFlags(DWDESC_CAPS - |DWDESC_SURFACE_CAPS - |DWDESC_PIXELFORMAT); + description.caps = DWCAPS_NODECORATION; + description.flags = DWDESC_CAPS|DWDESC_SURFACE_CAPS|DWDESC_PIXELFORMAT; description.surface_caps = DSCAPS_NONE; if (screen->directFBFlags() & QDirectFBScreen::VideoOnly) - description.surface_caps = DFBSurfaceCapabilities(description.surface_caps|DSCAPS_VIDEOONLY); + description.surface_caps |= DSCAPS_VIDEOONLY; const QImage::Format format = screen->pixelFormat(); description.pixelformat = QDirectFBScreen::getSurfacePixelFormat(format); if (QDirectFBScreen::isPremultiplied(format)) - description.surface_caps = DFBSurfaceCapabilities(DSCAPS_PREMULTIPLIED|description.caps); + description.surface_caps = DSCAPS_PREMULTIPLIED; DFBResult result = layer->CreateWindow(layer, &description, &dfbWindow); if (result != DFB_OK) @@ -370,7 +368,7 @@ void QDirectFBWindowSurface::flush(QWidget *widget, const QRegion ®ion, } else { if (!boundingRectFlip && region.numRects() > 1) { const QVector rects = region.rects(); - const DFBSurfaceFlipFlags nonWaitFlags = DFBSurfaceFlipFlags(flipFlags & ~DSFLIP_WAIT); + const DFBSurfaceFlipFlags nonWaitFlags = flipFlags & ~DSFLIP_WAIT; for (int i=0; i Date: Fri, 17 Jul 2009 03:17:06 -0700 Subject: Don't create dfbsurface in video mem if systemonly If DSCAPS_SYSTEMONLY is specified we shouldn't try to create the surface in video memory. Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index ecead0b..0928643 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -226,7 +226,9 @@ IDirectFBSurface *QDirectFBScreen::createDFBSurface(DFBSurfaceDescription desc, return 0; } - if (d_ptr->directFBFlags & VideoOnly && !(desc.flags & DSDESC_PREALLOCATED)) { + if (d_ptr->directFBFlags & VideoOnly + && !(desc.flags & DSDESC_PREALLOCATED) + && (!(desc.flags & DSDESC_CAPS) || !(desc.caps & DSCAPS_SYSTEMONLY))) { // Add the video only capability. This means the surface will be created in video ram if (!(desc.flags & DSDESC_CAPS)) { desc.caps = DSCAPS_VIDEOONLY; -- cgit v0.12 From 7ddc0e5fb477a9bacb4093878fb0ab0d083b7e3f Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 17 Jul 2009 03:25:06 -0700 Subject: Remove unused function in QDirectFBPaintEngine drawColorSpan is never called from anywhere so we might as well get rid of the code. Reviewed-by: TrustMe --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 32 ---------------------- .../gfxdrivers/directfb/qdirectfbpaintengine.h | 2 -- 2 files changed, 34 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 305d5be..2245acc 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -672,38 +672,6 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color) } } -void QDirectFBPaintEngine::drawColorSpans(const QSpan *spans, int count, - uint color) -{ - Q_D(QDirectFBPaintEngine); - color = INV_PREMUL(color); - - QVarLengthArray lines(count); - int j = 0; - for (int i = 0; i < count; ++i) { - if (spans[i].coverage == 255) { - lines[j].x1 = spans[i].x; - lines[j].y1 = spans[i].y; - lines[j].x2 = spans[i].x + spans[i].len - 1; - lines[j].y2 = spans[i].y; - ++j; - } else { - DFBSpan span = { spans[i].x, spans[i].len }; - uint c = BYTE_MUL(color, spans[i].coverage); - // ### how does this play with setDFBColor - d->surface->SetColor(d->surface, - qRed(c), qGreen(c), qBlue(c), qAlpha(c)); - d->surface->FillSpans(d->surface, spans[i].y, &span, 1); - } - } - if (j > 0) { - d->surface->SetColor(d->surface, - qRed(color), qGreen(color), qBlue(color), - qAlpha(color)); - d->surface->DrawLines(d->surface, lines.data(), j); - } -} - void QDirectFBPaintEngine::drawBufferSpan(const uint *buffer, int bufsize, int x, int y, int length, uint const_alpha) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h index 8c5877b..e57fcc9 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h @@ -78,11 +78,9 @@ public: void drawPixmap(const QRectF &r, const QPixmap &pixmap, const QRectF &sr); void drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr); - void drawColorSpans(const QSpan *spans, int count, uint color); void drawBufferSpan(const uint *buffer, int bufsize, int x, int y, int length, uint const_alpha); - // The following methods simply lock the surface & call the base implementation void stroke(const QVectorPath &path, const QPen &pen); void drawPath(const QPainterPath &path); -- cgit v0.12 From cb169009f99147d6f9e619b0e7cee2be92cbd82e Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 17 Jul 2009 03:26:43 -0700 Subject: Mark virtual functions as virtual in DFBPaintEng Make the code easier to read. Reviewed-by: TrustMe --- .../gfxdrivers/directfb/qdirectfbpaintengine.h | 53 +++++++++++----------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h index e57fcc9..6148b14 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h @@ -56,41 +56,40 @@ class QDirectFBPaintEngine : public QRasterPaintEngine Q_DECLARE_PRIVATE(QDirectFBPaintEngine) public: QDirectFBPaintEngine(QPaintDevice *device); - ~QDirectFBPaintEngine(); + virtual ~QDirectFBPaintEngine(); - bool begin(QPaintDevice *device); - bool end(); + virtual bool begin(QPaintDevice *device); + virtual bool end(); - void drawRects(const QRect *rects, int rectCount); - void drawRects(const QRectF *rects, int rectCount); + virtual void drawRects(const QRect *rects, int rectCount); + virtual void drawRects(const QRectF *rects, int rectCount); - void fillRect(const QRectF &r, const QBrush &brush); - void fillRect(const QRectF &r, const QColor &color); + virtual void fillRect(const QRectF &r, const QBrush &brush); + virtual void fillRect(const QRectF &r, const QColor &color); - void drawLines(const QLine *line, int lineCount); - void drawLines(const QLineF *line, int lineCount); + virtual void drawLines(const QLine *line, int lineCount); + virtual void drawLines(const QLineF *line, int lineCount); - void drawImage(const QPointF &p, const QImage &img); - void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, - Qt::ImageConversionFlags falgs = Qt::AutoColor); + virtual void drawImage(const QPointF &p, const QImage &img); + virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, + Qt::ImageConversionFlags falgs = Qt::AutoColor); - void drawPixmap(const QPointF &p, const QPixmap &pm); - void drawPixmap(const QRectF &r, const QPixmap &pixmap, const QRectF &sr); - void drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr); + virtual void drawPixmap(const QPointF &p, const QPixmap &pm); + virtual void drawPixmap(const QRectF &r, const QPixmap &pixmap, const QRectF &sr); + virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr); - void drawBufferSpan(const uint *buffer, int bufsize, - int x, int y, int length, uint const_alpha); + virtual void drawBufferSpan(const uint *buffer, int bufsize, + int x, int y, int length, uint const_alpha); - // The following methods simply lock the surface & call the base implementation - void stroke(const QVectorPath &path, const QPen &pen); - void drawPath(const QPainterPath &path); - void drawPoints(const QPointF *points, int pointCount); - void drawPoints(const QPoint *points, int pointCount); - void drawEllipse(const QRectF &rect); - void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode); - void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode); - void drawTextItem(const QPointF &p, const QTextItem &textItem); - void fill(const QVectorPath &path, const QBrush &brush); + virtual void stroke(const QVectorPath &path, const QPen &pen); + virtual void drawPath(const QPainterPath &path); + virtual void drawPoints(const QPointF *points, int pointCount); + virtual void drawPoints(const QPoint *points, int pointCount); + virtual void drawEllipse(const QRectF &rect); + virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode); + virtual void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode); + virtual void drawTextItem(const QPointF &p, const QTextItem &textItem); + virtual void fill(const QVectorPath &path, const QBrush &brush); virtual void clipEnabledChanged(); virtual void penChanged(); -- cgit v0.12 From 7d4a3a102c562d057c7fa5de900fe4a6c662dda4 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Fri, 17 Jul 2009 05:17:23 -0700 Subject: Prepare device in DFBPaintEngine::begin 86ea4dbb5a748491656d9621ecd58238bc3e3d82 accidentally took out this line. Reviewed-by: TrustMe --- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 2245acc..94f1aeb 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -232,6 +232,8 @@ bool QDirectFBPaintEngine::begin(QPaintDevice *device) device->devType()); } + d->prepare(d->dfbDevice); + return QRasterPaintEngine::begin(device); } -- cgit v0.12 From 1d52548c21f9ca47e2ef02cd944b7640b0d4dd6b Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Fri, 17 Jul 2009 14:24:35 +0200 Subject: QUdpSocket: Doc improvement Task-number: 236891 Reviewed-By: David Boddie --- src/network/socket/qudpsocket.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/network/socket/qudpsocket.cpp b/src/network/socket/qudpsocket.cpp index ea7753c..797becb 100644 --- a/src/network/socket/qudpsocket.cpp +++ b/src/network/socket/qudpsocket.cpp @@ -70,6 +70,9 @@ pendingDatagramSize() to obtain the size of the first pending datagram, and readDatagram() to read it. + \note An incoming datagram should be read when you receive the readyRead() + signal, otherwise this signal will not be emitted for the next datagram. + Example: \snippet doc/src/snippets/code/src_network_socket_qudpsocket.cpp 0 -- cgit v0.12 From b4d801bf4d6e664ad729e3e95b212b83cc0c784f Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 17 Jul 2009 16:16:31 +0200 Subject: reorganize numerus form count normalization replace implicit normalization of individual messages on file writeout with global normalization which is called by the command line tools. this should a) be faster and b) cover the most critical case: lrelease. --- tools/linguist/lconvert/main.cpp | 5 ++++ tools/linguist/linguist/messagemodel.cpp | 2 +- tools/linguist/lrelease/main.cpp | 1 + tools/linguist/lupdate/main.cpp | 5 ++++ tools/linguist/shared/po.cpp | 4 +-- tools/linguist/shared/translator.cpp | 42 ++++++++++++++++++++------------ tools/linguist/shared/translator.h | 4 +-- tools/linguist/shared/ts.cpp | 4 +-- tools/linguist/shared/xliff.cpp | 14 +++++------ 9 files changed, 51 insertions(+), 30 deletions(-) diff --git a/tools/linguist/lconvert/main.cpp b/tools/linguist/lconvert/main.cpp index ddde578..553ce6e 100644 --- a/tools/linguist/lconvert/main.cpp +++ b/tools/linguist/lconvert/main.cpp @@ -238,6 +238,11 @@ int main(int argc, char *argv[]) if (dropTranslations) tr.dropTranslations(); + tr.normalizeTranslations(cd); + if (!cd.errors().isEmpty()) { + qWarning("%s", qPrintable(cd.error())); + cd.clearErrors(); + } if (!tr.save(outFileName, cd, outFormat)) { qWarning("%s", qPrintable(cd.error())); return 3; diff --git a/tools/linguist/linguist/messagemodel.cpp b/tools/linguist/linguist/messagemodel.cpp index 6bbf6f3..9995220 100644 --- a/tools/linguist/linguist/messagemodel.cpp +++ b/tools/linguist/linguist/messagemodel.cpp @@ -139,7 +139,7 @@ DataModel::DataModel(QObject *parent) QStringList DataModel::normalizedTranslations(const MessageItem &m) const { - return Translator::normalizedTranslations(m.message(), m_language, m_country); + return Translator::normalizedTranslations(m.message(), m_numerusForms.count()); } ContextItem *DataModel::contextItem(int context) const diff --git a/tools/linguist/lrelease/main.cpp b/tools/linguist/lrelease/main.cpp index 845dcb8..843414d 100644 --- a/tools/linguist/lrelease/main.cpp +++ b/tools/linguist/lrelease/main.cpp @@ -120,6 +120,7 @@ static bool releaseTranslator(Translator &tor, const QString &qmFileName, } ConversionData cd; + tor.normalizeTranslations(cd); cd.m_verbose = verbose; cd.m_ignoreUnfinished = ignoreUnfinished; cd.m_saveMode = mode; diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp index 78e5b5f..cedc01e 100644 --- a/tools/linguist/lupdate/main.cpp +++ b/tools/linguist/lupdate/main.cpp @@ -199,6 +199,11 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil out.stripObsoleteMessages(); out.stripEmptyContexts(); + out.normalizeTranslations(cd); + if (!cd.errors().isEmpty()) { + printOut(cd.error()); + cd.clearErrors(); + } if (!out.save(fileName, cd, QLatin1String("auto"))) { printOut(cd.error()); *fail = true; diff --git a/tools/linguist/shared/po.cpp b/tools/linguist/shared/po.cpp index cb943be..a197b25 100644 --- a/tools/linguist/shared/po.cpp +++ b/tools/linguist/shared/po.cpp @@ -547,7 +547,7 @@ bool loadPO(Translator &translator, QIODevice &dev, ConversionData &cd) return !error && cd.errors().isEmpty(); } -bool savePO(const Translator &translator, QIODevice &dev, ConversionData &cd) +bool savePO(const Translator &translator, QIODevice &dev, ConversionData &) { bool ok = true; QTextStream out(&dev); @@ -633,7 +633,7 @@ bool savePO(const Translator &translator, QIODevice &dev, ConversionData &cd) if (plural.isEmpty()) plural = msg.sourceText(); out << poEscapedString(prefix, QLatin1String("msgid_plural"), noWrap, plural); - QStringList translations = translator.normalizedTranslations(msg, cd, &ok); + const QStringList &translations = msg.translations(); for (int i = 0; i != translations.size(); ++i) { out << poEscapedString(prefix, QString::fromLatin1("msgstr[%1]").arg(i), noWrap, translations.at(i)); diff --git a/tools/linguist/shared/translator.cpp b/tools/linguist/shared/translator.cpp index b8d559f..e5b8932 100644 --- a/tools/linguist/shared/translator.cpp +++ b/tools/linguist/shared/translator.cpp @@ -497,16 +497,10 @@ QList Translator::translatedMessages() const return result; } -QStringList Translator::normalizedTranslations(const TranslatorMessage &msg, - QLocale::Language language, QLocale::Country country) +QStringList Translator::normalizedTranslations(const TranslatorMessage &msg, int numPlurals) { QStringList translations = msg.translations(); - int numTranslations = 1; - if (msg.isPlural() && language != QLocale::C) { - QStringList forms; - if (getNumerusInfo(language, country, 0, &forms)) - numTranslations = forms.count(); // includes singular - } + int numTranslations = msg.isPlural() ? numPlurals : 1; // make sure that the stringlist always have the size of the // language's current numerus, or 1 if its not plural @@ -520,21 +514,39 @@ QStringList Translator::normalizedTranslations(const TranslatorMessage &msg, return translations; } -QStringList Translator::normalizedTranslations(const TranslatorMessage &msg, - ConversionData &cd, bool *ok) const +void Translator::normalizeTranslations(ConversionData &cd) { + bool truncated = false; QLocale::Language l; QLocale::Country c; languageAndCountry(languageCode(), &l, &c); - QStringList translns = normalizedTranslations(msg, l, c); - if (msg.translations().size() > translns.size() && ok) { + int numPlurals = 1; + if (l != QLocale::C) { + QStringList forms; + if (getNumerusInfo(l, c, 0, &forms)) + numPlurals = forms.count(); // includes singular + } + for (int i = 0; i < m_messages.count(); ++i) { + const TranslatorMessage &msg = m_messages.at(i); + QStringList tlns = msg.translations(); + int ccnt = msg.isPlural() ? numPlurals : 1; + if (tlns.count() != ccnt) { + while (tlns.count() < ccnt) + tlns.append(QString()); + while (tlns.count() > ccnt) { + tlns.removeLast(); + truncated = true; + } + TranslatorMessage msg2(msg); + msg2.setTranslations(tlns); + m_messages[i] = msg2; + } + } + if (truncated) cd.appendError(QLatin1String( "Removed plural forms as the target language has less " "forms.\nIf this sounds wrong, possibly the target language is " "not set or recognized.\n")); - *ok = false; - } - return translns; } QString Translator::guessLanguageCodeFromFileName(const QString &filename) diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h index 77b515f..01778d7 100644 --- a/tools/linguist/shared/translator.h +++ b/tools/linguist/shared/translator.h @@ -150,8 +150,8 @@ public: static QString guessLanguageCodeFromFileName(const QString &fileName); QList messages() const; QList translatedMessages() const; - static QStringList normalizedTranslations(const TranslatorMessage &m, - QLocale::Language lang, QLocale::Country country); + static QStringList normalizedTranslations(const TranslatorMessage &m, int numPlurals); + void normalizeTranslations(ConversionData &cd); QStringList normalizedTranslations(const TranslatorMessage &m, ConversionData &cd, bool *ok) const; int messageCount() const { return m_messages.size(); } diff --git a/tools/linguist/shared/ts.cpp b/tools/linguist/shared/ts.cpp index 6c95dbd..a0ce727 100644 --- a/tools/linguist/shared/ts.cpp +++ b/tools/linguist/shared/ts.cpp @@ -693,8 +693,8 @@ bool saveTS(const Translator &translator, QIODevice &dev, ConversionData &cd, in t << " type=\"obsolete\""; if (msg.isPlural()) { t << ">"; - QStringList translns = translator.normalizedTranslations(msg, cd, &result); - for (int j = 0; j < qMax(1, translns.count()); ++j) { + const QStringList &translns = msg.translations(); + for (int j = 0; j < translns.count(); ++j) { t << "\n "; diff --git a/tools/linguist/shared/xliff.cpp b/tools/linguist/shared/xliff.cpp index 61e4b9f..969d5d4 100644 --- a/tools/linguist/shared/xliff.cpp +++ b/tools/linguist/shared/xliff.cpp @@ -243,13 +243,12 @@ static void writeComment(QTextStream &ts, const TranslatorMessage &msg, const QR } } -static void writeTransUnits(QTextStream &ts, const TranslatorMessage &msg, const QRegExp &drops, int indent, - const Translator &translator, ConversionData &cd, bool *ok) +static void writeTransUnits(QTextStream &ts, const TranslatorMessage &msg, const QRegExp &drops, int indent) { static int msgid; QString msgidstr = !msg.id().isEmpty() ? msg.id() : QString::fromAscii("_msg%1").arg(++msgid); - QStringList translns = translator.normalizedTranslations(msg, cd, ok); + QStringList translns = msg.translations(); QHash::const_iterator it; QString pluralStr; QStringList sources(msg.sourceText()); @@ -347,8 +346,7 @@ static void writeTransUnits(QTextStream &ts, const TranslatorMessage &msg, const } } -static void writeMessage(QTextStream &ts, const TranslatorMessage &msg, const QRegExp &drops, int indent, - const Translator &translator, ConversionData &cd, bool *ok) +static void writeMessage(QTextStream &ts, const TranslatorMessage &msg, const QRegExp &drops, int indent) { if (msg.isPlural()) { writeIndent(ts, indent); @@ -362,12 +360,12 @@ static void writeMessage(QTextStream &ts, const TranslatorMessage &msg, const QR writeLineNumber(ts, msg, indent); writeComment(ts, msg, drops, indent); - writeTransUnits(ts, msg, drops, indent, translator, cd, ok); + writeTransUnits(ts, msg, drops, indent); --indent; writeIndent(ts, indent); ts << "\n"; } else { - writeTransUnits(ts, msg, drops, indent, translator, cd, ok); + writeTransUnits(ts, msg, drops, indent); } } @@ -790,7 +788,7 @@ bool saveXLIFF(const Translator &translator, QIODevice &dev, ConversionData &cd) } foreach (const TranslatorMessage &msg, messageOrder[fn][ctx]) - writeMessage(ts, msg, drops, indent, translator, cd, &ok); + writeMessage(ts, msg, drops, indent); if (!ctx.isEmpty()) { --indent; -- cgit v0.12 From 079f46af1a5821f981fcb53bf7484885f18b5b86 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 17 Jul 2009 16:17:41 +0200 Subject: Fix deadlock in the QWS server when destroying lots of windows First, don't call QWSWindowSurface::winId() in the destructor, as it will actually request a new id if there isn't already one around - which is a bit silly and highlighted the "real" bug. Second, make sure QWSDisplay::Data::takeId() asks for 1 new id before waiting for more ids to arrive. This is because waitForCreation() calls QWSServer::processEventQueue(). If the events in the queue cause takeId() to be called, QWSDisplay::Data::takeId() gets called recursively. Even though there will be a create 15 ids command in the queue, that will only allow 15 QWSDisplay::Data::takeId() calls to return. The 16th call to QWSDisplay::Data::takeId() on the stack will not be able to return because all the IDs have been taken and (because it has been called recursively) no new create id commands have been generated. So the 16th call to takeId() spins in waitForCreate(). Reviewed-by: Paul --- src/gui/kernel/qapplication_qws.cpp | 8 ++++++-- src/gui/painting/qwindowsurface_qws.cpp | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qapplication_qws.cpp b/src/gui/kernel/qapplication_qws.cpp index 1e158fc..ab2062c 100644 --- a/src/gui/kernel/qapplication_qws.cpp +++ b/src/gui/kernel/qapplication_qws.cpp @@ -661,10 +661,14 @@ void QWSDisplay::Data::sendSynchronousCommand(QWSCommand & cmd) int QWSDisplay::Data::takeId() { - if (unused_identifiers.count() == 10) + int unusedIdCount = unused_identifiers.count(); + if (unusedIdCount == 10) create(15); - if (unused_identifiers.count() == 0) + if (unusedIdCount == 0) { + create(1); // Make sure we have an incoming id to wait for, just in case we're recursive waitForCreation(); + } + return unused_identifiers.takeFirst(); } diff --git a/src/gui/painting/qwindowsurface_qws.cpp b/src/gui/painting/qwindowsurface_qws.cpp index 639bc92..d5a5c20 100644 --- a/src/gui/painting/qwindowsurface_qws.cpp +++ b/src/gui/painting/qwindowsurface_qws.cpp @@ -421,7 +421,8 @@ QWSWindowSurface::QWSWindowSurface(QWidget *widget) QWSWindowSurface::~QWSWindowSurface() { #ifdef Q_BACKINGSTORE_SUBSURFACES - winIdToSurfaceMap()->remove(winId()); + if (d_ptr->winId) + winIdToSurfaceMap()->remove(d_ptr->winId); #endif delete d_ptr; -- cgit v0.12 From c70fba2e0c2e00171baa46bbb0bb2e6ba0115ec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 17 Jul 2009 18:40:01 +0200 Subject: Test case for QDirIterator regression introduced in 4.5.0 Task-number: 258230 Reviewed-by: Olivier Goffart --- tests/auto/qdiriterator/tst_qdiriterator.cpp | 31 +++++++++++++++++++--------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/tests/auto/qdiriterator/tst_qdiriterator.cpp b/tests/auto/qdiriterator/tst_qdiriterator.cpp index e916e8b..2d5758e 100644 --- a/tests/auto/qdiriterator/tst_qdiriterator.cpp +++ b/tests/auto/qdiriterator/tst_qdiriterator.cpp @@ -183,17 +183,28 @@ void tst_QDirIterator::iterateRelativeDirectory() QFETCH(QStringList, entries); QDirIterator it(dirName, nameFilters, filters, flags); - QStringList iteratorList; - while (it.hasNext()) - iteratorList << it.next(); - - // The order of QDirIterator returning items differs on some platforms. - // Thus it is not guaranteed that all paths will be returned relative - // and we need to assure we have two valid StringLists to compare. So - // we make all entries absolute for comparison. QStringList list; - foreach(QString item, iteratorList) - list.append(QFileInfo(item).canonicalFilePath()); + while (it.hasNext()) { + QString next = it.next(); + + QString fileName = it.fileName(); + QString filePath = it.filePath(); + QString path = it.path(); + + QFileInfo info = it.fileInfo(); + + QCOMPARE(path, dirName); + QCOMPARE(next, filePath); + + QCOMPARE(info, QFileInfo(next)); + QCOMPARE(fileName, info.fileName()); + QCOMPARE(filePath, info.filePath()); + + // Using canonical file paths for final comparison + list << info.canonicalFilePath(); + } + + // The order of items returned by QDirIterator is not guaranteed. list.sort(); QStringList sortedEntries; -- cgit v0.12 From af643f0612f7bd560ccb94cdce91395fc4c9acdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 16 Jul 2009 13:01:05 +0200 Subject: QDirIterator was returning inconsistent data One less variable to maintain reduces the number of bugs and improves consistency. Reviewed-by: Olivier Goffart --- src/corelib/io/qdiriterator.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index 006b205..44ba950 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -119,7 +119,6 @@ public: QFileInfo nextFileInfo; //This fileinfo is the current that we will return from the public API QFileInfo currentFileInfo; - QString currentFilePath; QDirIterator::IteratorFlags iteratorFlags; QDir::Filters filters; QStringList nameFilters; @@ -188,10 +187,6 @@ void QDirIteratorPrivate::pushSubDirectory(const QString &path, const QStringLis */ void QDirIteratorPrivate::advance() { - // Store the current entry - if (!fileEngineIterators.isEmpty()) - currentFilePath = fileEngineIterators.top()->currentFilePath(); - // Advance to the next entry if (followNextDir) { // Start by navigating into the current directory. @@ -534,7 +529,7 @@ QString QDirIterator::fileName() const */ QString QDirIterator::filePath() const { - return d->currentFilePath; + return d->currentFileInfo.filePath(); } /*! -- cgit v0.12 From 62d95b8ef57f097422862cd2fa13f5debfbc8aae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 16 Jul 2009 13:34:34 +0200 Subject: QDirIterator: reducing "randomness" The difference between a canonical and absolute paths is subtle, and not what QDirIterator is about. With this change, we still avoid loops generated by symbolic links but won't duplicate entries because of these differences. While at it, when avoiding loops with symbolic links, please don't mess with the next path! That only added inconsistency. Reviewed-by: Olivier Goffart --- src/corelib/io/qdiriterator.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index 44ba950..d372ed3 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -160,16 +160,9 @@ QDirIteratorPrivate::~QDirIteratorPrivate() void QDirIteratorPrivate::pushSubDirectory(const QString &path, const QStringList &nameFilters, QDir::Filters filters) { - if (iteratorFlags & QDirIterator::FollowSymlinks) { - if (nextFileInfo.filePath() != path) - nextFileInfo.setFile(path); - if (nextFileInfo.isSymLink()) { - visitedLinks << nextFileInfo.canonicalFilePath(); - } else { - visitedLinks << nextFileInfo.absoluteFilePath(); - } - } - + if (iteratorFlags & QDirIterator::FollowSymlinks) + visitedLinks << nextFileInfo.canonicalFilePath(); + if (engine || (engine = QAbstractFileEngine::create(this->path))) { engine->setFileName(path); QAbstractFileEngineIterator *it = engine->beginEntryList(filters, nameFilters); -- cgit v0.12 From c9579d44c6ce70066f90224c18ac964865290583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 16 Jul 2009 17:54:22 +0200 Subject: Refactoring QDirIteratorPrivate::pushSubDirectory pushSubDirectory was operating on nextFileInfo when it should really be using the path received as argument. This fixes an issue introduced when currentFilePath variable was removed, that was exposed in the auto-tests; fixes a regression introduced in 4.5.0 -- test case a couple of commits back. This also allows refactoring calling code and avoid repetition. Task-number: 258230 Reviewed-by: Olivier Goffart --- src/corelib/io/qdiriterator.cpp | 41 +++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index d372ed3..e48a1b9 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -106,7 +106,7 @@ public: QDir::Filters filters, QDirIterator::IteratorFlags flags); ~QDirIteratorPrivate(); - void pushSubDirectory(const QString &path, const QStringList &nameFilters, + void pushSubDirectory(const QFileInfo &fileInfo, const QStringList &nameFilters, QDir::Filters filters); void advance(); bool shouldFollowDirectory(const QFileInfo &); @@ -142,8 +142,7 @@ QDirIteratorPrivate::QDirIteratorPrivate(const QString &path, const QStringList this->nameFilters = nameFilters; nextFileInfo.setFile(path); - pushSubDirectory(nextFileInfo.isSymLink() ? nextFileInfo.canonicalFilePath() : path, - nameFilters, filters); + pushSubDirectory(nextFileInfo, nameFilters, filters); } /*! @@ -157,11 +156,18 @@ QDirIteratorPrivate::~QDirIteratorPrivate() /*! \internal */ -void QDirIteratorPrivate::pushSubDirectory(const QString &path, const QStringList &nameFilters, +void QDirIteratorPrivate::pushSubDirectory(const QFileInfo &fileInfo, const QStringList &nameFilters, QDir::Filters filters) { + QString path = fileInfo.filePath(); + +#ifdef Q_OS_WIN + if (fileInfo.isSymLink()) + path = fileInfo.canonicalFilePath(); +#endif + if (iteratorFlags & QDirIterator::FollowSymlinks) - visitedLinks << nextFileInfo.canonicalFilePath(); + visitedLinks << fileInfo.canonicalFilePath(); if (engine || (engine = QAbstractFileEngine::create(this->path))) { engine->setFileName(path); @@ -183,16 +189,9 @@ void QDirIteratorPrivate::advance() // Advance to the next entry if (followNextDir) { // Start by navigating into the current directory. - followNextDir = false; - QAbstractFileEngineIterator *it = fileEngineIterators.top(); - - QString subDir = it->currentFilePath(); -#ifdef Q_OS_WIN - if (nextFileInfo.isSymLink()) - subDir = nextFileInfo.canonicalFilePath(); -#endif - pushSubDirectory(subDir, it->nameFilters(), it->filters()); + pushSubDirectory(it->currentFileInfo(), it->nameFilters(), it->filters()); + followNextDir = false; } while (!fileEngineIterators.isEmpty()) { @@ -210,18 +209,8 @@ void QDirIteratorPrivate::advance() //We found a matching entry. return; - } else if (iteratorFlags & QDirIterator::Subdirectories) { - QFileInfo fileInfo = it->currentFileInfo(); - - if (!shouldFollowDirectory(fileInfo)) - continue; - QString subDir = it->currentFilePath(); -#ifdef Q_OS_WIN - if (fileInfo.isSymLink()) - subDir = fileInfo.canonicalFilePath(); -#endif - pushSubDirectory(subDir, it->nameFilters(), it->filters()); - + } else if (shouldFollowDirectory(it->currentFileInfo())) { + pushSubDirectory(it->currentFileInfo(), it->nameFilters(), it->filters()); foundDirectory = true; break; } -- cgit v0.12 From 74c0b4300b538b24c56abf2be2d5e09b9c59a845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 16 Jul 2009 19:12:52 +0200 Subject: QDirIterator: Doc fixes and whitespace cleanup There is no QDirIterator::isValid() function. Reviewed-by: David Boddie --- src/corelib/io/qdiriterator.cpp | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/corelib/io/qdiriterator.cpp b/src/corelib/io/qdiriterator.cpp index e48a1b9..ca6f3ce 100644 --- a/src/corelib/io/qdiriterator.cpp +++ b/src/corelib/io/qdiriterator.cpp @@ -230,17 +230,15 @@ bool QDirIteratorPrivate::shouldFollowDirectory(const QFileInfo &fileInfo) // If we're doing flat iteration, we're done. if (!(iteratorFlags & QDirIterator::Subdirectories)) return false; - + // Never follow non-directory entries if (!fileInfo.isDir()) return false; - // Never follow . and .. if (fileInfo.fileName() == QLatin1String(".") || fileInfo.fileName() == QLatin1String("..")) return false; - // Check symlinks if (fileInfo.isSymLink() && !(iteratorFlags & QDirIterator::FollowSymlinks)) { // Follow symlinks only if FollowSymlinks was passed @@ -250,10 +248,9 @@ bool QDirIteratorPrivate::shouldFollowDirectory(const QFileInfo &fileInfo) // Stop link loops if (visitedLinks.contains(fileInfo.canonicalFilePath())) return false; - + return true; } - /*! \internal @@ -315,7 +312,7 @@ bool QDirIteratorPrivate::matchesFilters(const QAbstractFileEngineIterator *it) return false; } #endif - + bool dotOrDotDot = (fileName == QLatin1String(".") || fileName == QLatin1String("..")); if ((filters & QDir::NoDotAndDotDot) && dotOrDotDot) return false; @@ -356,7 +353,7 @@ bool QDirIteratorPrivate::matchesFilters(const QAbstractFileEngineIterator *it) || (!fi.exists() && fi.isSymLink()))) { return false; } - + return true; } @@ -433,7 +430,7 @@ QDirIterator::QDirIterator(const QString &path, IteratorFlags flags) passed to the flags. \warning This constructor expects \c flags to be left at its default value. Use the - constructors that do not take the \a filters argument instead. + constructors that do not take the \a filters argument instead. \sa hasNext(), next(), IteratorFlags */ @@ -488,13 +485,12 @@ bool QDirIterator::hasNext() const /*! Returns the file name for the current directory entry, without the path - prepended. If the current entry is invalid (i.e., isValid() returns - false), a null QString is returned. + prepended. + + This function is convenient when iterating a single directory. When using + the QDirIterator::Subdirectories flag, you can use filePath() to get the + full path. - This function is provided for the convenience when iterating single - directories. For recursive iteration, you should call filePath() or - fileInfo() instead. - \sa filePath(), fileInfo() */ QString QDirIterator::fileName() const @@ -503,9 +499,7 @@ QString QDirIterator::fileName() const } /*! - Returns the full file path for the current directory entry. If the current - entry is invalid (i.e., isValid() returns false), a null QString is - returned. + Returns the full file path for the current directory entry. \sa fileInfo(), fileName() */ @@ -515,8 +509,7 @@ QString QDirIterator::filePath() const } /*! - Returns a QFileInfo for the current directory entry. If the current entry - is invalid (i.e., isValid() returns false), a null QFileInfo is returned. + Returns a QFileInfo for the current directory entry. \sa filePath(), fileName() */ -- cgit v0.12 From 1185386dfe9727ed591da442e97084907f0a6735 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 17 Jul 2009 19:41:23 +0200 Subject: don't rely on system codec when handling PO files - make -input-codec affect PO files, default to UTF-8 - add -output-codec for PO files, same default --- tests/auto/linguist/lconvert/data/test-broken-utf8.po.out | 2 +- tools/linguist/lconvert/main.cpp | 12 +++++++++--- tools/linguist/shared/po.cpp | 5 +++-- tools/linguist/shared/qm.cpp | 3 ++- tools/linguist/shared/translator.h | 3 ++- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/tests/auto/linguist/lconvert/data/test-broken-utf8.po.out b/tests/auto/linguist/lconvert/data/test-broken-utf8.po.out index c00fd19..0a9f4c8 100644 --- a/tests/auto/linguist/lconvert/data/test-broken-utf8.po.out +++ b/tests/auto/linguist/lconvert/data/test-broken-utf8.po.out @@ -6,4 +6,4 @@ msgid "this works" msgstr "das geht: ä" msgid "this is broken" -msgstr "das ist kaputt: i" +msgstr "das ist kaputt: �i" diff --git a/tools/linguist/lconvert/main.cpp b/tools/linguist/lconvert/main.cpp index 553ce6e..fe8d529 100644 --- a/tools/linguist/lconvert/main.cpp +++ b/tools/linguist/lconvert/main.cpp @@ -86,8 +86,11 @@ static int usage(const QStringList &args) " --output-format \n" " Specify output format. See -if.\n\n" " --input-codec \n" - " Specify encoding for .qm input files. Default is 'Latin1'.\n" - " UTF-8 is always tried as well, corresponding to the trUtf8() function.\n\n" + " Specify encoding for .qm and .po input files. Default is 'Latin1'\n" + " for .qm and 'UTF-8' for .po files. UTF-8 is always tried as well for\n" + " .qm, corresponding to the possible use of the trUtf8() function.\n\n" + " --output-codec \n" + " Specify encoding for .po output files. Default is 'UTF-8'.\n\n" " --drop-tags \n" " Drop named extra tags when writing 'ts' or 'xlf' files.\n" " May be specified repeatedly.\n\n" @@ -139,7 +142,6 @@ int main(int argc, char *argv[]) bool verbose = false; ConversionData cd; - cd.m_codecForSource = "Latin1"; Translator tr; for (int i = 1; i < args.size(); ++i) { @@ -172,6 +174,10 @@ int main(int argc, char *argv[]) if (++i >= args.size()) return usage(args); cd.m_codecForSource = args[i].toLatin1(); + } else if (args[i] == QLatin1String("-output-codec")) { + if (++i >= args.size()) + return usage(args); + cd.m_outputCodec = args[i].toLatin1(); } else if (args[i] == QLatin1String("-drop-tag")) { if (++i >= args.size()) return usage(args); diff --git a/tools/linguist/shared/po.cpp b/tools/linguist/shared/po.cpp index a197b25..4850cfd 100644 --- a/tools/linguist/shared/po.cpp +++ b/tools/linguist/shared/po.cpp @@ -359,6 +359,7 @@ bool loadPO(Translator &translator, QIODevice &dev, ConversionData &cd) const QChar quote = QLatin1Char('"'); const QChar newline = QLatin1Char('\n'); QTextStream in(&dev); + in.setCodec(cd.m_codecForSource.isEmpty() ? "UTF-8" : cd.m_codecForSource); bool error = false; // format of a .po file entry: @@ -547,11 +548,11 @@ bool loadPO(Translator &translator, QIODevice &dev, ConversionData &cd) return !error && cd.errors().isEmpty(); } -bool savePO(const Translator &translator, QIODevice &dev, ConversionData &) +bool savePO(const Translator &translator, QIODevice &dev, ConversionData &cd) { bool ok = true; QTextStream out(&dev); - //qDebug() << "OUT CODEC: " << out.codec()->name(); + out.setCodec(cd.m_outputCodec.isEmpty() ? "UTF-8" : cd.m_outputCodec); bool first = true; if (translator.messages().isEmpty() || !translator.messages().first().sourceText().isEmpty()) { diff --git a/tools/linguist/shared/qm.cpp b/tools/linguist/shared/qm.cpp index 323bd29..381f5c5 100644 --- a/tools/linguist/shared/qm.cpp +++ b/tools/linguist/shared/qm.cpp @@ -545,7 +545,8 @@ bool loadQM(Translator &translator, QIODevice &dev, ConversionData &cd) size_t numItems = offsetLength / (2 * sizeof(quint32)); //qDebug() << "NUMITEMS: " << numItems; - QTextCodec *codec = QTextCodec::codecForName(cd.m_codecForSource); + QTextCodec *codec = QTextCodec::codecForName( + cd.m_codecForSource.isEmpty() ? "Latin1" : cd.m_codecForSource); QTextCodec *utf8Codec = 0; if (codec->name() != "UTF-8") utf8Codec = QTextCodec::codecForName("UTF-8"); diff --git a/tools/linguist/shared/translator.h b/tools/linguist/shared/translator.h index 01778d7..762a77ba 100644 --- a/tools/linguist/shared/translator.h +++ b/tools/linguist/shared/translator.h @@ -81,7 +81,8 @@ public: public: QString m_defaultContext; - QByteArray m_codecForSource; // CPP specific + QByteArray m_codecForSource; // CPP, PO & QM specific + QByteArray m_outputCodec; // PO specific QString m_sourceFileName; QString m_targetFileName; QDir m_sourceDir; -- cgit v0.12 From d3a2ba13342880e2912b9a669c8b6f8bc217eb56 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 20 Jul 2009 15:45:47 +1000 Subject: fix crash due to null pointer referencing during application desctruction globalEngineCache is deleted as part of Q_GLOBAL_STATIC macro. Other instances of code that happen to use QRegex after the cache destruction will subsequently crash. Most common reason are other Q_GLOBAL_STATIC instances which happen to use QRegExp as part of their destructor. Reviewed-by: Rhys Weatherley --- src/corelib/tools/qregexp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp index 8dad6e5..908b404 100644 --- a/src/corelib/tools/qregexp.cpp +++ b/src/corelib/tools/qregexp.cpp @@ -3296,7 +3296,7 @@ static void prepareEngine_helper(QRegExpPrivate *priv) { bool initMatchState = !priv->eng; #if !defined(QT_NO_REGEXP_OPTIM) - if (!priv->eng) { + if (!priv->eng && globalEngineCache()) { QMutexLocker locker(mutex()); priv->eng = globalEngineCache()->take(priv->engineKey); if (priv->eng != 0) -- cgit v0.12 From 84abdaa41e6c3bde6ac653e02bd72300b6681572 Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Mon, 20 Jul 2009 10:58:28 +0200 Subject: Fix crash when native socket notifiers would send a notification after being disabled. Spend a lot of time looking at this and at the CoreFoundation source code and it seems that we really do get a notification even after the notifier is disabled. I suspect there's a race condition between when we disable the socket notifier, but the kernel flags it as needing a read, then CoreFoundation just sends the notification without checking if the CFSocket has been disabled. No further notifications come of course. Since this breaks the invariant that was set in the assert, I'm replacing it with an if check. Task-number: 258198 Reviewed-by: Bradley T. Hughes --- src/gui/kernel/qeventdispatcher_mac.mm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm index 99a1fc1..cde0c47 100644 --- a/src/gui/kernel/qeventdispatcher_mac.mm +++ b/src/gui/kernel/qeventdispatcher_mac.mm @@ -264,12 +264,16 @@ void qt_mac_socket_callback(CFSocketRef s, CFSocketCallBackType callbackType, CF int nativeSocket = CFSocketGetNative(s); MacSocketInfo *socketInfo = eventDispatcher->macSockets.value(nativeSocket); QEvent notifierEvent(QEvent::SockAct); + + // There is a race condition that happen where we disable the notifier and + // the kernel still has a notification to pass on. We then get this + // notification after we've successfully disabled the CFSocket, but our Qt + // notifier is now gone. The upshot is we have to check the notifier + // everytime. if (callbackType == kCFSocketReadCallBack) { - Q_ASSERT(socketInfo->readNotifier); - QApplication::sendEvent(socketInfo->readNotifier, ¬ifierEvent); + if (socketInfo->readNotifier) + QApplication::sendEvent(socketInfo->readNotifier, ¬ifierEvent); } else if (callbackType == kCFSocketWriteCallBack) { - // ### Bug in Apple socket notifiers seems to send write even - // ### after the notifier has been disabled, need to investigate further. if (socketInfo->writeNotifier) QApplication::sendEvent(socketInfo->writeNotifier, ¬ifierEvent); } -- cgit v0.12 From 2d6caf67f8e2a49c5c5516e6837ed6b2862130c2 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Mon, 20 Jul 2009 11:35:44 +0200 Subject: Fix the hand scrolling in QGraphicsView that will stop unexpectedly. If you start a hand scrolling and during moving, you press another button of the mouse than the left one, the scrolling suddently stop working. In mouseReleaseEvent we just stop the hand scrolling if the button is left. Task:258356 Reviewed-by:janarve --- src/gui/graphicsview/qgraphicsview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index a3fe307..b888b01 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -3342,7 +3342,7 @@ void QGraphicsView::mouseReleaseEvent(QMouseEvent *event) } } else #endif - if (d->dragMode == QGraphicsView::ScrollHandDrag) { + if (d->dragMode == QGraphicsView::ScrollHandDrag && event->button() == Qt::LeftButton) { #ifndef QT_NO_CURSOR // Restore the open hand cursor. ### There might be items // under the mouse that have a valid cursor at this time, so -- cgit v0.12 From 0f494029a61a2f9f31917be6e6e954b6bb606085 Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Mon, 20 Jul 2009 11:29:00 +0200 Subject: Fix assert in message handling. Trivial fix. Reported by Michael Brasser. Task-number: 258337 Reviewed-By: Peter Hartmann --- src/xmlpatterns/data/qboolean.cpp | 2 +- tests/auto/qxmlquery/tst_qxmlquery.cpp | 18 ++++++++++++++++++ tools/xmlpatterns/qcoloringmessagehandler.cpp | 12 +++++++++--- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/xmlpatterns/data/qboolean.cpp b/src/xmlpatterns/data/qboolean.cpp index 07562fd..bb4ece1 100644 --- a/src/xmlpatterns/data/qboolean.cpp +++ b/src/xmlpatterns/data/qboolean.cpp @@ -76,7 +76,7 @@ bool Boolean::evaluateEBV(const Item &first, { Q_ASSERT(context); context->error(QtXmlPatterns::tr("Effective Boolean Value cannot be calculated for a sequence " - "containing two or more atomic values."), + "containing two or more atomic values."), ReportContext::FORG0006, QSourceLocation()); return false; diff --git a/tests/auto/qxmlquery/tst_qxmlquery.cpp b/tests/auto/qxmlquery/tst_qxmlquery.cpp index 28af641..b273311 100644 --- a/tests/auto/qxmlquery/tst_qxmlquery.cpp +++ b/tests/auto/qxmlquery/tst_qxmlquery.cpp @@ -219,6 +219,7 @@ private Q_SLOTS: void bindVariableQXmlNameQXmlQuerySignature() const; void bindVariableQXmlNameQXmlQuery() const; void bindVariableQXmlQueryInvalidate() const; + void unknownSourceLocation() const; // TODO call all URI resolving functions where 1) the URI resolver return a null QUrl(); 2) resolves into valid, existing URI, 3) invalid, non-existing URI. // TODO bind stringlists, variant lists, both ways. @@ -3222,6 +3223,23 @@ void tst_QXmlQuery::bindVariableQXmlQueryInvalidate() const QVERIFY(!query.isValid()); } +void tst_QXmlQuery::unknownSourceLocation() const +{ + QBuffer b; + b.setData(""); + b.open(QIODevice::ReadOnly); + + MessageSilencer silencer; + QXmlQuery query; + query.bindVariable(QLatin1String("inputDocument"), &b); + query.setMessageHandler(&silencer); + + query.setQuery(QLatin1String("doc($inputDocument)/a/(let $v := b/string() return if ($v) then $v else ())")); + + QString output; + query.evaluateTo(&output); +} + QTEST_MAIN(tst_QXmlQuery) #include "tst_qxmlquery.moc" diff --git a/tools/xmlpatterns/qcoloringmessagehandler.cpp b/tools/xmlpatterns/qcoloringmessagehandler.cpp index 9616097..0ddb246 100644 --- a/tools/xmlpatterns/qcoloringmessagehandler.cpp +++ b/tools/xmlpatterns/qcoloringmessagehandler.cpp @@ -100,12 +100,18 @@ void ColoringMessageHandler::handleMessage(QtMsgType type, } case QtFatalMsg: { - Q_ASSERT(!sourceLocation.isNull()); const QString errorCode(identifier.fragment()); Q_ASSERT(!errorCode.isEmpty()); QUrl uri(identifier); uri.setFragment(QString()); + QString location; + + if(sourceLocation.isNull()) + location = QXmlPatternistCLI::tr("Unknown location"); + else + location = QString::fromLatin1(sourceLocation.uri().toEncoded()); + QString errorId; /* If it's a standard error code, we don't want to output the * whole URI. */ @@ -117,7 +123,7 @@ void ColoringMessageHandler::handleMessage(QtMsgType type, if(hasLine) { writeUncolored(QXmlPatternistCLI::tr("Error %1 in %2, at line %3, column %4: %5").arg(colorify(errorId, ErrorCode), - colorify(QString::fromLatin1(sourceLocation.uri().toEncoded()), Location), + colorify(location, Location), colorify(QString::number(sourceLocation.line()), Location), colorify(QString::number(sourceLocation.column()), Location), colorifyDescription(description))); @@ -125,7 +131,7 @@ void ColoringMessageHandler::handleMessage(QtMsgType type, else { writeUncolored(QXmlPatternistCLI::tr("Error %1 in %2: %3").arg(colorify(errorId, ErrorCode), - colorify(QString::fromLatin1(sourceLocation.uri().toEncoded()), Location), + colorify(location, Location), colorifyDescription(description))); } break; -- cgit v0.12 From 3d6381b47a6048d04dbfc7b6984cae81c02d4fe6 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 16 Jul 2009 23:46:10 +0200 Subject: Fix QTextCodec case-insensitive comparison while in a Turkish locale. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In Turkish, lowercase('I') is 'ı', which means comparing "iso-8859-1" to "ISO-8859-1" will fail. Reviewed-by: Denis Dzyubenko --- src/corelib/codecs/qtextcodec.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index df150bd..2187cbe 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -99,6 +99,10 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, (QTextCodecFactoryInterface_iid, QLatin1String("/codecs"))) #endif +static char qtolower(register char c) +{ if (c >= 'A' && c <= 'Z') return c + 0x20; return c; } +static bool qisalnum(register char c) +{ return (c >= '0' && c <= '9') || ((c | 0x20) >= 'a' && (c | 0x20) <= 'z'); } static bool nameMatch(const QByteArray &name, const QByteArray &test) { @@ -111,21 +115,21 @@ static bool nameMatch(const QByteArray &name, const QByteArray &test) // if the letters and numbers are the same, we have a match while (*n != '\0') { - if (isalnum((uchar)*n)) { + if (qisalnum(*n)) { for (;;) { if (*h == '\0') return false; - if (isalnum((uchar)*h)) + if (qisalnum(*h)) break; ++h; } - if (tolower((uchar)*n) != tolower((uchar)*h)) + if (qtolower(*n) != qtolower(*h)) return false; ++h; } ++n; } - while (*h && !isalnum((uchar)*h)) + while (*h && !qisalnum(*h)) ++h; return (*h == '\0'); } -- cgit v0.12