From 6cf224de00ebf0681cd32a34866bdc3d16e0f45d Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 31 Aug 2009 07:04:12 +0200 Subject: Invalidate cached QVectorPath when QPainterPath changes Reviewed-by: Samuel --- src/gui/painting/qpainterpath.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index ff133b6..cb9ea80 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -3215,6 +3215,8 @@ void QPainterPath::setDirty(bool dirty) { d_func()->dirtyBounds = dirty; d_func()->dirtyControlBounds = dirty; + delete d_func()->pathConverter; + d_func()->pathConverter = 0; } void QPainterPath::computeBoundingRect() const -- cgit v0.12 From b0295e82d08605a5a40803895544e57eeb6c8dc3 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 31 Aug 2009 07:19:23 +0200 Subject: Don't crash when convert Indexed8 without colortable to QPixmap This implicitly adds "grayscale" support for indexed 8, but only for the conversion. The alternative would be leave the pixels uninitialized which would be less nice... Reviewed-by: Samuel --- src/gui/image/qimage.cpp | 6 ++++++ tests/auto/qpixmap/tst_qpixmap.cpp | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index d48d427..0358ba0 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -2904,6 +2904,12 @@ static void convert_Indexed8_to_X32(QImageData *dest, const QImageData *src, Qt: Q_ASSERT(src->height == dest->height); QVector colorTable = fix_color_table(src->colortable, dest->format); + if (colorTable.size() == 0) { + colorTable.resize(256); + for (int i=0; i<256; ++i) + colorTable[i] = qRgb(i, i, i); + + } int w = src->width; const uchar *src_data = src->data; diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 8dd5f5f..9422327 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -83,6 +83,9 @@ private slots: void fromImage_data(); void fromImage(); + void fromUninitializedImage_data(); + void fromUninitializedImage(); + void convertFromImage_data(); void convertFromImage(); @@ -266,6 +269,32 @@ void tst_QPixmap::fromImage() QCOMPARE(result, image); } + +void tst_QPixmap::fromUninitializedImage_data() +{ + QTest::addColumn("format"); + + QTest::newRow("Format_Mono") << QImage::Format_Mono; + QTest::newRow("Format_MonoLSB") << QImage::Format_MonoLSB; + QTest::newRow("Format_Indexed8") << QImage::Format_Indexed8; + QTest::newRow("Format_RGB32") << QImage::Format_RGB32; + QTest::newRow("Format_ARGB32") << QImage::Format_ARGB32; + QTest::newRow("Format_ARGB32_Premultiplied") << QImage::Format_ARGB32_Premultiplied; + QTest::newRow("Format_RGB16") << QImage::Format_RGB16; +} + +void tst_QPixmap::fromUninitializedImage() +{ + QFETCH(QImage::Format, format); + + QImage image(100, 100, format); + QPixmap pix = QPixmap::fromImage(image); + + // it simply shouldn't crash... + QVERIFY(true); + +} + void tst_QPixmap::convertFromImage_data() { QTest::addColumn("img1"); -- cgit v0.12 From 9d24605add8daabfa55e1085e71ed47b14ed7d83 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 31 Aug 2009 16:46:59 +0200 Subject: QNAM HTTP Code: Some tests where failing ietf.org changed their server to use gzip, therefore our check for the content-length reply header was bogus. Rev-By: Peter Hartmann --- tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp | 8 ++++++-- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index c54bf3c..639464e 100644 --- a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -177,7 +177,9 @@ void tst_QHttpNetworkConnection::head() QCOMPARE(reply->statusCode(), statusCode); QCOMPARE(reply->reasonPhrase(), statusString); - QCOMPARE(reply->contentLength(), qint64(contentLength)); + // only check it if it is set + if (reply->contentLength() != -1) + QCOMPARE(reply->contentLength(), qint64(contentLength)); QVERIFY(reply->isFinished()); @@ -237,7 +239,9 @@ void tst_QHttpNetworkConnection::get() QCOMPARE(reply->statusCode(), statusCode); QCOMPARE(reply->reasonPhrase(), statusString); - QCOMPARE(reply->contentLength(), qint64(contentLength)); + // only check it if it is set + if (reply->contentLength() != -1) + QCOMPARE(reply->contentLength(), qint64(contentLength)); stopWatch.start(); QByteArray ba; diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 3216a6a..48a48f4 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -1081,8 +1081,10 @@ void tst_QNetworkReply::getFromHttp() QCOMPARE(reply->url(), request.url()); QCOMPARE(reply->error(), QNetworkReply::NoError); QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), 200); - - QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), reference.size()); + QCOMPARE(reply->size(), reference.size()); + // only compare when the header is set. + if (reply->header(QNetworkRequest::ContentLengthHeader).isValid()) + QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), reference.size()); QCOMPARE(reply->readAll(), reference.readAll()); } -- cgit v0.12 From 7c06af4528d7aa7186b12546c261d5d2a0a3641d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 27 Aug 2009 18:56:47 +0200 Subject: Reset QTemporaryFile's state after failed open() on Windows This fixes a regression introduced in 4.5.2 where QTemporaryFile would no longer attempt to generate a random name after a failed open. Under certain situations, this led to a non-random file being left behind in QDir::tempPath when using the fallback implementation of QFile::copy. Avoid calling QFSFileEngine::setFileName() on a template, so as not to process it as file name. By consistently not calling setFileTemplate in the constructor, we also delay allocation of the fileEngine. Changes made to that function also keep it from unnecessarily allocating the fileEngine. Task-number: 260165 Reviewed-by: Thiago Macieira --- src/corelib/io/qtemporaryfile.cpp | 38 ++++++++--- tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp | 82 ++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 8 deletions(-) diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index bd039c8..47fa257 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -292,14 +292,20 @@ class QTemporaryFileEngine : public QFSFileEngine Q_DECLARE_PRIVATE(QFSFileEngine) public: QTemporaryFileEngine(const QString &file, bool fileIsTemplate = true) - : QFSFileEngine(file), filePathIsTemplate(fileIsTemplate) + : QFSFileEngine(), filePathIsTemplate(fileIsTemplate) { + Q_D(QFSFileEngine); + d->filePath = file; + + if (!filePathIsTemplate) + QFSFileEngine::setFileName(file); } ~QTemporaryFileEngine(); bool isReallyOpen(); void setFileName(const QString &file); + void setFileTemplate(const QString &fileTemplate); bool open(QIODevice::OpenMode flags); bool remove(); @@ -336,6 +342,13 @@ void QTemporaryFileEngine::setFileName(const QString &file) QFSFileEngine::setFileName(file); } +void QTemporaryFileEngine::setFileTemplate(const QString &fileTemplate) +{ + Q_D(QFSFileEngine); + if (filePathIsTemplate) + d->filePath = fileTemplate; +} + bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode) { Q_D(QFSFileEngine); @@ -382,12 +395,19 @@ bool QTemporaryFileEngine::open(QIODevice::OpenMode openMode) return false; } + QString template_ = d->filePath; d->filePath = QString::fromLocal8Bit(filename); - filePathIsTemplate = false; d->nativeInitFileName(); - d->closeFileHandle = true; delete [] filename; - return QFSFileEngine::open(openMode); + + if (QFSFileEngine::open(openMode)) { + filePathIsTemplate = false; + return true; + } + + d->filePath = template_; + d->nativeFilePath.clear(); + return false; #endif } @@ -533,7 +553,8 @@ QTemporaryFile::QTemporaryFile() QTemporaryFile::QTemporaryFile(const QString &templateName) : QFile(*new QTemporaryFilePrivate, 0) { - setFileTemplate(templateName); + Q_D(QTemporaryFile); + d->templateName = templateName; } /*! @@ -567,7 +588,8 @@ QTemporaryFile::QTemporaryFile(QObject *parent) QTemporaryFile::QTemporaryFile(const QString &templateName, QObject *parent) : QFile(*new QTemporaryFilePrivate, parent) { - setFileTemplate(templateName); + Q_D(QTemporaryFile); + d->templateName = templateName; } #endif @@ -671,10 +693,10 @@ QString QTemporaryFile::fileTemplate() const */ void QTemporaryFile::setFileTemplate(const QString &name) { - Q_ASSERT(!isOpen()); Q_D(QTemporaryFile); - fileEngine()->setFileName(name); d->templateName = name; + if (d->fileEngine) + static_cast(d->fileEngine)->setFileTemplate(name); } /*! diff --git a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp index 2541b48..73486e7 100644 --- a/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/qtemporaryfile/tst_qtemporaryfile.cpp @@ -89,6 +89,8 @@ private slots: void renameFdLeak(); void reOpenThroughQFile(); void keepOpenMode(); + void resetTemplateAfterError(); + void setTemplateAfterOpen(); public: }; @@ -472,5 +474,85 @@ void tst_QTemporaryFile::keepOpenMode() } } +void tst_QTemporaryFile::resetTemplateAfterError() +{ + // calling setFileTemplate on a failed open + + QString tempPath = QDir::tempPath(); + + QString const fileTemplate("destination/qt_temp_file_test.XXXXXX"); + QString const fileTemplate2(tempPath + "/qt_temp_file_test.XXXXXX"); + + QVERIFY2( QDir(tempPath).exists() || QDir().mkpath(tempPath), "Test precondition" ); + QVERIFY2( !QFile::exists("destination"), "Test precondition" ); + QVERIFY2( !QFile::exists(fileTemplate2) || QFile::remove(fileTemplate2), "Test precondition" ); + + QFile file(fileTemplate2); + QByteArray fileContent("This file is intentionally NOT left empty."); + + QVERIFY( file.open(QIODevice::ReadWrite | QIODevice::Truncate) ); + QCOMPARE( file.write(fileContent), (qint64)fileContent.size() ); + QVERIFY( file.flush() ); + + QString fileName; + { + QTemporaryFile temp; + + QVERIFY( temp.fileName().isEmpty() ); + QVERIFY( !temp.fileTemplate().isEmpty() ); + + temp.setFileTemplate( fileTemplate ); + + QVERIFY( temp.fileName().isEmpty() ); + QCOMPARE( temp.fileTemplate(), fileTemplate ); + + QVERIFY( !temp.open() ); + + QVERIFY( temp.fileName().isEmpty() ); + QCOMPARE( temp.fileTemplate(), fileTemplate ); + + temp.setFileTemplate( fileTemplate2 ); + QVERIFY( temp.open() ); + + fileName = temp.fileName(); + QVERIFY( QFile::exists(fileName) ); + QVERIFY( !fileName.isEmpty() ); + QVERIFY2( fileName != fileTemplate2, + ("Generated name shouldn't be same as template: " + fileTemplate2).toLocal8Bit().constData() ); + } + + QVERIFY( !QFile::exists(fileName) ); + + file.seek(0); + QCOMPARE( QString(file.readAll()), QString(fileContent) ); + QVERIFY( file.remove() ); +} + +void tst_QTemporaryFile::setTemplateAfterOpen() +{ + QTemporaryFile temp; + + QVERIFY( temp.fileName().isEmpty() ); + QVERIFY( !temp.fileTemplate().isEmpty() ); + + QVERIFY( temp.open() ); + + QString const fileName = temp.fileName(); + QString const newTemplate("funny-path/funny-name-XXXXXX.tmp"); + + QVERIFY( !fileName.isEmpty() ); + QVERIFY( QFile::exists(fileName) ); + QVERIFY( !temp.fileTemplate().isEmpty() ); + QVERIFY( temp.fileTemplate() != newTemplate ); + + temp.close(); // QTemporaryFile::setFileTemplate will assert on isOpen() up to 4.5.2 + temp.setFileTemplate(newTemplate); + QCOMPARE( temp.fileTemplate(), newTemplate ); + + QVERIFY( temp.open() ); + QCOMPARE( temp.fileName(), fileName ); + QCOMPARE( temp.fileTemplate(), newTemplate ); +} + QTEST_MAIN(tst_QTemporaryFile) #include "tst_qtemporaryfile.moc" -- cgit v0.12 From 20cc50a21eb5841b3a3e8546877e805f5a4df528 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Mon, 31 Aug 2009 19:33:10 +0200 Subject: Fix #error line not to have a ' as it's not correct Merge-request: 753 Reviewed-by: Thiago Macieira --- src/3rdparty/webkit/WebCore/DerivedSources.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/webkit/WebCore/DerivedSources.cpp b/src/3rdparty/webkit/WebCore/DerivedSources.cpp index f698913..aaf8983 100644 --- a/src/3rdparty/webkit/WebCore/DerivedSources.cpp +++ b/src/3rdparty/webkit/WebCore/DerivedSources.cpp @@ -334,5 +334,5 @@ // want StaticConstructors.h to "pollute" all the source files we #include here // accidentally, so we'll throw an error whenever any file includes it. #ifdef StaticConstructors_h -#error Don't include any file in DerivedSources.cpp that includes StaticConstructors.h +#error Do not include any file in DerivedSources.cpp that includes StaticConstructors.h #endif -- cgit v0.12