From 6ff6998ad91a3cfee233cb25c750144eae8881b3 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Tue, 2 Mar 2010 08:53:12 +1000 Subject: Fix build breakage in windowflags example Reviewed-by: Sarah Smith --- examples/widgets/windowflags/controllerwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/widgets/windowflags/controllerwindow.cpp b/examples/widgets/windowflags/controllerwindow.cpp index a1e5455..fb82b8f 100644 --- a/examples/widgets/windowflags/controllerwindow.cpp +++ b/examples/widgets/windowflags/controllerwindow.cpp @@ -149,7 +149,7 @@ void ControllerWindow::createTypeGroupBox() splashScreenRadioButton = createRadioButton(tr("Splash screen")); windowRadioButton->setChecked(true); - QVBoxLayout *layout = new QGridLayout; + QGridLayout *layout = new QGridLayout; layout->addWidget(windowRadioButton, 0, 0); layout->addWidget(dialogRadioButton, 1, 0); layout->addWidget(sheetRadioButton, 2, 0); -- cgit v0.12 From 9842e823a5a3df8d786ddc1c6fe355db8f511354 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 1 Mar 2010 13:11:52 -0800 Subject: Uncomment #DIRECTFB_DRAWINGOPERATIONS in pri-file This has no effect unless QT_DIRECTFB_WARN_ON_RASTERFALLBACKS or QT_DIRECTFB_DISABLE_RASTERFALLBACKS is defined but will decrease likelyhood of customers encountering strange compile errors if they don't uncomment it when using these defines. Reviewed-by: Noam Rosenthal --- src/gui/embedded/directfb.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/embedded/directfb.pri b/src/gui/embedded/directfb.pri index bd1d947..1795bbd 100644 --- a/src/gui/embedded/directfb.pri +++ b/src/gui/embedded/directfb.pri @@ -15,7 +15,7 @@ #DEFINES += QT_DIRECTFB_TIMING #DEFINES += QT_NO_DIRECTFB_OPAQUE_DETECTION #DEFINES += QT_NO_DIRECTFB_STRETCHBLIT -#DIRECTFB_DRAWINGOPERATIONS=DRAW_RECTS|DRAW_LINES|DRAW_IMAGE|DRAW_PIXMAP|DRAW_TILED_PIXMAP|STROKE_PATH|DRAW_PATH|DRAW_POINTS|DRAW_ELLIPSE|DRAW_POLYGON|DRAW_TEXT|FILL_PATH|FILL_RECT|DRAW_COLORSPANS|DRAW_ROUNDED_RECT +DIRECTFB_DRAWINGOPERATIONS=DRAW_RECTS|DRAW_LINES|DRAW_IMAGE|DRAW_PIXMAP|DRAW_TILED_PIXMAP|STROKE_PATH|DRAW_PATH|DRAW_POINTS|DRAW_ELLIPSE|DRAW_POLYGON|DRAW_TEXT|FILL_PATH|FILL_RECT|DRAW_COLORSPANS|DRAW_ROUNDED_RECT #DEFINES += \"QT_DIRECTFB_WARN_ON_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\" #DEFINES += \"QT_DIRECTFB_DISABLE_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\" -- cgit v0.12 From 8b90fe35a737a71dbc15de48088fc100241f701c Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 1 Mar 2010 13:10:37 -0800 Subject: Add support for composition mode DSPD_DST in DFB This porter duff rule was added in DirectFB 1.2 Reviewed-by: Noam Rosenthal --- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 2b11058..d6e1a03 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -944,6 +944,11 @@ void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode m case QPainter::CompositionMode_DestinationOut: surface->SetPorterDuff(surface, DSPD_DST_OUT); break; +#if (Q_DIRECTFB_VERSION >= 0x010200) + case QPainter::CompositionMode_Destination: + surface->SetPorterDuff(surface, DSPD_DST); + break; +#endif #if (Q_DIRECTFB_VERSION >= 0x010000) case QPainter::CompositionMode_SourceAtop: surface->SetPorterDuff(surface, DSPD_SRC_ATOP); -- cgit v0.12 From 629b3e0d03875665a75a5a1c40d53dd478fdc982 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 1 Mar 2010 14:45:40 -0800 Subject: Don't disable alpha when filling with opaque color Qt heuristics say that a QPixmap becomes an alpha pixmap when filled with a color with alpha != 255 but not that it returns to being opaque when filled with a color with alpha == 255 Reviewed-by: Noam Rosenthal --- src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp index ba50329..b5ac67d 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp @@ -425,7 +425,7 @@ void QDirectFBPixmapData::fill(const QColor &color) Q_ASSERT(dfbSurface); - alpha = (color.alpha() < 255); + alpha |= (color.alpha() < 255); if (alpha && isOpaqueFormat(imageFormat)) { QSize size; -- cgit v0.12 From 6f20bd49782045897b5cb067aa42cc2e0d955770 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 1 Mar 2010 12:57:39 -0800 Subject: Make composition modes work better for DirectFB It seems that I have to premultiply the colors I pass to IDirectFBSurface->SetColor when composition mode != Source|SourceIn. It now seems to behave the same way as the raster engine which I guess should be considered the authority on this matter. Reviewed-by: Noam Rosenthal --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 99 +++++++++------------- 1 file changed, 39 insertions(+), 60 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index d6e1a03..388e369 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -1,4 +1,4 @@ -/**************************************************************************** + /**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. @@ -68,11 +68,10 @@ public: }; enum CompositionModeStatus { - PorterDuff_None = 0x00, - PorterDuff_SupportedBlits = 0x01, - PorterDuff_SupportedPrimitives = 0x02, - PorterDuff_SupportedOpaquePrimitives = 0x04, - PorterDuff_Dirty = 0x10 + PorterDuff_None = 0x0, + PorterDuff_Supported = 0x1, + PorterDuff_PremultiplyColors = 0x2, + PorterDuff_AlwaysBlend = 0x4 }; enum ClipType { @@ -97,7 +96,6 @@ public: inline void unlock(); static inline void unlock(QDirectFBPaintDevice *device); - inline bool testCompositionMode(const QPen *pen, const QBrush *brush, const QColor *color = 0) const; inline bool isSimpleBrush(const QBrush &brush) const; void drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap, const QPointF &pos); @@ -130,6 +128,7 @@ public: ClipType clipType; QDirectFBPaintDevice *dfbDevice; uint compositionModeStatus; + bool isPremultiplied; bool inClip; QRect currentClip; @@ -287,6 +286,7 @@ bool QDirectFBPaintEngine::begin(QPaintDevice *device) qFatal("QDirectFBPaintEngine used on an invalid device: 0x%x", device->devType()); } + d->isPremultiplied = QDirectFBScreen::isPremultiplied(d->dfbDevice->format()); d->prepare(d->dfbDevice); gccaps = AllFeatures; @@ -413,7 +413,7 @@ void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount) || !d->simplePen || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip || !d->isSimpleBrush(brush) - || !d->testCompositionMode(&pen, &brush)) { + || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) { RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawRects(rects, rectCount); @@ -443,7 +443,7 @@ void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount) || !d->simplePen || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip || !d->isSimpleBrush(brush) - || !d->testCompositionMode(&pen, &brush)) { + || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) { RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawRects(rects, rectCount); @@ -468,7 +468,7 @@ void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount) const QPen &pen = state()->pen; if (!d->simplePen || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip - || !d->testCompositionMode(&pen, 0)) { + || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) { RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawLines(lines, lineCount); @@ -488,7 +488,7 @@ void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount) const QPen &pen = state()->pen; if (!d->simplePen || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip - || !d->testCompositionMode(&pen, 0)) { + || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) { RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG()); d->lock(); QRasterPaintEngine::drawLines(lines, lineCount); @@ -526,7 +526,7 @@ void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image, */ #if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE - if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) + if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported) || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) || (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) || (!d->supportsStretchBlit() && state()->matrix.mapRect(r).size() != sr.size()) @@ -575,7 +575,7 @@ void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, QPixmapData *data = pixmap.pixmapData(); Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); QDirectFBPixmapData *dfbData = static_cast(data); - if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) + if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported) || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) || (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) || (!d->supportsStretchBlit() && state()->matrix.mapRect(r).size() != sr.size())) { @@ -606,7 +606,7 @@ void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r, RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), offset); d->lock(); QRasterPaintEngine::drawTiledPixmap(r, pixmap, offset); - } else if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) + } else if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported) || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) || (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) || (!d->supportsStretchBlit() && state()->matrix.isScaling())) { @@ -720,7 +720,7 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) switch (brush.style()) { case Qt::SolidPattern: { if (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported - || !d->testCompositionMode(0, &brush)) { + || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) { break; } const QColor color = brush.color(); @@ -732,7 +732,7 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) return; } case Qt::TexturePattern: { - if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_SupportedBlits) + if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported) || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported) || (!d->supportsStretchBlit() && state()->matrix.isScaling())) { break; @@ -760,7 +760,7 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color) Q_D(QDirectFBPaintEngine); if ((d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported) || (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip) - || !d->testCompositionMode(0, 0, &color)) { + || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) { RASTERFALLBACK(FILL_RECT, rect, color, VOID_ARG()); d->lock(); QRasterPaintEngine::fillRect(rect, color); @@ -804,7 +804,7 @@ QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p : surface(0), antialiased(false), simplePen(false), transformationType(0), opacity(255), clipType(ClipUnset), dfbDevice(0), - compositionModeStatus(0), inClip(false), q(p) + compositionModeStatus(0), isPremultiplied(false), inClip(false), q(p) { fb = QDirectFBScreen::instance()->dfb(); surfaceCache = new SurfaceCache; @@ -820,36 +820,6 @@ bool QDirectFBPaintEnginePrivate::isSimpleBrush(const QBrush &brush) const return (brush.style() == Qt::NoBrush) || (brush.style() == Qt::SolidPattern && !antialiased); } -bool QDirectFBPaintEnginePrivate::testCompositionMode(const QPen *pen, const QBrush *brush, const QColor *color) const -{ - Q_ASSERT(!pen || pen->style() == Qt::NoPen || pen->style() == Qt::SolidLine); - Q_ASSERT(!brush || brush->style() == Qt::NoBrush || brush->style() == Qt::SolidPattern); - switch (compositionModeStatus & (QDirectFBPaintEnginePrivate::PorterDuff_SupportedOpaquePrimitives - |QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives)) { - case QDirectFBPaintEnginePrivate::PorterDuff_SupportedPrimitives: - return true; - case QDirectFBPaintEnginePrivate::PorterDuff_SupportedOpaquePrimitives: - if (pen && pen->style() == Qt::SolidLine && pen->color().alpha() != 255) - return false; - if (brush) { - if (brush->style() == Qt::SolidPattern && brush->color().alpha() != 255) { - return false; - } - } else if (color && color->alpha() != 255) { - return false; - } - return true; - case QDirectFBPaintEnginePrivate::PorterDuff_None: - return false; - default: - // ### PorterDuff_SupportedOpaquePrimitives|PorterDuff_SupportedPrimitives can't be combined - break; - } - Q_ASSERT(0); - return false; -} - - void QDirectFBPaintEnginePrivate::lock() { // We will potentially get a new pointer to the buffer after a @@ -912,21 +882,23 @@ void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode m static const bool forceRasterFallBack = qgetenv("QT_DIRECTFB_FORCE_RASTER").toInt() > 0; if (forceRasterFallBack) { - compositionModeStatus = 0; + compositionModeStatus = PorterDuff_None; return; } - compositionModeStatus = PorterDuff_SupportedBlits; + compositionModeStatus = PorterDuff_Supported|PorterDuff_PremultiplyColors|PorterDuff_AlwaysBlend; switch (mode) { case QPainter::CompositionMode_Clear: surface->SetPorterDuff(surface, DSPD_CLEAR); break; case QPainter::CompositionMode_Source: surface->SetPorterDuff(surface, DSPD_SRC); - compositionModeStatus |= PorterDuff_SupportedOpaquePrimitives; + compositionModeStatus &= ~PorterDuff_AlwaysBlend; + if (!isPremultiplied) + compositionModeStatus &= ~PorterDuff_PremultiplyColors; break; case QPainter::CompositionMode_SourceOver: - compositionModeStatus |= PorterDuff_SupportedPrimitives; + compositionModeStatus &= ~PorterDuff_AlwaysBlend; surface->SetPorterDuff(surface, DSPD_SRC_OVER); break; case QPainter::CompositionMode_DestinationOver: @@ -934,6 +906,8 @@ void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode m break; case QPainter::CompositionMode_SourceIn: surface->SetPorterDuff(surface, DSPD_SRC_IN); + if (!isPremultiplied) + compositionModeStatus &= ~PorterDuff_PremultiplyColors; break; case QPainter::CompositionMode_DestinationIn: surface->SetPorterDuff(surface, DSPD_DST_IN); @@ -964,7 +938,7 @@ void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode m break; #endif default: - compositionModeStatus = 0; + compositionModeStatus = PorterDuff_None; break; } } @@ -986,9 +960,6 @@ void QDirectFBPaintEnginePrivate::prepareForBlit(bool alpha) } surface->SetColor(surface, 0xff, 0xff, 0xff, opacity); surface->SetBlittingFlags(surface, blittingFlags); - if (compositionModeStatus & PorterDuff_Dirty) { - setCompositionMode(q->state()->composition_mode); - } } static inline uint ALPHA_MUL(uint x, uint a) @@ -1001,12 +972,20 @@ static inline uint ALPHA_MUL(uint x, uint a) void QDirectFBPaintEnginePrivate::setDFBColor(const QColor &color) { Q_ASSERT(surface); + Q_ASSERT(compositionModeStatus & PorterDuff_Supported); const quint8 alpha = (opacity == 255 ? color.alpha() : ALPHA_MUL(color.alpha(), opacity)); - surface->SetColor(surface, color.red(), color.green(), color.blue(), alpha); - surface->SetPorterDuff(surface, DSPD_NONE); - surface->SetDrawingFlags(surface, alpha == 255 ? DSDRAW_NOFX : DSDRAW_BLEND); - compositionModeStatus |= PorterDuff_Dirty; + QColor col; + if (compositionModeStatus & PorterDuff_PremultiplyColors) { + col = QColor(ALPHA_MUL(color.red(), alpha), + ALPHA_MUL(color.green(), alpha), + ALPHA_MUL(color.blue(), alpha), + alpha); + } else { + col = QColor(color.red(), color.green(), color.blue(), alpha); + } + surface->SetColor(surface, col.red(), col.green(), col.blue(), col.alpha()); + surface->SetDrawingFlags(surface, alpha == 255 && !(compositionModeStatus & PorterDuff_AlwaysBlend) ? DSDRAW_NOFX : DSDRAW_BLEND); } IDirectFBSurface *QDirectFBPaintEnginePrivate::getSurface(const QImage &img, bool *release) -- cgit v0.12 From c55a99965d8c08d5f924d49db4fe4aa49df80961 Mon Sep 17 00:00:00 2001 From: Bill King Date: Tue, 2 Mar 2010 15:20:10 +1000 Subject: Fixes: ODBC Driver expects 16bit when system is 32bit Fixed ODBC to use SQLTCHAR type and not assume that wchar's are 2 bytes wide. Task-number: QTBUG-6928 Reviewed-by: Justin McPherson --- src/plugins/sqldrivers/odbc/odbc.pro | 1 + src/sql/drivers/drivers.pri | 1 + src/sql/drivers/odbc/qsql_odbc.cpp | 273 +++++++++++++++++++++-------------- src/sql/drivers/odbc/qsql_odbc.h | 4 - 4 files changed, 170 insertions(+), 109 deletions(-) diff --git a/src/plugins/sqldrivers/odbc/odbc.pro b/src/plugins/sqldrivers/odbc/odbc.pro index 3de8ab2..2bf85f1 100644 --- a/src/plugins/sqldrivers/odbc/odbc.pro +++ b/src/plugins/sqldrivers/odbc/odbc.pro @@ -8,6 +8,7 @@ unix { !contains( LIBS, .*odbc.* ) { LIBS *= $$QT_LFLAGS_ODBC } + DEFINES += UNICODE } win32 { diff --git a/src/sql/drivers/drivers.pri b/src/sql/drivers/drivers.pri index 184eca9..7250c6e 100644 --- a/src/sql/drivers/drivers.pri +++ b/src/sql/drivers/drivers.pri @@ -49,6 +49,7 @@ contains(sql-drivers, odbc) { mac:!contains( LIBS, .*odbc.* ):LIBS *= -liodbc unix:!contains( LIBS, .*odbc.* ):LIBS *= -lodbc + unix:DEFINES += UNICODE win32 { !win32-borland:LIBS *= -lodbc32 diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index 2049a76..f34aea5 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -66,7 +66,7 @@ QT_BEGIN_NAMESPACE //crude hack to get non-unicode capable driver managers to work # undef UNICODE # define SQLTCHAR SQLCHAR -# define SQL_C_WCHAR SQL_C_CHAR +# define SQL_C_TCHAR SQL_C_CHAR #endif // newer platform SDKs use SQLLEN instead of SQLINTEGER @@ -78,11 +78,54 @@ QT_BEGIN_NAMESPACE # define QSQLULEN SQLULEN #endif - static const int COLNAMESIZE = 256; //Map Qt parameter types to ODBC types static const SQLSMALLINT qParamType[4] = { SQL_PARAM_INPUT, SQL_PARAM_INPUT, SQL_PARAM_OUTPUT, SQL_PARAM_INPUT_OUTPUT }; +inline static QString fromSQLTCHAR(const QVarLengthArray& input, int size=-1) +{ + QString result; + + int realsize = qMin(size, input.size()); + if(realsize > 0 && input[realsize-1] == 0) + realsize--; + switch(sizeof(SQLTCHAR)) { + case 1: + result=QString::fromUtf8((const char *)input.constData(), realsize); + break; + case 2: + result=QString::fromUtf16((const ushort *)input.constData(), realsize); + break; + case 4: + result=QString::fromUcs4((const uint *)input.constData(), realsize); + break; + default: + qCritical() << "sizeof(SQLTCHAR) is " << sizeof(SQLTCHAR) << "Don't know how to handle this"; + } + return result; +} + +inline static QVarLengthArray toSQLTCHAR(const QString &input) +{ + QVarLengthArray result; + result.resize(input.size()); + switch(sizeof(SQLTCHAR)) { + case 1: + memcpy(result.data(), input.toUtf8().data(), input.size()); + break; + case 2: + memcpy(result.data(), input.unicode(), input.size() * 2); + break; + case 4: + memcpy(result.data(), input.toUcs4().data(), input.size() * 4); + break; + default: + qCritical() << "sizeof(SQLTCHAR) is " << sizeof(SQLTCHAR) << "Don't know how to handle this"; + } + result.append(0); // make sure it's null terminated, doesn't matter if it already is, it does if it isn't. + return result; +} + class QODBCDriverPrivate { public: @@ -98,8 +141,8 @@ public: SQLHANDLE hEnv; SQLHANDLE hDbc; - uint unicode :1; - uint useSchema :1; + bool unicode; + bool useSchema; int disconnectCount; bool isMySqlServer; bool isMSSqlServer; @@ -139,8 +182,8 @@ public: SQLHANDLE dpDbc() const { return driverPrivate ? driverPrivate->hDbc : 0;} SQLHANDLE hStmt; - uint unicode :1; - uint useSchema :1; + bool unicode; + bool useSchema; QSqlRecord rInf; QVector fieldCache; @@ -177,19 +220,18 @@ static QString qWarnODBCHandle(int handleType, SQLHANDLE handle, int *nativeCode int i = 1; description_[0] = 0; - r = SQLGetDiagRec(handleType, - handle, - i, - state_, - &nativeCode_, - 0, - NULL, - &msgLen); - if(r == SQL_NO_DATA) - return QString(); - description_.resize(msgLen+1); do { r = SQLGetDiagRec(handleType, + handle, + i, + state_, + &nativeCode_, + 0, + NULL, + &msgLen); + if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && msgLen > 0) + description_.resize(msgLen+1); + r = SQLGetDiagRec(handleType, handle, i, state_, @@ -202,9 +244,9 @@ static QString qWarnODBCHandle(int handleType, SQLHANDLE handle, int *nativeCode *nativeCode = nativeCode_; QString tmpstore; #ifdef UNICODE - tmpstore = QString((const QChar*)description_.data(), msgLen); + tmpstore = fromSQLTCHAR(description_, msgLen); #else - tmpstore = QString::fromLocal8Bit((const char*)description_.data(), msgLen); + tmpstore = QString::fromUtf8((const char*)description_.constData(), msgLen); #endif if(result != tmpstore) { if(!result.isEmpty()) @@ -223,13 +265,13 @@ static QString qODBCWarn(const QODBCPrivate* odbc, int *nativeCode = 0) { return (qWarnODBCHandle(SQL_HANDLE_ENV, odbc->dpEnv()) + QLatin1Char(' ') + qWarnODBCHandle(SQL_HANDLE_DBC, odbc->dpDbc()) + QLatin1Char(' ') - + qWarnODBCHandle(SQL_HANDLE_STMT, odbc->hStmt, nativeCode)); + + qWarnODBCHandle(SQL_HANDLE_STMT, odbc->hStmt, nativeCode)).simplified(); } static QString qODBCWarn(const QODBCDriverPrivate* odbc, int *nativeCode = 0) { return (qWarnODBCHandle(SQL_HANDLE_ENV, odbc->hEnv) + QLatin1Char(' ') - + qWarnODBCHandle(SQL_HANDLE_DBC, odbc->hDbc, nativeCode)); + + qWarnODBCHandle(SQL_HANDLE_DBC, odbc->hDbc, nativeCode)).simplified(); } static void qSqlWarning(const QString& message, const QODBCPrivate* odbc) @@ -331,17 +373,22 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni colSize = 65536; } else { colSize++; // make sure there is room for more than the 0 termination - if (unicode) { - colSize *= 2; // a tiny bit faster, since it saves a SQLGetData() call - } } - QVarLengthArray buf(colSize); + r = SQLGetData(hStmt, + column+1, + SQL_C_TCHAR, + NULL, + 0, + &lengthIndicator); + if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && lengthIndicator > 0) + colSize = lengthIndicator/sizeof(SQLTCHAR) + 1; + QVarLengthArray buf(colSize); while (true) { r = SQLGetData(hStmt, column+1, - unicode ? SQL_C_WCHAR : SQL_C_CHAR, + SQL_C_TCHAR, (SQLPOINTER)buf.data(), - colSize, + colSize*sizeof(SQLTCHAR), &lengthIndicator); if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) { if (lengthIndicator == SQL_NULL_DATA || lengthIndicator == SQL_NO_TOTAL) { @@ -353,14 +400,9 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni // contain the number of bytes returned - it contains the // total number of bytes that CAN be fetched // colSize-1: remove 0 termination when there is more data to fetch - int rSize = (r == SQL_SUCCESS_WITH_INFO) ? (unicode ? colSize-2 : colSize-1) : lengthIndicator; - if (unicode) { - fieldVal += QString((const QChar*) buf.constData(), rSize / 2); - } else { - fieldVal += QString::fromAscii(buf.constData(), rSize); - } - memset(buf.data(), 0, colSize); - if (lengthIndicator < colSize) { + int rSize = (r == SQL_SUCCESS_WITH_INFO) ? colSize : lengthIndicator/sizeof(SQLTCHAR); + fieldVal += fromSQLTCHAR(buf, rSize); + if (lengthIndicator < (unsigned int)colSize*sizeof(SQLTCHAR)) { // workaround for Drivermanagers that don't return SQL_NO_DATA break; } @@ -386,10 +428,11 @@ static QVariant qGetBinaryData(SQLHANDLE hStmt, int column) QSQLLEN lengthIndicator = 0; SQLRETURN r = SQL_ERROR; - SQLTCHAR colName[COLNAMESIZE]; + QVarLengthArray colName(COLNAMESIZE); + r = SQLDescribeCol(hStmt, column + 1, - colName, + colName.data(), COLNAMESIZE, &colNameLen, &colType, @@ -522,10 +565,10 @@ static QSqlField qMakeFieldInfo(const QODBCPrivate* p, int i ) SQLSMALLINT colScale; SQLSMALLINT nullable; SQLRETURN r = SQL_ERROR; - SQLTCHAR colName[COLNAMESIZE]; + QVarLengthArray colName(COLNAMESIZE); r = SQLDescribeCol(p->hStmt, i+1, - colName, + colName.data(), (SQLSMALLINT)COLNAMESIZE, &colNameLen, &colType, @@ -551,9 +594,9 @@ static QSqlField qMakeFieldInfo(const QODBCPrivate* p, int i ) } #ifdef UNICODE - QString qColName((const QChar*)colName, colNameLen); + QString qColName(fromSQLTCHAR(colName, colNameLen)); #else - QString qColName = QString::fromLocal8Bit((const char*)colName); + QString qColName = QString::fromUtf8((const char *)colName.constData()); #endif // nullable can be SQL_NO_NULLS, SQL_NULLABLE or SQL_NULLABLE_UNKNOWN int required = -1; @@ -581,24 +624,33 @@ static int qGetODBCVersion(const QString &connOpts) if (connOpts.contains(QLatin1String("SQL_ATTR_ODBC_VERSION=SQL_OV_ODBC3"), Qt::CaseInsensitive)) return SQL_OV_ODBC3; #endif + if (connOpts.contains(QLatin1String("SQL_ATTR_ODBC_VERSION=SQL_OV_ODBC2"), Qt::CaseInsensitive)) + return SQL_OV_ODBC2; +#ifdef _IODBCUNIX_H + return SQL_OV_ODBC3; +#else return SQL_OV_ODBC2; +#endif } QChar QODBCDriverPrivate::quoteChar() { if (!isQuoteInitialized) { - char driverResponse[4]; + SQLTCHAR driverResponse[4]; SQLSMALLINT length; int r = SQLGetInfo(hDbc, SQL_IDENTIFIER_QUOTE_CHAR, &driverResponse, sizeof(driverResponse), &length); - if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) { + if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) +#ifdef UNICODE + quote = QChar(driverResponse[0]); +#else quote = QLatin1Char(driverResponse[0]); - } else { +#endif + else quote = QLatin1Char('"'); - } isQuoteInitialized = true; } return quote; @@ -642,11 +694,11 @@ bool QODBCDriverPrivate::setConnectionOptions(const QString& connOpts) val.utf16(); // 0 terminate r = SQLSetConnectAttr(hDbc, SQL_ATTR_CURRENT_CATALOG, #ifdef UNICODE - (SQLWCHAR*) val.unicode(), + toSQLTCHAR(val).constData(), #else - (SQLCHAR*) val.toLatin1().constData(), + (SQLCHAR*) val.toUtf8().constData(), #endif - SQL_NTS); + val.length()*sizeof(SQLTCHAR)); } else if (opt.toUpper() == QLatin1String("SQL_ATTR_METADATA_ID")) { if (val.toUpper() == QLatin1String("SQL_TRUE")) { v = SQL_TRUE; @@ -664,11 +716,11 @@ bool QODBCDriverPrivate::setConnectionOptions(const QString& connOpts) val.utf16(); // 0 terminate r = SQLSetConnectAttr(hDbc, SQL_ATTR_TRACEFILE, #ifdef UNICODE - (SQLWCHAR*) val.unicode(), + toSQLTCHAR(val).constData(), #else - (SQLCHAR*) val.toLatin1().constData(), + (SQLCHAR*) val.toUtf8().constData(), #endif - SQL_NTS); + val.length()*sizeof(SQLTCHAR)); } else if (opt.toUpper() == QLatin1String("SQL_ATTR_TRACE")) { if (val.toUpper() == QLatin1String("SQL_OPT_TRACE_OFF")) { v = SQL_OPT_TRACE_OFF; @@ -880,10 +932,10 @@ bool QODBCResult::reset (const QString& query) #ifdef UNICODE r = SQLExecDirect(d->hStmt, - (SQLWCHAR*) query.unicode(), + toSQLTCHAR(query).constData(), (SQLINTEGER) query.length()); #else - QByteArray query8 = query.toLocal8Bit(); + QByteArray query8 = query.toUtf8(); r = SQLExecDirect(d->hStmt, (SQLCHAR*) query8.constData(), (SQLINTEGER) query8.length()); @@ -1231,10 +1283,10 @@ bool QODBCResult::prepare(const QString& query) #ifdef UNICODE r = SQLPrepare(d->hStmt, - (SQLWCHAR*) query.unicode(), + toSQLTCHAR(query).constData(), (SQLINTEGER) query.length()); #else - QByteArray query8 = query.toLocal8Bit(); + QByteArray query8 = query.toUtf8(); r = SQLPrepare(d->hStmt, (SQLCHAR*) query8.constData(), (SQLINTEGER) query8.length()); @@ -1435,43 +1487,44 @@ bool QODBCResult::exec() #ifndef Q_ODBC_VERSION_2 if (d->unicode) { QString str = val.toString(); - str.utf16(); if (*ind != SQL_NULL_DATA) - *ind = str.length() * sizeof(QChar); - int strSize = str.length() * sizeof(QChar); + *ind = str.length() * sizeof(SQLTCHAR); + int strSize = str.length() * sizeof(SQLTCHAR); if (bindValueType(i) & QSql::Out) { - QByteArray ba((char*)str.constData(), str.capacity() * sizeof(QChar)); + QVarLengthArray ba(toSQLTCHAR(str)); + ba.reserve(str.capacity()); r = SQLBindParameter(d->hStmt, i + 1, qParamType[(QFlag)(bindValueType(i)) & QSql::InOut], - SQL_C_WCHAR, + SQL_C_TCHAR, strSize > 254 ? SQL_WLONGVARCHAR : SQL_WVARCHAR, 0, // god knows... don't change this! 0, (void *)ba.constData(), ba.size(), ind); - tmpStorage.append(ba); + tmpStorage.append(QByteArray((const char *)ba.constData(), ba.size()*sizeof(SQLTCHAR))); break; } - + QByteArray strba((const char *)toSQLTCHAR(str).constData(), str.size()*sizeof(SQLTCHAR)); r = SQLBindParameter(d->hStmt, i + 1, qParamType[(QFlag)(bindValueType(i)) & QSql::InOut], - SQL_C_WCHAR, + SQL_C_TCHAR, strSize > 254 ? SQL_WLONGVARCHAR : SQL_WVARCHAR, strSize, 0, - (void *)str.constData(), - strSize, + (SQLPOINTER)strba.constData(), + strba.size(), ind); + tmpStorage.append(strba); break; } else #endif { - QByteArray str = val.toString().toAscii(); + QByteArray str = val.toString().toUtf8(); if (*ind != SQL_NULL_DATA) *ind = str.length(); int strSize = str.length(); @@ -1572,15 +1625,18 @@ bool QODBCResult::exec() break; case QVariant::String: if (d->unicode) { - if (bindValueType(i) & QSql::Out) - values[i] = QString::fromUtf16((ushort*)tmpStorage.takeFirst().constData()); + if (bindValueType(i) & QSql::Out) { + QByteArray first = tmpStorage.takeFirst(); + QVarLengthArray array; + array.append((SQLTCHAR *)first.constData(), first.size()); + values[i] = fromSQLTCHAR(array, first.size()/sizeof(SQLTCHAR*)); + } break; } // fall through default: { - QByteArray ba = tmpStorage.takeFirst(); if (bindValueType(i) & QSql::Out) - values[i] = QString::fromAscii(ba.constData()); + values[i] = tmpStorage.takeFirst(); break; } } if (indicators[i] == SQL_NULL_DATA) @@ -1789,19 +1845,20 @@ bool QODBCDriver::open(const QString & db, connQStr += QLatin1String(";PWD=") + password; SQLSMALLINT cb; - SQLTCHAR connOut[1024]; + QVarLengthArray connOut(1024); r = SQLDriverConnect(d->hDbc, NULL, #ifdef UNICODE - (SQLWCHAR*)connQStr.unicode(), + toSQLTCHAR(connQStr).constData(), #else - (SQLCHAR*)connQStr.toLatin1().constData(), + (SQLCHAR*)connQStr.toUtf8().constData(), #endif (SQLSMALLINT)connQStr.length(), - connOut, + connOut.data(), 1024, &cb, - SQL_DRIVER_NOPROMPT); + /*SQL_DRIVER_NOPROMPT*/0); + if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) { setLastError(qMakeError(tr("Unable to connect"), QSqlError::ConnectionError, d)); setOpenError(true); @@ -1977,20 +2034,21 @@ void QODBCDriverPrivate::checkSchemaUsage() void QODBCDriverPrivate::checkSqlServer() { SQLRETURN r; - char serverString[200]; + QVarLengthArray serverString(200); SQLSMALLINT t; + memset(serverString.data(), 0, serverString.size() * sizeof(SQLTCHAR)); r = SQLGetInfo(hDbc, SQL_DBMS_NAME, - serverString, - sizeof(serverString), + serverString.data(), + serverString.size() * sizeof(SQLTCHAR), &t); if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) { QString serverType; #ifdef UNICODE - serverType = QString(reinterpret_cast(serverString), t/sizeof(QChar)); + serverType = fromSQLTCHAR(serverString, t/sizeof(SQLTCHAR)); #else - serverType = QString::fromLocal8Bit(serverString, t); + serverType = QString::fromUtf8((const char *)serverString.constData(), t); #endif isMySqlServer = serverType.contains(QLatin1String("mysql"), Qt::CaseInsensitive); isMSSqlServer = serverType.contains(QLatin1String("Microsoft SQL Server"), Qt::CaseInsensitive); @@ -2009,18 +2067,18 @@ void QODBCDriverPrivate::checkHasSQLFetchScroll() void QODBCDriverPrivate::checkHasMultiResults() { - char driverResponse[4]; + QVarLengthArray driverResponse(2); SQLSMALLINT length; SQLRETURN r = SQLGetInfo(hDbc, SQL_MULT_RESULT_SETS, - driverResponse, - sizeof(driverResponse), + driverResponse.data(), + driverResponse.size() * sizeof(SQLTCHAR), &length); if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) #ifdef UNICODE - hasMultiResultSets = QString(reinterpret_cast(driverResponse), length/sizeof(QChar)).startsWith(QLatin1Char('Y')); + hasMultiResultSets = fromSQLTCHAR(driverResponse, length/sizeof(SQLTCHAR)).startsWith(QLatin1Char('Y')); #else - hasMultiResultSets = QString::fromLocal8Bit(driverResponse, length).startsWith(QLatin1Char('Y')); + hasMultiResultSets = QString::fromUtf8((const char *)driverResponse.constData(), length).startsWith(QLatin1Char('Y')); #endif } @@ -2134,9 +2192,9 @@ QStringList QODBCDriver::tables(QSql::TableType type) const NULL, 0, #ifdef UNICODE - (SQLWCHAR*)joinedTableTypeString.unicode(), + toSQLTCHAR(joinedTableTypeString).constData(), #else - (SQLCHAR*)joinedTableTypeString.toLatin1().constData(), + (SQLCHAR*)joinedTableTypeString.toUtf8().constData(), #endif joinedTableTypeString.length() /* characters, not bytes */); @@ -2150,6 +2208,11 @@ QStringList QODBCDriver::tables(QSql::TableType type) const else r = SQLFetch(hStmt); + if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO && r != SQL_NO_DATA) { + qWarning() << "QODBCDriver::tables failed to retrieve table/view list: (" << r << "," << qWarnODBCHandle(SQL_HANDLE_STMT, hStmt) << ")"; + return QStringList(); + } + while (r == SQL_SUCCESS) { QString fieldVal = qGetStringData(hStmt, 2, -1, false); tl.append(fieldVal); @@ -2208,21 +2271,21 @@ QSqlIndex QODBCDriver::primaryIndex(const QString& tablename) const SQL_IS_UINTEGER); r = SQLPrimaryKeys(hStmt, #ifdef UNICODE - catalog.length() == 0 ? NULL : (SQLWCHAR*)catalog.unicode(), + catalog.length() == 0 ? NULL : toSQLTCHAR(catalog).constData(), #else - catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toLatin1().constData(), + catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toUtf8().constData(), #endif catalog.length(), #ifdef UNICODE - schema.length() == 0 ? NULL : (SQLWCHAR*)schema.unicode(), + schema.length() == 0 ? NULL : toSQLTCHAR(schema).constData(), #else - schema.length() == 0 ? NULL : (SQLCHAR*)schema.toLatin1().constData(), + schema.length() == 0 ? NULL : (SQLCHAR*)schema.toUtf8().constData(), #endif schema.length(), #ifdef UNICODE - (SQLWCHAR*)table.unicode(), + toSQLTCHAR(table).constData(), #else - (SQLCHAR*)table.toLatin1().constData(), + (SQLCHAR*)table.toUtf8().constData(), #endif table.length() /* in characters, not in bytes */); @@ -2233,21 +2296,21 @@ QSqlIndex QODBCDriver::primaryIndex(const QString& tablename) const r = SQLSpecialColumns(hStmt, SQL_BEST_ROWID, #ifdef UNICODE - catalog.length() == 0 ? NULL : (SQLWCHAR*)catalog.unicode(), + catalog.length() == 0 ? NULL : toSQLTCHAR(catalog).constData(), #else - catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toLatin1().constData(), + catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toUtf8().constData(), #endif catalog.length(), #ifdef UNICODE - schema.length() == 0 ? NULL : (SQLWCHAR*)schema.unicode(), + schema.length() == 0 ? NULL : toSQLTCHAR(schema).constData(), #else - schema.length() == 0 ? NULL : (SQLCHAR*)schema.toLatin1().constData(), + schema.length() == 0 ? NULL : (SQLCHAR*)schema.toUtf8().constData(), #endif schema.length(), #ifdef UNICODE - (SQLWCHAR*)table.unicode(), + toSQLTCHAR(table).constData(), #else - (SQLCHAR*)table.toLatin1().constData(), + (SQLCHAR*)table.toUtf8().constData(), #endif table.length(), SQL_SCOPE_CURROW, @@ -2333,21 +2396,21 @@ QSqlRecord QODBCDriver::record(const QString& tablename) const SQL_IS_UINTEGER); r = SQLColumns(hStmt, #ifdef UNICODE - catalog.length() == 0 ? NULL : (SQLWCHAR*)catalog.unicode(), + catalog.length() == 0 ? NULL : toSQLTCHAR(catalog).constData(), #else - catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toLatin1().constData(), + catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toUtf8().constData(), #endif catalog.length(), #ifdef UNICODE - schema.length() == 0 ? NULL : (SQLWCHAR*)schema.unicode(), + schema.length() == 0 ? NULL : toSQLTCHAR(schema).constData(), #else - schema.length() == 0 ? NULL : (SQLCHAR*)schema.toLatin1().constData(), + schema.length() == 0 ? NULL : (SQLCHAR*)schema.toUtf8().constData(), #endif schema.length(), #ifdef UNICODE - (SQLWCHAR*)table.unicode(), + toSQLTCHAR(table).constData(), #else - (SQLCHAR*)table.toLatin1().constData(), + (SQLCHAR*)table.toUtf8().constData(), #endif table.length(), NULL, diff --git a/src/sql/drivers/odbc/qsql_odbc.h b/src/sql/drivers/odbc/qsql_odbc.h index 145a902..13b2cc3 100644 --- a/src/sql/drivers/odbc/qsql_odbc.h +++ b/src/sql/drivers/odbc/qsql_odbc.h @@ -75,10 +75,6 @@ # undef _MSC_VER #endif -#ifndef Q_ODBC_VERSION_2 -#include -#endif - #include QT_BEGIN_HEADER -- cgit v0.12 From 26f3d40e99b6afa6e5205eb2fbe162dd30416888 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 2 Mar 2010 09:18:21 +0100 Subject: Fix licenseCheck autotest --- src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 388e369..023bb28 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -1,4 +1,4 @@ - /**************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -- cgit v0.12 From 9253b0dffc5e8a5d704f0a3d4960db4cd484d69a Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 2 Mar 2010 09:22:12 +0100 Subject: skip tst_QDialog::throwInExec on WinCE, ARM platform Rethrowing exceptions across DLL boundaries crashes on Windows CE ARM devices. This is a restriction of the Microsoft tools. See thread "(Re)throwing from a catch block across dll boundaries" in microsoft.public.windowsce.embedded.vc Reviewed-by: ninerider --- tests/auto/qdialog/tst_qdialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qdialog/tst_qdialog.cpp b/tests/auto/qdialog/tst_qdialog.cpp index 7b8213d..86f87b8 100644 --- a/tests/auto/qdialog/tst_qdialog.cpp +++ b/tests/auto/qdialog/tst_qdialog.cpp @@ -464,8 +464,8 @@ public slots: void tst_QDialog::throwInExec() { -#ifdef Q_WS_MAC - QSKIP("Qt/Mac: Throwing exceptions in exec() is not supported.", SkipAll); +#if defined(Q_WS_MAC) || (defined(Q_WS_WINCE) && defined(_ARM_)) + QSKIP("Throwing exceptions in exec() is not supported on this platform.", SkipAll); #endif int caughtExceptions = 0; try { -- cgit v0.12 From cb9051c79e5937ad8441100aaf67553e28ba0700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 2 Mar 2010 10:25:13 +0100 Subject: Prevented assert on 1 pixel wide / high images in qt_blurImage. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't attempt to run qt_halfScaled on images less than 2px in either dimension. Particularly, avoid doing this from qt_blurImage, where that situation can happen as a result of a clipped QGraphicsEffect. Reviewed-by: Bjørn Erik Nilsen --- src/gui/image/qpixmapfilter.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/image/qpixmapfilter.cpp b/src/gui/image/qpixmapfilter.cpp index 2792e45..c605880 100644 --- a/src/gui/image/qpixmapfilter.cpp +++ b/src/gui/image/qpixmapfilter.cpp @@ -777,6 +777,9 @@ void expblur(QImage &img, qreal radius, bool improvedQuality = false, int transp Q_GUI_EXPORT QImage qt_halfScaled(const QImage &source) { + if (source.width() < 2 || source.height() < 2) + return QImage(); + QImage srcImage = source; if (source.format() == QImage::Format_Indexed8) { @@ -869,7 +872,7 @@ Q_GUI_EXPORT void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, boo } qreal scale = 1; - if (radius >= 4) { + if (radius >= 4 && blurImage.width() >= 2 && blurImage.height() >= 2) { blurImage = qt_halfScaled(blurImage); scale = 2; radius *= qreal(0.5); -- cgit v0.12 From 1bc449a16051f09028cfcb78ebdffa6ee0440572 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 2 Mar 2010 10:52:47 +0100 Subject: Revert "ItemViews: make it possible for chekcable items to get partiallyChecked" This reverts commit 435bbd4be73768f617e4a4083a345d1d8d62daa3. Reviewed-By: ogoffart --- src/gui/itemviews/qitemdelegate.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp index 9069ce4..7d8e103 100644 --- a/src/gui/itemviews/qitemdelegate.cpp +++ b/src/gui/itemviews/qitemdelegate.cpp @@ -1297,14 +1297,8 @@ bool QItemDelegate::editorEvent(QEvent *event, return false; } - Qt::CheckState state; - if ( flags & Qt::ItemIsTristate ) { - state = static_cast( (value.toInt() + 1) % 3 ); - } else { - state = (static_cast(value.toInt()) == Qt::Checked + Qt::CheckState state = (static_cast(value.toInt()) == Qt::Checked ? Qt::Unchecked : Qt::Checked); - } - return model->setData(index, state, Qt::CheckStateRole); } -- cgit v0.12 From b6e312df6cc087dbf45becb91bd43b35913e3684 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 2 Mar 2010 11:26:51 +0100 Subject: 2nd part of revert of commit 435bbd4be73768f617e4a After a mess-up by git rebase... Reviewed-by: ogoffart --- src/gui/itemviews/qstyleditemdelegate.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/gui/itemviews/qstyleditemdelegate.cpp b/src/gui/itemviews/qstyleditemdelegate.cpp index 9aac554..880f8ab 100644 --- a/src/gui/itemviews/qstyleditemdelegate.cpp +++ b/src/gui/itemviews/qstyleditemdelegate.cpp @@ -747,13 +747,8 @@ bool QStyledItemDelegate::editorEvent(QEvent *event, return false; } - Qt::CheckState state; - if ( flags & Qt::ItemIsTristate ) { - state = static_cast( (value.toInt() + 1) % 3 ); - } else { - state = (static_cast(value.toInt()) == Qt::Checked + Qt::CheckState state = (static_cast(value.toInt()) == Qt::Checked ? Qt::Unchecked : Qt::Checked); - } return model->setData(index, state, Qt::CheckStateRole); } -- cgit v0.12 From fd30cc9fabe6fc023fbca5b93cfdb116fe194514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 2 Mar 2010 13:49:33 +0100 Subject: Fixed rendering bugs when scrolling graphics items with drop shadows. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We can't clip source pixmaps to the device rect, as there's no way of knowing which parts of the source pixmap are needed for the part of the graphics effect that's unclipped. Reviewed-by: Bjørn Erik Nilsen --- src/gui/graphicsview/qgraphicsitem.cpp | 28 +++------------------- src/gui/graphicsview/qgraphicsscene.cpp | 23 ++++-------------- tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp | 23 ++++++++++++++++++ 3 files changed, 31 insertions(+), 43 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index bd214e1..368af58 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -10810,6 +10810,7 @@ void QGraphicsItemEffectSourcePrivate::draw(QPainter *painter) } } +// sourceRect must be in the given coordinate system QRect QGraphicsItemEffectSourcePrivate::paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded) const { QRectF effectRectF; @@ -10819,7 +10820,8 @@ QRect QGraphicsItemEffectSourcePrivate::paddedEffectRect(Qt::CoordinateSystem sy if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) { if (info) { - effectRectF = item->graphicsEffect()->boundingRectFor(boundingRect(Qt::DeviceCoordinates)); + QRectF deviceRect = system == Qt::DeviceCoordinates ? sourceRect : info->painter->worldTransform().mapRect(sourceRect); + effectRectF = item->graphicsEffect()->boundingRectFor(deviceRect); if (unpadded) *unpadded = (effectRectF.size() == sourceRect.size()); if (info && system == Qt::LogicalCoordinates) @@ -10868,30 +10870,6 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP return static_cast(item)->pixmap(); } - if (deviceCoordinates) { - // Clip to viewport rect. - int left, top, right, bottom; - effectRect.getCoords(&left, &top, &right, &bottom); - if (left < 0) { - if (offset) - offset->rx() += -left; - effectRect.setX(0); - } - if (top < 0) { - if (offset) - offset->ry() += -top; - effectRect.setY(0); - } - // NB! We use +-1 for historical reasons (see QRect documentation). - QPaintDevice *device = info->painter->device(); - const int deviceWidth = device->width(); - const int deviceHeight = device->height(); - if (right + 1 > deviceWidth) - effectRect.setRight(deviceWidth - 1); - if (bottom + 1 > deviceHeight) - effectRect.setBottom(deviceHeight -1); - - } if (effectRect.isEmpty()) return QPixmap(); diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index afea082..4ee2301 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -4714,31 +4714,18 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter * if (sourced->currentCachedSystem() != Qt::LogicalCoordinates && sourced->lastEffectTransform != painter->worldTransform()) { - bool unclipped = false; if (sourced->lastEffectTransform.type() <= QTransform::TxTranslate && painter->worldTransform().type() <= QTransform::TxTranslate) { - QRectF itemRect = item->boundingRect(); - if (!item->d_ptr->children.isEmpty()) - itemRect |= item->childrenBoundingRect(); + QRectF sourceRect = sourced->boundingRect(Qt::DeviceCoordinates); + QRect effectRect = sourced->paddedEffectRect(Qt::DeviceCoordinates, sourced->currentCachedMode(), sourceRect); - QRectF oldSourceRect = sourced->lastEffectTransform.mapRect(itemRect); - QRectF newSourceRect = painter->worldTransform().mapRect(itemRect); - - QRect oldEffectRect = sourced->paddedEffectRect(sourced->currentCachedSystem(), sourced->currentCachedMode(), oldSourceRect); - QRect newEffectRect = sourced->paddedEffectRect(sourced->currentCachedSystem(), sourced->currentCachedMode(), newSourceRect); - - QRect deviceRect(0, 0, painter->device()->width(), painter->device()->height()); - if (deviceRect.contains(oldEffectRect) && deviceRect.contains(newEffectRect)) { - sourced->setCachedOffset(newEffectRect.topLeft()); - unclipped = true; - } + sourced->setCachedOffset(effectRect.topLeft()); + } else { + sourced->invalidateCache(QGraphicsEffectSourcePrivate::TransformChanged); } sourced->lastEffectTransform = painter->worldTransform(); - - if (!unclipped) - sourced->invalidateCache(QGraphicsEffectSourcePrivate::TransformChanged); } item->d_ptr->graphicsEffect->draw(painter); diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp index 795431b..1007d61 100644 --- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp @@ -72,6 +72,7 @@ private slots: void drawPixmapItem(); void deviceCoordinateTranslateCaching(); void inheritOpacity(); + void dropShadowClipping(); }; void tst_QGraphicsEffect::initTestCase() @@ -590,6 +591,28 @@ void tst_QGraphicsEffect::inheritOpacity() QTRY_VERIFY(item->numRepaints > numRepaints); } +void tst_QGraphicsEffect::dropShadowClipping() +{ + QImage img(128, 128, QImage::Format_ARGB32_Premultiplied); + img.fill(0xffffffff); + + QGraphicsScene scene; + QGraphicsRectItem *item = new QGraphicsRectItem(-5, -500, 10, 1000); + item->setGraphicsEffect(new QGraphicsDropShadowEffect); + item->setPen(Qt::NoPen); + item->setBrush(Qt::red); + + scene.addItem(item); + + QPainter p(&img); + scene.render(&p, img.rect(), QRect(-64, -64, 128, 128)); + p.end(); + + for (int y = 1; y < img.height(); ++y) + for (int x = 0; x < img.width(); ++x) + QCOMPARE(img.pixel(x, y), img.pixel(x, y-1)); +} + QTEST_MAIN(tst_QGraphicsEffect) #include "tst_qgraphicseffect.moc" -- cgit v0.12 From d6aba8dd917e8306799743dd33905f2037e00d10 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 2 Mar 2010 15:26:03 +0100 Subject: Compile with GCC 3.3 Task-number: QTBUG-8554 Reviewed-by: Gabriel --- src/corelib/kernel/qmetaobject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index cd7418a..b151040 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -943,7 +943,7 @@ QByteArray QMetaObject::normalizedType(const char *type) if (!type || !*type) return result; - QVarLengthArray stackbuf(int(strlen(type)) + 1); + QVarLengthArray stackbuf(qstrlen(type) + 1); qRemoveWhitespace(type, stackbuf.data()); int templdepth = 0; qNormalizeType(stackbuf.data(), templdepth, result); -- cgit v0.12 From 120905fbc48ac7658fac392113bf45e00880c456 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 24 Feb 2010 16:55:15 +0100 Subject: Expand indicator would not be displayed after removal of a collapsed item's child While setting the hasChildren property of QTreeViewItem, "collapsed" and "not visible" were being mistaken. Auto-test included. Reviewed-by: Olivier Task-number: QTBUG-7443 (cherry picked from commit 77670c3c0fdc3021356e212e94042a0b5a4f4f8c) --- src/gui/itemviews/qtreeview.cpp | 13 +++++++++---- tests/auto/qtreeview/tst_qtreeview.cpp | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 706d2a8..37168eb 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -3770,10 +3770,15 @@ void QTreeViewPrivate::rowsRemoved(const QModelIndex &parent, if (previousSibiling != -1 && after && model->rowCount(parent) == start) viewItems[previousSibiling].hasMoreSiblings = false; - - updateChildCount(parentItem, -removedCount); - if (parentItem != -1 && viewItems.at(parentItem).total == 0) - viewItems[parentItem].hasChildren = false; //every children have been removed; + if (parentItem != -1) { + if (viewItems.at(parentItem).expanded) { + updateChildCount(parentItem, -removedCount); + if (viewItems.at(parentItem).total == 0) + viewItems[parentItem].hasChildren = false; //every children have been removed; + } else if (viewItems[parentItem].hasChildren && !hasVisibleChildren(parent)) { + viewItems[parentItem].hasChildren = false; + } + } if (after) { q->updateGeometries(); viewport->update(); diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index fd4815e..e39cf6c 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -3083,6 +3083,20 @@ void tst_QTreeView::styleOptionViewItem() QApplication::processEvents(); QTRY_VERIFY(delegate.count >= 3); QApplication::processEvents(); + + item00->setText("OnlyOne"); + item0->insertRow(2, new QStandardItem("OnlyOne Last")); + view.collapse(item0->index()); + item0->removeRow(0); + delegate.count = 0; + QTRY_VERIFY(delegate.count >= 2); + QApplication::processEvents(); + + item0->removeRow(1); + item0->setText("OnlyOne"); + delegate.count = 0; + QTRY_VERIFY(delegate.count >= 2); + QApplication::processEvents(); } } -- cgit v0.12 From 7fc63dd0ff368a637dcd17e692b9d6b26278b538 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 2 Mar 2010 16:41:05 +0100 Subject: QString::section: Fix crash with SectionIncludeLeadingSep flag And start is out of bounds. Reviewed-by: Thiago Reviewed-by: Joao Task-number: QTBUG-4306 --- src/corelib/tools/qstring.cpp | 2 +- tests/auto/qstring/tst_qstring.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 3ef0e66..03bc053 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -3185,7 +3185,7 @@ QString QString::section(const QRegExp ®, int start, int end, SectionFlags fl if (!empty || !(flags & SectionSkipEmpty)) x++; } - if((flags & SectionIncludeLeadingSep)) { + if((flags & SectionIncludeLeadingSep) && first_i < sections.size()) { const qt_section_chunk §ion = sections.at(first_i); ret.prepend(section.string.left(section.length)); } diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp index c9b3436..4ebcade 100644 --- a/tests/auto/qstring/tst_qstring.cpp +++ b/tests/auto/qstring/tst_qstring.cpp @@ -3503,7 +3503,10 @@ void tst_QString::section_data() << QString("\\b") << 3 << 3 << int(QString::SectionDefault) << QString("is") << true; - + QTest::newRow( "task257941-rx" ) << QString("99.0 42.3") + << QString("\\s*[AaBb]\\s*") << 1 << 1 + << int(QString::SectionIncludeLeadingSep) + << QString() << true; } void tst_QString::section() -- cgit v0.12 From 1d656b760c75de5f98ff3cf0542015a641bc692c Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Tue, 2 Mar 2010 11:00:55 -0800 Subject: Simplify DirectFB performance debugging Allow people to control whether or not to warn on/disable raster fallbacks using the following mechanism: export QT_DIRECTFB_DISABLE_RASTERFALLBACKS="draw_pixmap|draw_text" export QT_DIRECTFB_WARN_ON_RASTERFALLBACKS="draw_lines" It's still possible to define QT_DIRECTFB_WARN_ON_RASTERFALLBACKS to something for legacy reasons. The environment variable check is only available in debug mode. --- .../gfxdrivers/directfb/qdirectfbpaintengine.cpp | 103 +++++++++++++++++---- 1 file changed, 87 insertions(+), 16 deletions(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index 023bb28..537baf5 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -167,7 +167,7 @@ struct CachedImage static QCache imageCache(4*1024*1024); // 4 MB #endif -#if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS || defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS +#if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS || defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS || defined QT_DEBUG #define VOID_ARG() static_cast(false) enum PaintOperation { DRAW_RECTS = 0x0001, DRAW_LINES = 0x0002, DRAW_IMAGE = 0x0004, @@ -177,9 +177,74 @@ enum PaintOperation { FILL_RECT = 0x1000, DRAW_COLORSPANS = 0x2000, DRAW_ROUNDED_RECT = 0x4000, ALL = 0xffff }; + +#ifdef QT_DEBUG +static void initRasterFallbacksMasks(int *warningMask, int *disableMask) +{ + struct { + const char *name; + PaintOperation operation; + } const operations[] = { + { "DRAW_RECTS", DRAW_RECTS }, + { "DRAW_LINES", DRAW_LINES }, + { "DRAW_IMAGE", DRAW_IMAGE }, + { "DRAW_PIXMAP", DRAW_PIXMAP }, + { "DRAW_TILED_PIXMAP", DRAW_TILED_PIXMAP }, + { "STROKE_PATH", STROKE_PATH }, + { "DRAW_PATH", DRAW_PATH }, + { "DRAW_POINTS", DRAW_POINTS }, + { "DRAW_ELLIPSE", DRAW_ELLIPSE }, + { "DRAW_POLYGON", DRAW_POLYGON }, + { "DRAW_TEXT", DRAW_TEXT }, + { "FILL_PATH", FILL_PATH }, + { "FILL_RECT", FILL_RECT }, + { "DRAW_COLORSPANS", DRAW_COLORSPANS }, + { "DRAW_ROUNDED_RECT", DRAW_ROUNDED_RECT }, + { "ALL", ALL }, + { 0, ALL } + }; + + const QStringList warning = QString::fromLatin1(qgetenv("QT_DIRECTFB_WARN_ON_RASTERFALLBACKS")).toUpper().split(QLatin1Char('|')); + const QStringList disable = QString::fromLatin1(qgetenv("QT_DIRECTFB_DISABLE_RASTERFALLBACKS")).toUpper().split(QLatin1Char('|')); + *warningMask = 0; + *disableMask = 0; + if (!warning.isEmpty() || !disable.isEmpty()) { + for (int i=0; operations[i].name; ++i) { + const QString name = QString::fromLatin1(operations[i].name); + if (warning.contains(name)) { + *warningMask |= operations[i].operation; + } + if (disable.contains(name)) { + *disableMask |= operations[i].operation; + } + } + } +} #endif +static inline int rasterFallbacksMask(bool warn) +{ #ifdef QT_DIRECTFB_WARN_ON_RASTERFALLBACKS + if (warn) + return QT_DIRECTFB_WARN_ON_RASTERFALLBACKS; +#endif +#ifdef QT_DIRECTFB_DISABLE_RASTERFALLBACKS + if (!warn) + return QT_DIRECTFB_DISABLE_RASTERFALLBACKS; +#endif +#ifndef QT_DEBUG + return 0; +#else + static int warnMask = -1; + static int disableMask = -1; + if (warnMask == -1) + initRasterFallbacksMasks(&warnMask, &disableMask); + return warn ? warnMask : disableMask; +#endif +} +#endif + +#if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS || defined QT_DEBUG template static void rasterFallbackWarn(const char *msg, const char *func, const device *dev, uint transformationType, bool simplePen, @@ -189,25 +254,31 @@ static void rasterFallbackWarn(const char *msg, const char *func, const device * const char *nameThree, const T3 &three); #endif -#if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS && defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS +#if defined QT_DEBUG || (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()->clipType, \ - d_func()->compositionModeStatus, \ - #one, one, #two, two, #three, three); \ - if (op & (QT_DIRECTFB_DISABLE_RASTERFALLBACKS)) \ - return; + { \ + const bool disable = op & rasterFallbacksMask(false); \ + if (op & rasterFallbacksMask(true)) \ + rasterFallbackWarn(disable \ + ? "Disabled raster engine operation" \ + : "Falling back to raster engine for", \ + __FUNCTION__, \ + state()->painter->device(), \ + d_func()->transformationType, \ + d_func()->simplePen, \ + d_func()->clipType, \ + d_func()->compositionModeStatus, \ + #one, one, #two, two, #three, three); \ + if (disable) \ + return; \ + } #elif defined QT_DIRECTFB_DISABLE_RASTERFALLBACKS -#define RASTERFALLBACK(op, one, two, three) \ - if (op & (QT_DIRECTFB_DISABLE_RASTERFALLBACKS)) \ +#define RASTERFALLBACK(op, one, two, three) \ + if (op & rasterFallbacksMask(false)) \ return; #elif defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS #define RASTERFALLBACK(op, one, two, three) \ - if (op & (QT_DIRECTFB_WARN_ON_RASTERFALLBACKS)) \ + if (op & rasterFallbacksMask(true)) \ rasterFallbackWarn("Falling back to raster engine for", \ __FUNCTION__, state()->painter->device(), \ d_func()->transformationType, \ @@ -1267,7 +1338,7 @@ static inline void drawRects(const T *rects, int n, const QTransform &transform, } } -#ifdef QT_DIRECTFB_WARN_ON_RASTERFALLBACKS +#if defined QT_DIRECTFB_WARN_ON_RASTERFALLBACKS || defined QT_DEBUG template inline const T *ptr(const T &t) { return &t; } template <> inline const bool* ptr(const bool &) { return 0; } template -- cgit v0.12 From 0c12cec56c73342735b51e8aa21c8f0d7fe20c16 Mon Sep 17 00:00:00 2001 From: Bill King Date: Wed, 3 Mar 2010 09:17:41 +1000 Subject: Fix compile. Stupid inconsistent constness/overall api Task-number: QTBUG-6928 --- src/sql/drivers/odbc/qsql_odbc.cpp | 60 +++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index f34aea5..e75c19d 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -694,9 +694,9 @@ bool QODBCDriverPrivate::setConnectionOptions(const QString& connOpts) val.utf16(); // 0 terminate r = SQLSetConnectAttr(hDbc, SQL_ATTR_CURRENT_CATALOG, #ifdef UNICODE - toSQLTCHAR(val).constData(), + toSQLTCHAR(val).data(), #else - (SQLCHAR*) val.toUtf8().constData(), + (SQLCHAR*) val.toUtf8().data(), #endif val.length()*sizeof(SQLTCHAR)); } else if (opt.toUpper() == QLatin1String("SQL_ATTR_METADATA_ID")) { @@ -716,9 +716,9 @@ bool QODBCDriverPrivate::setConnectionOptions(const QString& connOpts) val.utf16(); // 0 terminate r = SQLSetConnectAttr(hDbc, SQL_ATTR_TRACEFILE, #ifdef UNICODE - toSQLTCHAR(val).constData(), + toSQLTCHAR(val).data(), #else - (SQLCHAR*) val.toUtf8().constData(), + (SQLCHAR*) val.toUtf8().data(), #endif val.length()*sizeof(SQLTCHAR)); } else if (opt.toUpper() == QLatin1String("SQL_ATTR_TRACE")) { @@ -932,12 +932,12 @@ bool QODBCResult::reset (const QString& query) #ifdef UNICODE r = SQLExecDirect(d->hStmt, - toSQLTCHAR(query).constData(), + toSQLTCHAR(query).data(), (SQLINTEGER) query.length()); #else QByteArray query8 = query.toUtf8(); r = SQLExecDirect(d->hStmt, - (SQLCHAR*) query8.constData(), + (SQLCHAR*) query8.data(), (SQLINTEGER) query8.length()); #endif if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO && r!= SQL_NO_DATA) { @@ -1283,12 +1283,12 @@ bool QODBCResult::prepare(const QString& query) #ifdef UNICODE r = SQLPrepare(d->hStmt, - toSQLTCHAR(query).constData(), + toSQLTCHAR(query).data(), (SQLINTEGER) query.length()); #else QByteArray query8 = query.toUtf8(); r = SQLPrepare(d->hStmt, - (SQLCHAR*) query8.constData(), + (SQLCHAR*) query8.data(), (SQLINTEGER) query8.length()); #endif @@ -1849,9 +1849,9 @@ bool QODBCDriver::open(const QString & db, r = SQLDriverConnect(d->hDbc, NULL, #ifdef UNICODE - toSQLTCHAR(connQStr).constData(), + toSQLTCHAR(connQStr).data(), #else - (SQLCHAR*)connQStr.toUtf8().constData(), + (SQLCHAR*)connQStr.toUtf8().data(), #endif (SQLSMALLINT)connQStr.length(), connOut.data(), @@ -2192,9 +2192,9 @@ QStringList QODBCDriver::tables(QSql::TableType type) const NULL, 0, #ifdef UNICODE - toSQLTCHAR(joinedTableTypeString).constData(), + toSQLTCHAR(joinedTableTypeString).data(), #else - (SQLCHAR*)joinedTableTypeString.toUtf8().constData(), + (SQLCHAR*)joinedTableTypeString.toUtf8().data(), #endif joinedTableTypeString.length() /* characters, not bytes */); @@ -2271,21 +2271,21 @@ QSqlIndex QODBCDriver::primaryIndex(const QString& tablename) const SQL_IS_UINTEGER); r = SQLPrimaryKeys(hStmt, #ifdef UNICODE - catalog.length() == 0 ? NULL : toSQLTCHAR(catalog).constData(), + catalog.length() == 0 ? NULL : toSQLTCHAR(catalog).data(), #else - catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toUtf8().constData(), + catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toUtf8().data(), #endif catalog.length(), #ifdef UNICODE - schema.length() == 0 ? NULL : toSQLTCHAR(schema).constData(), + schema.length() == 0 ? NULL : toSQLTCHAR(schema).data(), #else - schema.length() == 0 ? NULL : (SQLCHAR*)schema.toUtf8().constData(), + schema.length() == 0 ? NULL : (SQLCHAR*)schema.toUtf8().data(), #endif schema.length(), #ifdef UNICODE - toSQLTCHAR(table).constData(), + toSQLTCHAR(table).data(), #else - (SQLCHAR*)table.toUtf8().constData(), + (SQLCHAR*)table.toUtf8().data(), #endif table.length() /* in characters, not in bytes */); @@ -2296,21 +2296,21 @@ QSqlIndex QODBCDriver::primaryIndex(const QString& tablename) const r = SQLSpecialColumns(hStmt, SQL_BEST_ROWID, #ifdef UNICODE - catalog.length() == 0 ? NULL : toSQLTCHAR(catalog).constData(), + catalog.length() == 0 ? NULL : toSQLTCHAR(catalog).data(), #else - catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toUtf8().constData(), + catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toUtf8().data(), #endif catalog.length(), #ifdef UNICODE - schema.length() == 0 ? NULL : toSQLTCHAR(schema).constData(), + schema.length() == 0 ? NULL : toSQLTCHAR(schema).data(), #else - schema.length() == 0 ? NULL : (SQLCHAR*)schema.toUtf8().constData(), + schema.length() == 0 ? NULL : (SQLCHAR*)schema.toUtf8().data(), #endif schema.length(), #ifdef UNICODE - toSQLTCHAR(table).constData(), + toSQLTCHAR(table).data(), #else - (SQLCHAR*)table.toUtf8().constData(), + (SQLCHAR*)table.toUtf8().data(), #endif table.length(), SQL_SCOPE_CURROW, @@ -2396,21 +2396,21 @@ QSqlRecord QODBCDriver::record(const QString& tablename) const SQL_IS_UINTEGER); r = SQLColumns(hStmt, #ifdef UNICODE - catalog.length() == 0 ? NULL : toSQLTCHAR(catalog).constData(), + catalog.length() == 0 ? NULL : toSQLTCHAR(catalog).data(), #else - catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toUtf8().constData(), + catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toUtf8().data(), #endif catalog.length(), #ifdef UNICODE - schema.length() == 0 ? NULL : toSQLTCHAR(schema).constData(), + schema.length() == 0 ? NULL : toSQLTCHAR(schema).data(), #else - schema.length() == 0 ? NULL : (SQLCHAR*)schema.toUtf8().constData(), + schema.length() == 0 ? NULL : (SQLCHAR*)schema.toUtf8().data(), #endif schema.length(), #ifdef UNICODE - toSQLTCHAR(table).constData(), + toSQLTCHAR(table).data(), #else - (SQLCHAR*)table.toUtf8().constData(), + (SQLCHAR*)table.toUtf8().data(), #endif table.length(), NULL, -- cgit v0.12