From eeb5c3dba27b02f6ddeb69257e78b22149ca8487 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 28 Jul 2010 19:20:19 +0200 Subject: QScript: document/obsolete things that does not work since the move to JSC Reviewed-by: Kent Hansen --- src/script/api/qscriptcontext.cpp | 10 ++++++++++ src/script/api/qscriptcontextinfo.cpp | 11 ++--------- src/script/api/qscriptcontextinfo.h | 4 +++- src/script/api/qscriptengine.cpp | 11 ++++------- src/script/api/qscriptengineagent.cpp | 7 ++++--- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/script/api/qscriptcontext.cpp b/src/script/api/qscriptcontext.cpp index 3f08e74..1a11100 100644 --- a/src/script/api/qscriptcontext.cpp +++ b/src/script/api/qscriptcontext.cpp @@ -323,6 +323,9 @@ QScriptValue QScriptContext::argumentsObject() const When a function is called as constructor, the thisObject() contains the newly constructed object to be initialized. + + \note This function is only guarenteed to work for a context + corresponding to native functions. */ bool QScriptContext::isCalledAsConstructor() const { @@ -413,6 +416,9 @@ void QScriptContext::setReturnValue(const QScriptValue &result) object provides access to the local variables associated with this context. + \note The activation object might not be available if there is no + active QScriptEngineAgent, as it might be optimized. + \sa argument(), argumentsObject() */ @@ -472,6 +478,10 @@ QScriptValue QScriptContext::activationObject() const activation. If \a activation is not an object, this function does nothing. + + \note For a context corresponding to a JavaScript function, this is only + guarenteed to work if there was an QScriptEngineAgent active on the + engine while the function was evaluated. */ void QScriptContext::setActivationObject(const QScriptValue &activation) { diff --git a/src/script/api/qscriptcontextinfo.cpp b/src/script/api/qscriptcontextinfo.cpp index ebb1770..a90e014 100644 --- a/src/script/api/qscriptcontextinfo.cpp +++ b/src/script/api/qscriptcontextinfo.cpp @@ -53,8 +53,7 @@ QT_BEGIN_NAMESPACE current statement. If the called function is executing Qt Script code, you can obtain - the script location with the functions fileName(), lineNumber() and - columnNumber(). + the script location with the functions fileName() and lineNumber(). You can obtain the starting line number and ending line number of a Qt Script function definition with functionStartLineNumber() and @@ -317,13 +316,7 @@ int QScriptContextInfo::lineNumber() const } /*! - Returns the column number corresponding to the statement being - executed, or -1 if the column number is not available. - - The column number is only available if Qt Script code is being - executed. - - \sa lineNumber(), fileName() + \obsolete */ int QScriptContextInfo::columnNumber() const { diff --git a/src/script/api/qscriptcontextinfo.h b/src/script/api/qscriptcontextinfo.h index d0b3f21..64a1e15 100644 --- a/src/script/api/qscriptcontextinfo.h +++ b/src/script/api/qscriptcontextinfo.h @@ -69,7 +69,9 @@ public: qint64 scriptId() const; QString fileName() const; int lineNumber() const; - int columnNumber() const; +#ifdef QT_DEPRECATED + QT_DEPRECATED int columnNumber() const; +#endif QString functionName() const; FunctionType functionType() const; diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 26673f4..c566f25 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -152,8 +152,7 @@ QT_BEGIN_NAMESPACE evaluation caused an exception by calling hasUncaughtException(). In that case, you can call toString() on the error object to obtain an error message. The current uncaught exception is also available - through uncaughtException(). You can obtain a human-readable - backtrace of the exception with uncaughtExceptionBacktrace(). + through uncaughtException(). Calling clearExceptions() will cause any uncaught exceptions to be cleared. @@ -2800,8 +2799,7 @@ void QScriptEnginePrivate::popContext() The exception state is cleared when evaluate() is called. - \sa uncaughtException(), uncaughtExceptionLineNumber(), - uncaughtExceptionBacktrace() + \sa uncaughtException(), uncaughtExceptionLineNumber() */ bool QScriptEngine::hasUncaughtException() const { @@ -2819,7 +2817,6 @@ bool QScriptEngine::hasUncaughtException() const message. \sa hasUncaughtException(), uncaughtExceptionLineNumber(), - uncaughtExceptionBacktrace() */ QScriptValue QScriptEngine::uncaughtException() const { @@ -2839,7 +2836,7 @@ QScriptValue QScriptEngine::uncaughtException() const Line numbers are 1-based, unless a different base was specified as the second argument to evaluate(). - \sa hasUncaughtException(), uncaughtExceptionBacktrace() + \sa hasUncaughtException() */ int QScriptEngine::uncaughtExceptionLineNumber() const { @@ -2851,7 +2848,7 @@ int QScriptEngine::uncaughtExceptionLineNumber() const /*! Returns a human-readable backtrace of the last uncaught exception. - Each line is of the form \c{()@:}. + It is in the form \c{()@:}. \sa uncaughtException() */ diff --git a/src/script/api/qscriptengineagent.cpp b/src/script/api/qscriptengineagent.cpp index c3d1566..b1f131e 100644 --- a/src/script/api/qscriptengineagent.cpp +++ b/src/script/api/qscriptengineagent.cpp @@ -372,9 +372,8 @@ void QScriptEngineAgent::functionExit(qint64 scriptId, /*! This function is called when the engine is about to execute a new statement in the script identified by \a scriptId. The statement - begins on the line and column specified by \a lineNumber and \a - columnNumber. This event is not generated for native Qt Script - functions. + begins on the line and column specified by \a lineNumber + This event is not generated for native Qt Script functions. Reimplement this function to handle this event. For example, a debugger implementation could reimplement this function to provide @@ -383,6 +382,8 @@ void QScriptEngineAgent::functionExit(qint64 scriptId, The default implementation does nothing. + \note \a columnNumber is undefined + \sa scriptLoad(), functionEntry() */ void QScriptEngineAgent::positionChange(qint64 scriptId, -- cgit v0.12 From 5d68ac574e7edbfd91c53e96c80045effa17a1e9 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 28 Jul 2010 19:21:47 +0200 Subject: QScript: remove JSC::JSLock They are useless and cause warnings in the code. Reviewed-by: Kent Hansen --- src/script/api/qscriptengine.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index c566f25..8560214 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -44,7 +44,6 @@ #include "CodeBlock.h" #include "Error.h" -#include "JSLock.h" #include "Interpreter.h" #include "PrototypeFunction.h" @@ -1002,7 +1001,6 @@ QScriptEnginePrivate::~QScriptEnginePrivate() detachAllRegisteredScriptStrings(); qDeleteAll(m_qobjectData); qDeleteAll(m_typeInfos); - JSC::JSLock lock(false); globalData->heap.destroy(); globalData->deref(); while (freeScriptValues) { @@ -1291,7 +1289,6 @@ bool QScriptEnginePrivate::isCollecting() const void QScriptEnginePrivate::collectGarbage() { - JSC::JSLock lock(false); QScript::APIShim shim(this); globalData->heap.collectAllGarbage(); } @@ -1321,7 +1318,6 @@ JSC::JSValue QScriptEnginePrivate::evaluateHelper(JSC::ExecState *exec, intptr_t bool &compile) { Q_Q(QScriptEngine); - JSC::JSLock lock(false); // ### hmmm QBoolBlocker inEvalBlocker(inEval, true); q->currentContext()->activationObject(); //force the creation of a context for native function; -- cgit v0.12 From 121c5143f1002734ff7aa62785ff14e0e6612aae Mon Sep 17 00:00:00 2001 From: John Brooks Date: Thu, 29 Jul 2010 11:06:03 +0200 Subject: Fix the byte order in QImage::fill for 24bpp formats QImage::fill() was using BGR ordering for 24-bit formats, which is always incorrect as QImage does not support BGR. qrgb888 is the correct 24-bit helper class that does use the proper order. Merge-request: 2440 Reviewed-by: Olivier Goffart --- src/gui/image/qimage.cpp | 2 +- tests/auto/qimage/tst_qimage.cpp | 64 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 30cf758..52ba2b9 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -2010,7 +2010,7 @@ void QImage::fill(uint pixel) 0, 0, d->width, d->height, d->bytes_per_line); return; } else if (d->depth == 24) { - qt_rectfill(reinterpret_cast(d->data), pixel, + qt_rectfill(reinterpret_cast(d->data), pixel, 0, 0, d->width, d->height, d->bytes_per_line); return; } diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp index 1330d96..62deb5ae 100644 --- a/tests/auto/qimage/tst_qimage.cpp +++ b/tests/auto/qimage/tst_qimage.cpp @@ -103,6 +103,9 @@ private slots: void copy(); + void fill_data(); + void fill(); + void setPixel_data(); void setPixel(); @@ -1015,6 +1018,67 @@ void tst_QImage::copy() } } +void tst_QImage::fill_data() +{ + QTest::addColumn("format"); + QTest::addColumn("input"); + QTest::addColumn("expectedResult"); + + QTest::newRow("ARGB32") << int(QImage::Format_ARGB32) << 0x33557799u << 0x33557799u; + QTest::newRow("RGB888") << int(QImage::Format_RGB888) << 0x335577u << 0x335577u; + QTest::newRow("RGB16") << int(QImage::Format_RGB16) << 0x3355u << 0x3355u; + QTest::newRow("Indexed8") << int(QImage::Format_Indexed8) << 0x55u << 0x55u; + QTest::newRow("Mono") << int(QImage::Format_Mono) << 1u << 1u; + QTest::newRow("Mono_LSB") << int(QImage::Format_MonoLSB) << 0u << 0u; +} + +void tst_QImage::fill() +{ + QFETCH(int, format); + QFETCH(uint, input); + QFETCH(uint, expectedResult); + + QImage img(13, 15, (QImage::Format)format); + img.fill(input); + + const int bpp = img.depth(); + for (int y = 0; y < img.height(); ++y) { + uchar *line = img.scanLine(y); + for (int x = 0; x < img.width(); ++x) { + uint value; + switch (bpp) { + case 32: + value = *((uint*)line); + line += 4; + break; + case 24: + value = ((uint)line[0] << 16) | ((uint)line[1] << 8) | line[2]; + line += 3; + break; + case 16: + value = *((quint16*)line); + line += 2; + break; + case 8: + value = *line; + line++; + break; + case 1: + if (format == QImage::Format_Mono) + value = (*line >> (7- (x & 7))) & 1; + else if (format == QImage::Format_MonoLSB) + value = (*line >> (x & 7)) & 1; + + if (x && !(x & 7)) + ++line; + break; + } + + QCOMPARE(value, expectedResult); + } + } +} + void tst_QImage::setPixel_data() { QTest::addColumn("format"); -- cgit v0.12 From ebbab30af417dfbf3df47dec15c0e2f8d6a30fa6 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Thu, 29 Jul 2010 11:09:48 +0200 Subject: Fix the rendering of lines with the X11 paint engine On the X11 paint engine, when rendering lines with float coordinates, the lines were one pixel off if the decimal was > 0.5. This fixes the WebKit bug https://bugs.webkit.org/show_bug.cgi?id=42248 Autotest by Yoann Lopes. Reviewed-by: Simon Hausmann Reviewed-by: Yoann Lopes Reviewed-by: Andreas Kling --- src/gui/painting/qpaintengine_x11.cpp | 22 ++++++------ tests/auto/qpainter/tst_qpainter.cpp | 65 +++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 12 deletions(-) diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp index 910b2df..e521e01 100644 --- a/src/gui/painting/qpaintengine_x11.cpp +++ b/src/gui/painting/qpaintengine_x11.cpp @@ -696,11 +696,10 @@ void QX11PaintEngine::drawLines(const QLine *lines, int lineCount) linef = d->matrix.map(QLineF(lines[i])); } if (clipLine(&linef, d->polygonClipper.boundingRect())) { - int x1 = qRound(linef.x1() + aliasedCoordinateDelta); - int y1 = qRound(linef.y1() + aliasedCoordinateDelta); - int x2 = qRound(linef.x2() + aliasedCoordinateDelta); - int y2 = qRound(linef.y2() + aliasedCoordinateDelta); - + int x1 = qFloor(linef.x1() + aliasedCoordinateDelta); + int y1 = qFloor(linef.y1() + aliasedCoordinateDelta); + int x2 = qFloor(linef.x2() + aliasedCoordinateDelta); + int y2 = qFloor(linef.y2() + aliasedCoordinateDelta); XDrawLine(d->dpy, d->hd, d->gc, x1, y1, x2, y2); } } @@ -730,11 +729,10 @@ void QX11PaintEngine::drawLines(const QLineF *lines, int lineCount) for (int i = 0; i < lineCount; ++i) { QLineF linef = d->matrix.map(lines[i]); if (clipLine(&linef, d->polygonClipper.boundingRect())) { - int x1 = qRound(linef.x1() + aliasedCoordinateDelta); - int y1 = qRound(linef.y1() + aliasedCoordinateDelta); - int x2 = qRound(linef.x2() + aliasedCoordinateDelta); - int y2 = qRound(linef.y2() + aliasedCoordinateDelta); - + int x1 = qFloor(linef.x1() + aliasedCoordinateDelta); + int y1 = qFloor(linef.y1() + aliasedCoordinateDelta); + int x2 = qFloor(linef.x2() + aliasedCoordinateDelta); + int y2 = qFloor(linef.y2() + aliasedCoordinateDelta); XDrawLine(d->dpy, d->hd, d->gc, x1, y1, x2, y2); } } @@ -1690,8 +1688,8 @@ void QX11PaintEnginePrivate::strokePolygon_dev(const QPointF *polygonPoints, int if (clippedCount > 0) { QVarLengthArray xpoints(clippedCount); for (int i = 0; i < clippedCount; ++i) { - xpoints[i].x = qRound(clippedPoints[i].x + aliasedCoordinateDelta); - xpoints[i].y = qRound(clippedPoints[i].y + aliasedCoordinateDelta); + xpoints[i].x = qFloor(clippedPoints[i].x + aliasedCoordinateDelta); + xpoints[i].y = qFloor(clippedPoints[i].y + aliasedCoordinateDelta); } uint numberPoints = qMin(clippedCount, xlibMaxLinePoints); XPoint *pts = xpoints.data(); diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index f358681..2cbb9b2 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -118,10 +118,12 @@ private slots: void drawLine_task190634(); void drawLine_task229459(); void drawLine_task234891(); + void drawHorizontalLineF(); void drawRect_data() { fillData(); } void drawRect(); void drawRect2(); + void drawRectFHorizontalLine(); void fillRect(); void fillRect2(); @@ -251,6 +253,7 @@ private slots: void setPenColorOnPixmap(); void QTBUG5939_attachPainterPrivate(); + void drawHorizontalLine(); private: void fillData(); @@ -1218,6 +1221,26 @@ void tst_QPainter::drawLine_task234891() QCOMPARE(expected, img); } +void tst_QPainter::drawHorizontalLineF() +{ + QPixmap pixmap(100, 3); + pixmap.fill(); + + { + QPainter painter(&pixmap); + painter.drawLine(QLineF(1.5f, 1.5f, 98.5f, 1.5f)); + } + + QImage refImage(100, 3, QImage::Format_ARGB32); + refImage.fill(0xFFFFFFFF); + { + QPainter painter(&refImage); + painter.drawLine(QLineF(1.5f, 1.5f, 98.5f, 1.5f)); + } + + QCOMPARE(pixmap.toImage().convertToFormat(QImage::Format_ARGB32), refImage); +} + void tst_QPainter::drawLine_task216948() { QImage img(1, 10, QImage::Format_ARGB32_Premultiplied); @@ -1302,6 +1325,26 @@ void tst_QPainter::drawRect2() } } +void tst_QPainter::drawRectFHorizontalLine() +{ + QPixmap pixmap(100, 3); + pixmap.fill(); + + { + QPainter painter(&pixmap); + painter.drawRect(QRectF(1.5f, 1.5f, 98.5f, 1.5f)); + } + + QImage refImage(100, 3, QImage::Format_ARGB32); + refImage.fill(0xFFFFFFFF); + { + QPainter painter(&refImage); + painter.drawRect(QRectF(1.5f, 1.5f, 98.5f, 1.5f)); + } + + QCOMPARE(pixmap.toImage().convertToFormat(QImage::Format_ARGB32), refImage); +} + void tst_QPainter::fillRect() { QImage image(100, 100, QImage::Format_ARGB32_Premultiplied); @@ -4522,6 +4565,28 @@ void tst_QPainter::QTBUG5939_attachPainterPrivate() QCOMPARE(widget->deviceTransform, proxy->deviceTransform); } +void tst_QPainter::drawHorizontalLine() +{ + QPixmap pixmap(100, 3); + pixmap.fill(); + + { + QPainter painter(&pixmap); + painter.translate(0.3, 0.3); + painter.drawLine(QLine(1, 1, 99, 1)); + } + + QImage refImage(100, 3, QImage::Format_ARGB32); + refImage.fill(0xFFFFFFFF); + { + QPainter painter(&refImage); + painter.translate(0.3, 0.3); + painter.drawLine(QLine(1, 1, 99, 1)); + } + + QCOMPARE(pixmap.toImage().convertToFormat(QImage::Format_ARGB32), refImage); +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" -- cgit v0.12 From d8c6ae24f94133828f4f1b536538e69c5e438202 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 30 Jul 2010 11:10:05 +0200 Subject: Fix tst_QPainter::drawImage_task258776 This test was broken, and change 121c5143f1002734ff7aa62785ff14e0e6612aae exposed it. Why would one check red == blue? --- tests/auto/qpainter/tst_qpainter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 2cbb9b2..7679545 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -3642,7 +3642,7 @@ void tst_QPainter::drawImage_task258776() painter.end(); QImage expected(33, 33, QImage::Format_RGB32); - expected.fill(0xff0000); + expected.fill(0x0000ff); painter.begin(&expected); painter.drawImage(QRectF(0, 0, 32, 32), src); -- cgit v0.12 From 43f37074391b338b250883dfeb4a16844ca759fd Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 2 Aug 2010 09:36:00 +0200 Subject: Fix crash when setting font decorations on text drawn with QStaticText Qt has a run-time assert for implementing drawPolygon() in any subclass of QPaintEngine, which will be hit if set font decorations on the font used by QStaticText. Since we don't care about line decorations or any other shapes drawn in the QTextLayout, we simply leave the implementation empty. Reviewed-by: Gunnar --- src/gui/text/qstatictext.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index f6daed8..7396bcd 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -472,7 +472,12 @@ namespace { memcpy(charsDestination, ti.chars, sizeof(QChar) * currentItem.numChars); m_items.append(currentItem); - } + } + + virtual void drawPolygon(const QPointF *, int , PolygonDrawMode ) + { + /* intentionally empty */ + } virtual bool begin(QPaintDevice *) { return true; } virtual bool end() { return true; } -- cgit v0.12 From f127fadc833f7b64977877879787d96586d0a501 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 2 Aug 2010 11:11:52 +0200 Subject: Revert "Fix the byte order in QImage::fill for 24bpp formats" This change the behavior. (as it break tests like drawImage_task258776 and tst_QPainter::drawhelper_blend_color) The bug it fixes is not considered importent enough This reverts commit 121c5143f1002734ff7aa62785ff14e0e6612aae and d8c6ae24f94133828f4f1b536538e69c5e438202 --- src/gui/image/qimage.cpp | 2 +- tests/auto/qimage/tst_qimage.cpp | 64 ------------------------------------ tests/auto/qpainter/tst_qpainter.cpp | 2 +- 3 files changed, 2 insertions(+), 66 deletions(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 52ba2b9..30cf758 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -2010,7 +2010,7 @@ void QImage::fill(uint pixel) 0, 0, d->width, d->height, d->bytes_per_line); return; } else if (d->depth == 24) { - qt_rectfill(reinterpret_cast(d->data), pixel, + qt_rectfill(reinterpret_cast(d->data), pixel, 0, 0, d->width, d->height, d->bytes_per_line); return; } diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp index 62deb5ae..1330d96 100644 --- a/tests/auto/qimage/tst_qimage.cpp +++ b/tests/auto/qimage/tst_qimage.cpp @@ -103,9 +103,6 @@ private slots: void copy(); - void fill_data(); - void fill(); - void setPixel_data(); void setPixel(); @@ -1018,67 +1015,6 @@ void tst_QImage::copy() } } -void tst_QImage::fill_data() -{ - QTest::addColumn("format"); - QTest::addColumn("input"); - QTest::addColumn("expectedResult"); - - QTest::newRow("ARGB32") << int(QImage::Format_ARGB32) << 0x33557799u << 0x33557799u; - QTest::newRow("RGB888") << int(QImage::Format_RGB888) << 0x335577u << 0x335577u; - QTest::newRow("RGB16") << int(QImage::Format_RGB16) << 0x3355u << 0x3355u; - QTest::newRow("Indexed8") << int(QImage::Format_Indexed8) << 0x55u << 0x55u; - QTest::newRow("Mono") << int(QImage::Format_Mono) << 1u << 1u; - QTest::newRow("Mono_LSB") << int(QImage::Format_MonoLSB) << 0u << 0u; -} - -void tst_QImage::fill() -{ - QFETCH(int, format); - QFETCH(uint, input); - QFETCH(uint, expectedResult); - - QImage img(13, 15, (QImage::Format)format); - img.fill(input); - - const int bpp = img.depth(); - for (int y = 0; y < img.height(); ++y) { - uchar *line = img.scanLine(y); - for (int x = 0; x < img.width(); ++x) { - uint value; - switch (bpp) { - case 32: - value = *((uint*)line); - line += 4; - break; - case 24: - value = ((uint)line[0] << 16) | ((uint)line[1] << 8) | line[2]; - line += 3; - break; - case 16: - value = *((quint16*)line); - line += 2; - break; - case 8: - value = *line; - line++; - break; - case 1: - if (format == QImage::Format_Mono) - value = (*line >> (7- (x & 7))) & 1; - else if (format == QImage::Format_MonoLSB) - value = (*line >> (x & 7)) & 1; - - if (x && !(x & 7)) - ++line; - break; - } - - QCOMPARE(value, expectedResult); - } - } -} - void tst_QImage::setPixel_data() { QTest::addColumn("format"); diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 7679545..2cbb9b2 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -3642,7 +3642,7 @@ void tst_QPainter::drawImage_task258776() painter.end(); QImage expected(33, 33, QImage::Format_RGB32); - expected.fill(0x0000ff); + expected.fill(0xff0000); painter.begin(&expected); painter.drawImage(QRectF(0, 0, 32, 32), src); -- cgit v0.12 From 4778af08ca848c82526305c66dc23bb6b732b944 Mon Sep 17 00:00:00 2001 From: Hurewitz Kevin Date: Mon, 2 Aug 2010 15:00:00 +0200 Subject: QDesktopServices crashes when accessing the NULL X11 variable It appears that QDesktopServices for X11 assumes that it will be used with a GUI application and may access the X11 variable. The X11 variable will be NULL if it has not been initialized by the QApplication initialization. Merge-request: 2442 Reviewed-by: Olivier Goffart --- src/gui/util/qdesktopservices_x11.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/gui/util/qdesktopservices_x11.cpp b/src/gui/util/qdesktopservices_x11.cpp index fe7f9a6..75e7209 100644 --- a/src/gui/util/qdesktopservices_x11.cpp +++ b/src/gui/util/qdesktopservices_x11.cpp @@ -71,10 +71,12 @@ static bool openDocument(const QUrl &url) if (launch(url, QLatin1String("xdg-open"))) return true; - if (X11->desktopEnvironment == DE_GNOME && launch(url, QLatin1String("gnome-open"))) { + // Use the X11->desktopEnvironment value if X11 is non-NULL, + // otherwise just attempt to launch command regardless of the desktop environment + if ((!X11 || (X11 && X11->desktopEnvironment == DE_GNOME)) && launch(url, QLatin1String("gnome-open"))) { return true; } else { - if (X11->desktopEnvironment == DE_KDE && launch(url, QLatin1String("kfmclient exec"))) + if ((!X11 || (X11 && X11->desktopEnvironment == DE_KDE)) && launch(url, QLatin1String("kfmclient exec"))) return true; } @@ -104,10 +106,12 @@ static bool launchWebBrowser(const QUrl &url) if (launch(url, QString::fromLocal8Bit(getenv("BROWSER")))) return true; - if (X11->desktopEnvironment == DE_GNOME && launch(url, QLatin1String("gnome-open"))) { + // Use the X11->desktopEnvironment value if X11 is non-NULL, + // otherwise just attempt to launch command regardless of the desktop environment + if ((!X11 || (X11 && X11->desktopEnvironment == DE_GNOME)) && launch(url, QLatin1String("gnome-open"))) { return true; } else { - if (X11->desktopEnvironment == DE_KDE && launch(url, QLatin1String("kfmclient openURL"))) + if ((!X11 || (X11 && X11->desktopEnvironment == DE_KDE)) && launch(url, QLatin1String("kfmclient openURL"))) return true; } -- cgit v0.12