From 4ebe96275944643a06ac4119ef707e1436df5781 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 2 Jun 2010 11:33:24 +0200 Subject: Reset gesture when in MayBeGesture state. When a gesture recognizer switches from MayBeGesture to Cancelled gesture we need to reset the state of the recognizer, but do not send any events to the user. Reviewed-by: Thomas Zander --- src/gui/kernel/qgesturemanager.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 43facef..7363d70 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -284,6 +284,9 @@ bool QGestureManager::filterEventThroughContexts(const QMultiMap activeToMaybeGestures = m_activeGestures & newMaybeGestures; + // check if a maybe gesture switched to canceled - reset it but don't send an event + QSet maybeToCanceledGestures = m_maybeGestures & notGestures; + // check if a running gesture switched back to not gesture state, // i.e. were canceled QSet canceledGestures = m_activeGestures & notGestures; @@ -343,7 +346,8 @@ bool QGestureManager::filterEventThroughContexts(const QMultiMap undeliveredGestures; @@ -364,7 +368,7 @@ bool QGestureManager::filterEventThroughContexts(const QMultiMap endedGestures = - finishedGestures + canceledGestures + undeliveredGestures; + finishedGestures + canceledGestures + undeliveredGestures + maybeToCanceledGestures; foreach (QGesture *gesture, endedGestures) { recycle(gesture); m_gestureTargets.remove(gesture); -- cgit v0.12 From d0a27b157c6a5d3cf4b75c6b1b71de399733f553 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 4 Jun 2010 10:28:11 +0200 Subject: Fixed GestureOverride event delivery in GraphicsView. GestureOverride event was not respected when delivering to items in GraphicsView. Task-number: QTBUG-10745 Reviewed-by: Thomas Zander --- src/gui/graphicsview/qgraphicsscene.cpp | 9 ++++- tests/auto/gestures/tst_gestures.cpp | 66 +++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 22c3f92..53a24a8 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -6088,8 +6088,15 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) if (ev.isAccepted() || ev.isAccepted(g)) { conflictedGestures.remove(g); // mark the item as a gesture target - if (item) + if (item) { gestureTargets.insert(g, item.data()); + QHash >::iterator it, e; + it = cachedItemGestures.begin(); + e = cachedItemGestures.end(); + for(; it != e; ++it) + it.value().remove(g); + cachedItemGestures[item.data()].insert(g); + } DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:" << "override was accepted:" << g << item.data(); diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 4a9f1d1..644a9b3 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -333,6 +333,7 @@ private slots: void gestureOverChild(); void multipleWidgetOnlyGestureInTree(); void conflictingGestures(); + void conflictingGesturesInGraphicsView(); void finishedWithoutStarted(); void unknownGesture(); void graphicsItemGesture(); @@ -2069,5 +2070,70 @@ void tst_Gestures::testQGestureRecognizerCleanup() delete w; } +void tst_Gestures::conflictingGesturesInGraphicsView() +{ + QGraphicsScene scene; + GraphicsView view(&scene); + view.setWindowFlags(Qt::X11BypassWindowManagerHint); + + GestureItem *item1 = new GestureItem("item1"); + item1->grabGesture(CustomGesture::GestureType); + item1->size = QRectF(0, 0, 100, 100); + item1->setZValue(2); + scene.addItem(item1); + + GestureItem *item2 = new GestureItem("item2"); + item2->grabGesture(CustomGesture::GestureType); + item2->size = QRectF(0, 0, 100, 100); + item2->setZValue(5); + scene.addItem(item2); + + view.show(); + QTest::qWaitForWindowShown(&view); + view.ensureVisible(scene.sceneRect()); + + static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; + + CustomEvent event; + + // nobody accepts override + item1->acceptGestureOverride = false; + item2->acceptGestureOverride = false; + event.hotSpot = mapToGlobal(item2->boundingRect().center(), item2, &view); + event.hasHotSpot = true; + sendCustomGesture(&event, item2, &scene); + QCOMPARE(item2->gestureOverrideEventsReceived, 1); + QCOMPARE(item2->gestureEventsReceived, TotalGestureEventsCount); + QCOMPARE(item1->gestureOverrideEventsReceived, 1); + QCOMPARE(item1->gestureEventsReceived, 0); + + item1->reset(); item2->reset(); + + // the original target accepts override + item1->acceptGestureOverride = false; + item2->acceptGestureOverride = true; + event.hotSpot = mapToGlobal(item2->boundingRect().center(), item2, &view); + event.hasHotSpot = true; + sendCustomGesture(&event, item2, &scene); + QCOMPARE(item2->gestureOverrideEventsReceived, 1); + QCOMPARE(item2->gestureEventsReceived, TotalGestureEventsCount); + QCOMPARE(item1->gestureOverrideEventsReceived, 0); + QCOMPARE(item1->gestureEventsReceived, 0); + + item1->reset(); item2->reset(); + + // the item behind accepts override + item1->acceptGestureOverride = true; + item2->acceptGestureOverride = false; + event.hotSpot = mapToGlobal(item2->boundingRect().center(), item2, &view); + event.hasHotSpot = true; + sendCustomGesture(&event, item2, &scene); + + QCOMPARE(item2->gestureOverrideEventsReceived, 1); + QCOMPARE(item2->gestureEventsReceived, 0); + QCOMPARE(item1->gestureOverrideEventsReceived, 1); + QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount); +} + QTEST_MAIN(tst_Gestures) #include "tst_gestures.moc" -- cgit v0.12 From c28da4dd467c2763bed5c6b31471f078ac26cee6 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 4 Jun 2010 11:13:19 +0200 Subject: Added setting a hotspot on standard gestures In order for gestures to work in graphicsview the hotspot should be set. The fix adds the hotspot to standard gestures that are shipped with Qt. Task-number: QTBUG-10967 Task-number: QT-3406 Reviewed-by: trustme --- src/gui/kernel/qstandardgestures.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index a575717..bfcfa86 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -110,6 +110,7 @@ QGestureRecognizer::Result QPanGestureRecognizer::recognize(QGesture *state, p1.pos().y() - p1.startPos().y() + p2.pos().y() - p2.startPos().y()) / 2; if (d->offset.x() > 10 || d->offset.y() > 10 || d->offset.x() < -10 || d->offset.y() < -10) { + q->setHotSpot(p1.startScreenPos()); result = QGestureRecognizer::TriggerGesture; } else { result = QGestureRecognizer::MayBeGesture; @@ -439,6 +440,7 @@ QGestureRecognizer::Result QTapGestureRecognizer::recognize(QGesture *state, switch (event->type()) { case QEvent::TouchBegin: { d->position = ev->touchPoints().at(0).pos(); + q->setHotSpot(ev->touchPoints().at(0).screenPos()); result = QGestureRecognizer::TriggerGesture; break; } @@ -521,6 +523,7 @@ QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object, if (d->timerId) q->killTimer(d->timerId); d->timerId = q->startTimer(TimerInterval); + q->setHotSpot(ev->touchPoints().at(0).startScreenPos()); result = QGestureRecognizer::TriggerGesture; break; case QEvent::TouchEnd: -- cgit v0.12 From 0c0f22ec0e36d7001c8195dcc6e390a37118e33e Mon Sep 17 00:00:00 2001 From: Michael Hasselmann Date: Mon, 7 Jun 2010 17:18:54 +0200 Subject: Fix QApplication/QWidget to really take ownership of input contexts * src/gui/kernel/[qapplication|qwidget].cpp, tests/auto/qapplication/tst_[qapplication|qwidget].cpp (setInputContext): The documentation for [QApplication|QWidget]::setInputContext claims that the [QApplication|QWidget] instance would take ownership. This commit fixes the setter to also reparent the input context. Furthermore, the crappy test for this setter was improved. Reviewed-by: Denis Dzyubenko --- src/gui/kernel/qapplication.cpp | 1 + src/gui/kernel/qwidget.cpp | 2 ++ tests/auto/qapplication/tst_qapplication.cpp | 19 +++++++++++++------ tests/auto/qwidget/tst_qwidget.cpp | 6 +++++- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index a2c058a..8529615 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -5297,6 +5297,7 @@ void QApplication::setInputContext(QInputContext *inputContext) } delete QApplicationPrivate::inputContext; QApplicationPrivate::inputContext = inputContext; + QApplicationPrivate::inputContext->setParent(this); } /*! diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index b5879ae..91dfaab 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -332,6 +332,8 @@ void QWidget::setInputContext(QInputContext *context) if (d->ic) delete d->ic; d->ic = context; + if (d->ic) + d->ic->setParent(this); #endif } diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp index 43fbba1..1a38070 100644 --- a/tests/auto/qapplication/tst_qapplication.cpp +++ b/tests/auto/qapplication/tst_qapplication.cpp @@ -189,15 +189,22 @@ void tst_QApplication::getSetCheck() { int argc = 0; QApplication obj1(argc, 0, QApplication::GuiServer); - // QInputContext * QApplication::inputContext() - // void QApplication::setInputContext(QInputContext *) MyInputContext *var1 = new MyInputContext; + + // QApplication takes ownership, so check for reparenting: obj1.setInputContext(var1); - QCOMPARE((QInputContext *)var1, obj1.inputContext()); + QCOMPARE(var1->parent(), static_cast(&obj1)); + + // Test for self-assignment: + obj1.setInputContext(obj1.inputContext()); + QVERIFY(obj1.inputContext()); + QCOMPARE(static_cast(var1), obj1.inputContext()); + + // Resetting the input context to 0 is not allowed: QTest::ignoreMessage(QtWarningMsg, "QApplication::setInputContext: called with 0 input context"); - obj1.setInputContext((QInputContext *)0); - QCOMPARE((QInputContext *)var1, obj1.inputContext()); - // delete var1; // No delete, since QApplication takes ownership + obj1.setInputContext(0); + + QCOMPARE(static_cast(var1), obj1.inputContext()); } class CloseEventTestWindow : public QWidget diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 5d47aed..83a9e3a 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -605,10 +605,14 @@ void tst_QWidget::getSetCheck() obj1.setAttribute(Qt::WA_InputMethodEnabled); obj1.setInputContext(var13); QCOMPARE(static_cast(var13), obj1.inputContext()); + // QWidget takes ownership, so check parent + QCOMPARE(var13->parent(), static_cast(&obj1)); + // Check self assignment + obj1.setInputContext(obj1.inputContext()); + QCOMPARE(static_cast(var13), obj1.inputContext()); obj1.setInputContext((QInputContext *)0); QCOMPARE(qApp->inputContext(), obj1.inputContext()); QVERIFY(qApp->inputContext() != var13); - //delete var13; // No delete, since QWidget takes ownership // bool QWidget::autoFillBackground() // void QWidget::setAutoFillBackground(bool) -- cgit v0.12 From dfbd44c8ec75d3b0156547ef3fb5811a4548a0a5 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 7 Jun 2010 18:49:48 +0200 Subject: Unbreak Linux build when qendian.h is included before qglobal.h --- mkspecs/common/g++.conf | 2 +- mkspecs/common/linux.conf | 4 +-- src/corelib/global/qendian.h | 1 + src/gui/image/qimage.cpp | 10 ++++++ src/plugins/imageformats/gif/qgifhandler.cpp | 49 ++++++++++++++-------------- 5 files changed, 38 insertions(+), 28 deletions(-) diff --git a/mkspecs/common/g++.conf b/mkspecs/common/g++.conf index d3db24a..b3d6296 100644 --- a/mkspecs/common/g++.conf +++ b/mkspecs/common/g++.conf @@ -7,7 +7,7 @@ QMAKE_CFLAGS += -pipe QMAKE_CFLAGS_DEPS += -M QMAKE_CFLAGS_WARN_ON += -Wall -W QMAKE_CFLAGS_WARN_OFF += -w -QMAKE_CFLAGS_RELEASE += -O2 +QMAKE_CFLAGS_RELEASE += -g -O2 QMAKE_CFLAGS_DEBUG += -g QMAKE_CFLAGS_SHLIB += -fPIC QMAKE_CFLAGS_STATIC_LIB += -fPIC diff --git a/mkspecs/common/linux.conf b/mkspecs/common/linux.conf index 4fbe2dc..320ae71 100644 --- a/mkspecs/common/linux.conf +++ b/mkspecs/common/linux.conf @@ -51,8 +51,8 @@ QMAKE_COPY_DIR = $(COPY) -r QMAKE_MOVE = mv -f QMAKE_DEL_FILE = rm -f QMAKE_DEL_DIR = rmdir -QMAKE_STRIP = strip -QMAKE_STRIPFLAGS_LIB += --strip-unneeded +#QMAKE_STRIP = strip +#QMAKE_STRIPFLAGS_LIB += --strip-unneeded QMAKE_CHK_DIR_EXISTS = test -d QMAKE_MKDIR = mkdir -p QMAKE_INSTALL_FILE = install -m 644 -p diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h index 353e8b9..01550cf 100644 --- a/src/corelib/global/qendian.h +++ b/src/corelib/global/qendian.h @@ -43,6 +43,7 @@ #define QENDIAN_H #ifdef Q_OS_LINUX +# include QT_BEGIN_INCLUDE_NAMESPACE # include QT_END_INCLUDE_NAMESPACE diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 98f235e..6408432 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -245,6 +245,11 @@ QImageData * QImageData::create(const QSize &size, QImage::Format format, int nu return 0; } + if (d->nbytes == 15840000) + { + d->nbytes = 15840000; + } + d->ref.ref(); return d.take(); @@ -898,6 +903,11 @@ QImageData *QImageData::create(uchar *data, int width, int height, int bpl, QIm d->bytes_per_line = bpl; d->nbytes = d->bytes_per_line * height; + if (d->nbytes == 15840000) + { + d->nbytes = 15840000; + } + return d; } diff --git a/src/plugins/imageformats/gif/qgifhandler.cpp b/src/plugins/imageformats/gif/qgifhandler.cpp index 8abc2d1..fa89f0a 100644 --- a/src/plugins/imageformats/gif/qgifhandler.cpp +++ b/src/plugins/imageformats/gif/qgifhandler.cpp @@ -78,8 +78,8 @@ public: bool partialNewFrame; private: - void fillRect(QImage *image, int x, int y, int w, int h, QRgb col); - inline QRgb color(uchar index) const; + void fillRect(QImage *image, int x, int y, int w, int h, uchar col); + //inline uchar color(uchar index) const; // GIF specific stuff QRgb* globalcmap; @@ -197,13 +197,13 @@ void QGIFFormat::disposePrevious(QImage *image) case RestoreBackground: if (trans_index>=0) { // Easy: we use the transparent color - fillRect(image, l, t, r-l+1, b-t+1, Q_TRANSPARENT); + fillRect(image, l, t, r-l+1, b-t+1, trans_index); } else if (bgcol>=0) { // Easy: we use the bgcol given - fillRect(image, l, t, r-l+1, b-t+1, color(bgcol)); + fillRect(image, l, t, r-l+1, b-t+1, bgcol); } else { // Impossible: We don't know of a bgcol - use pixel 0 - QRgb *bits = (QRgb*)image->bits(); + const uchar *bits = image->constBits(); fillRect(image, l, t, r-l+1, b-t+1, bits[0]); } // ### Changed: QRect(l, t, r-l+1, b-t+1) @@ -211,9 +211,7 @@ void QGIFFormat::disposePrevious(QImage *image) case RestoreImage: { if (frame >= 0) { for (int ln=t; ln<=b; ln++) { - memcpy(image->scanLine(ln)+l, - backingstore.scanLine(ln-t), - (r-l+1)*sizeof(QRgb)); + memcpy(image->scanLine(ln)+l, backingstore.constScanLine(ln-t), (r-l+1)); } // ### Changed: QRect(l, t, r-l+1, b-t+1) } @@ -341,9 +339,8 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, if (sheight <= 0) sheight = newtop + newheight; - QImage::Format format = trans_index >= 0 ? QImage::Format_ARGB32 : QImage::Format_RGB32; if (image->isNull()) { - (*image) = QImage(swidth, sheight, format); + (*image) = QImage(swidth, sheight, QImage::Format_Indexed8); bpl = image->bytesPerLine(); bits = image->bits(); memset(bits, 0, image->byteCount()); @@ -377,10 +374,10 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, if (left || top || width= 0) { - fillRect(image, 0, 0, swidth, sheight, color(trans_index)); + fillRect(image, 0, 0, swidth, sheight, trans_index); // ### Changed: QRect(0, 0, swidth, sheight) } else if (bgcol>=0) { - fillRect(image, 0, 0, swidth, sheight, color(bgcol)); + fillRect(image, 0, 0, swidth, sheight, bgcol); // ### Changed: QRect(0, 0, swidth, sheight) } } @@ -399,7 +396,7 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, // We just use the backing store as a byte array backingstore = QImage(qMax(backingstore.width(), w), qMax(backingstore.height(), h), - QImage::Format_RGB32); + QImage::Format_Indexed8); memset(bits, 0, image->byteCount()); } const int dest_bpl = backingstore.bytesPerLine(); @@ -479,7 +476,7 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, if (needfirst) { firstcode=oldcode=code; if (!out_of_bounds && image->height() > y && firstcode!=trans_index) - ((QRgb*)FAST_SCAN_LINE(bits, bpl, y))[x] = color(firstcode); + FAST_SCAN_LINE(bits, bpl, y)[x] = firstcode; x++; if (x>=swidth) out_of_bounds = true; needfirst=false; @@ -909,11 +906,11 @@ void QGIFFormat::scan(QIODevice *device, QVector *imageSizes, int *loopCo return; } -void QGIFFormat::fillRect(QImage *image, int col, int row, int w, int h, QRgb color) +void QGIFFormat::fillRect(QImage *image, int col, int row, int w, int h, uchar color) { if (w>0) { for (int j=0; jscanLine(j+row); + uchar *line = (uchar*)image->scanLine(j+row); for (int i=0; i= sheight) out_of_bounds=true; //y=bottom; } -inline QRgb QGIFFormat::color(uchar index) const +#if 0 +inline uchar QGIFFormat::color(uchar index) const { if (index == trans_index || index > ncols) - return Q_TRANSPARENT; + return trans_index; - QRgb *map = lcmap ? localcmap : globalcmap; + uchar *map = lcmap ? localcmap : globalcmap; return map ? map[index] : 0; } +#endif //------------------------------------------------------------------------- //------------------------------------------------------------------------- -- cgit v0.12 From fee316304b48bb3437e122c34b2127d6ccc4f469 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 7 Jun 2010 19:08:46 +0200 Subject: Revert accidental commit of irrelevant stuff. Silly mondays.. This reverts commit dfbd44c8ec75d3b0156547ef3fb5811a4548a0a5. --- mkspecs/common/g++.conf | 2 +- mkspecs/common/linux.conf | 4 +-- src/corelib/global/qendian.h | 1 - src/gui/image/qimage.cpp | 10 ------ src/plugins/imageformats/gif/qgifhandler.cpp | 49 ++++++++++++++-------------- 5 files changed, 28 insertions(+), 38 deletions(-) diff --git a/mkspecs/common/g++.conf b/mkspecs/common/g++.conf index b3d6296..d3db24a 100644 --- a/mkspecs/common/g++.conf +++ b/mkspecs/common/g++.conf @@ -7,7 +7,7 @@ QMAKE_CFLAGS += -pipe QMAKE_CFLAGS_DEPS += -M QMAKE_CFLAGS_WARN_ON += -Wall -W QMAKE_CFLAGS_WARN_OFF += -w -QMAKE_CFLAGS_RELEASE += -g -O2 +QMAKE_CFLAGS_RELEASE += -O2 QMAKE_CFLAGS_DEBUG += -g QMAKE_CFLAGS_SHLIB += -fPIC QMAKE_CFLAGS_STATIC_LIB += -fPIC diff --git a/mkspecs/common/linux.conf b/mkspecs/common/linux.conf index 320ae71..4fbe2dc 100644 --- a/mkspecs/common/linux.conf +++ b/mkspecs/common/linux.conf @@ -51,8 +51,8 @@ QMAKE_COPY_DIR = $(COPY) -r QMAKE_MOVE = mv -f QMAKE_DEL_FILE = rm -f QMAKE_DEL_DIR = rmdir -#QMAKE_STRIP = strip -#QMAKE_STRIPFLAGS_LIB += --strip-unneeded +QMAKE_STRIP = strip +QMAKE_STRIPFLAGS_LIB += --strip-unneeded QMAKE_CHK_DIR_EXISTS = test -d QMAKE_MKDIR = mkdir -p QMAKE_INSTALL_FILE = install -m 644 -p diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h index 01550cf..353e8b9 100644 --- a/src/corelib/global/qendian.h +++ b/src/corelib/global/qendian.h @@ -43,7 +43,6 @@ #define QENDIAN_H #ifdef Q_OS_LINUX -# include QT_BEGIN_INCLUDE_NAMESPACE # include QT_END_INCLUDE_NAMESPACE diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 6408432..98f235e 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -245,11 +245,6 @@ QImageData * QImageData::create(const QSize &size, QImage::Format format, int nu return 0; } - if (d->nbytes == 15840000) - { - d->nbytes = 15840000; - } - d->ref.ref(); return d.take(); @@ -903,11 +898,6 @@ QImageData *QImageData::create(uchar *data, int width, int height, int bpl, QIm d->bytes_per_line = bpl; d->nbytes = d->bytes_per_line * height; - if (d->nbytes == 15840000) - { - d->nbytes = 15840000; - } - return d; } diff --git a/src/plugins/imageformats/gif/qgifhandler.cpp b/src/plugins/imageformats/gif/qgifhandler.cpp index fa89f0a..8abc2d1 100644 --- a/src/plugins/imageformats/gif/qgifhandler.cpp +++ b/src/plugins/imageformats/gif/qgifhandler.cpp @@ -78,8 +78,8 @@ public: bool partialNewFrame; private: - void fillRect(QImage *image, int x, int y, int w, int h, uchar col); - //inline uchar color(uchar index) const; + void fillRect(QImage *image, int x, int y, int w, int h, QRgb col); + inline QRgb color(uchar index) const; // GIF specific stuff QRgb* globalcmap; @@ -197,13 +197,13 @@ void QGIFFormat::disposePrevious(QImage *image) case RestoreBackground: if (trans_index>=0) { // Easy: we use the transparent color - fillRect(image, l, t, r-l+1, b-t+1, trans_index); + fillRect(image, l, t, r-l+1, b-t+1, Q_TRANSPARENT); } else if (bgcol>=0) { // Easy: we use the bgcol given - fillRect(image, l, t, r-l+1, b-t+1, bgcol); + fillRect(image, l, t, r-l+1, b-t+1, color(bgcol)); } else { // Impossible: We don't know of a bgcol - use pixel 0 - const uchar *bits = image->constBits(); + QRgb *bits = (QRgb*)image->bits(); fillRect(image, l, t, r-l+1, b-t+1, bits[0]); } // ### Changed: QRect(l, t, r-l+1, b-t+1) @@ -211,7 +211,9 @@ void QGIFFormat::disposePrevious(QImage *image) case RestoreImage: { if (frame >= 0) { for (int ln=t; ln<=b; ln++) { - memcpy(image->scanLine(ln)+l, backingstore.constScanLine(ln-t), (r-l+1)); + memcpy(image->scanLine(ln)+l, + backingstore.scanLine(ln-t), + (r-l+1)*sizeof(QRgb)); } // ### Changed: QRect(l, t, r-l+1, b-t+1) } @@ -339,8 +341,9 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, if (sheight <= 0) sheight = newtop + newheight; + QImage::Format format = trans_index >= 0 ? QImage::Format_ARGB32 : QImage::Format_RGB32; if (image->isNull()) { - (*image) = QImage(swidth, sheight, QImage::Format_Indexed8); + (*image) = QImage(swidth, sheight, format); bpl = image->bytesPerLine(); bits = image->bits(); memset(bits, 0, image->byteCount()); @@ -374,10 +377,10 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, if (left || top || width= 0) { - fillRect(image, 0, 0, swidth, sheight, trans_index); + fillRect(image, 0, 0, swidth, sheight, color(trans_index)); // ### Changed: QRect(0, 0, swidth, sheight) } else if (bgcol>=0) { - fillRect(image, 0, 0, swidth, sheight, bgcol); + fillRect(image, 0, 0, swidth, sheight, color(bgcol)); // ### Changed: QRect(0, 0, swidth, sheight) } } @@ -396,7 +399,7 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, // We just use the backing store as a byte array backingstore = QImage(qMax(backingstore.width(), w), qMax(backingstore.height(), h), - QImage::Format_Indexed8); + QImage::Format_RGB32); memset(bits, 0, image->byteCount()); } const int dest_bpl = backingstore.bytesPerLine(); @@ -476,7 +479,7 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, if (needfirst) { firstcode=oldcode=code; if (!out_of_bounds && image->height() > y && firstcode!=trans_index) - FAST_SCAN_LINE(bits, bpl, y)[x] = firstcode; + ((QRgb*)FAST_SCAN_LINE(bits, bpl, y))[x] = color(firstcode); x++; if (x>=swidth) out_of_bounds = true; needfirst=false; @@ -906,11 +909,11 @@ void QGIFFormat::scan(QIODevice *device, QVector *imageSizes, int *loopCo return; } -void QGIFFormat::fillRect(QImage *image, int col, int row, int w, int h, uchar color) +void QGIFFormat::fillRect(QImage *image, int col, int row, int w, int h, QRgb color) { if (w>0) { for (int j=0; jscanLine(j+row); + QRgb *line = (QRgb*)image->scanLine(j+row); for (int i=0; i= sheight) out_of_bounds=true; //y=bottom; } -#if 0 -inline uchar QGIFFormat::color(uchar index) const +inline QRgb QGIFFormat::color(uchar index) const { if (index == trans_index || index > ncols) - return trans_index; + return Q_TRANSPARENT; - uchar *map = lcmap ? localcmap : globalcmap; + QRgb *map = lcmap ? localcmap : globalcmap; return map ? map[index] : 0; } -#endif //------------------------------------------------------------------------- //------------------------------------------------------------------------- -- cgit v0.12 From d70dcb5f120affb8a908d4fbcdf16eef4c51389c Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 7 Jun 2010 19:10:44 +0200 Subject: Unbreak Linux build when qendian.h is included before qglobal.h --- src/corelib/global/qendian.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h index 353e8b9..01550cf 100644 --- a/src/corelib/global/qendian.h +++ b/src/corelib/global/qendian.h @@ -43,6 +43,7 @@ #define QENDIAN_H #ifdef Q_OS_LINUX +# include QT_BEGIN_INCLUDE_NAMESPACE # include QT_END_INCLUDE_NAMESPACE -- cgit v0.12