summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-03-02 18:59:46 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-03-02 18:59:46 (GMT)
commit822edcf68efb132dc96c9c4270916f440ec362e0 (patch)
tree786ada88d7c9e9894a3c18ddcd376011f74de0e1 /src
parent6b674ae7459cf8a391a10c3b61fee525add35f98 (diff)
parent7fc63dd0ff368a637dcd17e692b9d6b26278b538 (diff)
downloadQt-822edcf68efb132dc96c9c4270916f440ec362e0.zip
Qt-822edcf68efb132dc96c9c4270916f440ec362e0.tar.gz
Qt-822edcf68efb132dc96c9c4270916f440ec362e0.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.6-integration
* '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2: QString::section: Fix crash with SectionIncludeLeadingSep flag Expand indicator would not be displayed after removal of a collapsed item's child Compile with GCC 3.3 Fixed rendering bugs when scrolling graphics items with drop shadows. 2nd part of revert of commit 435bbd4be73768f617e4a Revert "ItemViews: make it possible for chekcable items to get partiallyChecked" Prevented assert on 1 pixel wide / high images in qt_blurImage. skip tst_QDialog::throwInExec on WinCE, ARM platform Fix licenseCheck autotest Fixes: ODBC Driver expects 16bit when system is 32bit Make composition modes work better for DirectFB Don't disable alpha when filling with opaque color Add support for composition mode DSPD_DST in DFB Uncomment #DIRECTFB_DRAWINGOPERATIONS in pri-file Fix build breakage in windowflags example
Diffstat (limited to 'src')
-rw-r--r--src/corelib/kernel/qmetaobject.cpp2
-rw-r--r--src/corelib/tools/qstring.cpp2
-rw-r--r--src/gui/embedded/directfb.pri2
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp28
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp23
-rw-r--r--src/gui/image/qpixmapfilter.cpp5
-rw-r--r--src/gui/itemviews/qitemdelegate.cpp8
-rw-r--r--src/gui/itemviews/qstyleditemdelegate.cpp7
-rw-r--r--src/gui/itemviews/qtreeview.cpp13
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp102
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp2
-rw-r--r--src/plugins/sqldrivers/odbc/odbc.pro1
-rw-r--r--src/sql/drivers/drivers.pri1
-rw-r--r--src/sql/drivers/odbc/qsql_odbc.cpp273
-rw-r--r--src/sql/drivers/odbc/qsql_odbc.h4
15 files changed, 240 insertions, 233 deletions
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<char> stackbuf(int(strlen(type)) + 1);
+ QVarLengthArray<char> stackbuf(qstrlen(type) + 1);
qRemoveWhitespace(type, stackbuf.data());
int templdepth = 0;
qNormalizeType(stackbuf.data(), templdepth, result);
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 &reg, 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 &section = sections.at(first_i);
ret.prepend(section.string.left(section.length));
}
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\"
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<QGraphicsPixmapItem *>(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/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);
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<Qt::CheckState>( (value.toInt() + 1) % 3 );
- } else {
- state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
+ Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
? Qt::Unchecked : Qt::Checked);
- }
-
return model->setData(index, state, Qt::CheckStateRole);
}
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<Qt::CheckState>( (value.toInt() + 1) % 3 );
- } else {
- state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
+ Qt::CheckState state = (static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked
? Qt::Unchecked : Qt::Checked);
- }
return model->setData(index, state, Qt::CheckStateRole);
}
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/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
index 2b11058..023bb28 100644
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
+++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
@@ -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<QDirectFBPixmapData*>(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);
@@ -944,6 +918,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);
@@ -959,7 +938,7 @@ void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode m
break;
#endif
default:
- compositionModeStatus = 0;
+ compositionModeStatus = PorterDuff_None;
break;
}
}
@@ -981,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)
@@ -996,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)
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;
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<SQLTCHAR>& 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<SQLTCHAR> toSQLTCHAR(const QString &input)
+{
+ QVarLengthArray<SQLTCHAR> 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<QVariant> 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<char> 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<SQLTCHAR> 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<SQLTCHAR> 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<SQLTCHAR> 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<SQLTCHAR> 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<SQLTCHAR> 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<SQLTCHAR> 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<SQLTCHAR> 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<const QChar*>(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<SQLTCHAR> 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<const QChar*>(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 <sqlucode.h>
-#endif
-
#include <sqlext.h>
QT_BEGIN_HEADER