From cc01e0b1e112aac3a0e515f7accbd05ca5a55ecd Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Mon, 8 Aug 2011 15:00:29 +1000 Subject: [PATCH] Allow borderimage .sci source to be a quoted filename Previously, attempting to set the source property of a border image via a .sci file to a quoted filename would fail. This commit adds support for quoted source filenames. Task-number: QTBUG-20709 Change-Id: Ida54ef42bc07081457fd945bb279f3cc82c26e10 Reviewed-on: http://codereview.qt.nokia.com/2724 Reviewed-by: Qt Sanity Bot Reviewed-by: Damian Jansen Reviewed-by: Michael Brasser --- src/declarative/items/qsgscalegrid.cpp | 2 ++ src/qtquick1/graphicsitems/qdeclarativescalegrid.cpp | 2 ++ tests/auto/declarative/qsgborderimage/data/colors-round-quotes.sci | 7 +++++++ tests/auto/declarative/qsgborderimage/tst_qsgborderimage.cpp | 2 ++ .../qtquick1/qdeclarativeborderimage/data/colors-round-quotes.sci | 7 +++++++ .../qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp | 2 ++ 6 files changed, 22 insertions(+) create mode 100644 tests/auto/declarative/qsgborderimage/data/colors-round-quotes.sci create mode 100644 tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-quotes.sci diff --git a/src/declarative/items/qsgscalegrid.cpp b/src/declarative/items/qsgscalegrid.cpp index a9eb080..e1b76c4 100644 --- a/src/declarative/items/qsgscalegrid.cpp +++ b/src/declarative/items/qsgscalegrid.cpp @@ -164,6 +164,8 @@ QSGGridScaledImage::QSGGridScaledImage(QIODevice *data) _l = l; _r = r; _t = t; _b = b; _pix = imgFile; + if (_pix.startsWith(QLatin1Char('"')) && _pix.endsWith(QLatin1Char('"'))) + _pix = _pix.mid(1, _pix.size() - 2); // remove leading/trailing quotes. } QSGBorderImage::TileMode QSGGridScaledImage::stringToRule(const QString &s) diff --git a/src/qtquick1/graphicsitems/qdeclarativescalegrid.cpp b/src/qtquick1/graphicsitems/qdeclarativescalegrid.cpp index 83a94ec..bcdf92c 100644 --- a/src/qtquick1/graphicsitems/qdeclarativescalegrid.cpp +++ b/src/qtquick1/graphicsitems/qdeclarativescalegrid.cpp @@ -167,6 +167,8 @@ QDeclarative1GridScaledImage::QDeclarative1GridScaledImage(QIODevice *data) _l = l; _r = r; _t = t; _b = b; _pix = imgFile; + if (_pix.startsWith(QLatin1Char('"')) && _pix.endsWith(QLatin1Char('"'))) + _pix = _pix.mid(1, _pix.size() - 2); // remove leading/trailing quotes. } QDeclarative1BorderImage::TileMode QDeclarative1GridScaledImage::stringToRule(const QString &s) diff --git a/tests/auto/declarative/qsgborderimage/data/colors-round-quotes.sci b/tests/auto/declarative/qsgborderimage/data/colors-round-quotes.sci new file mode 100644 index 0000000..294f3cf --- /dev/null +++ b/tests/auto/declarative/qsgborderimage/data/colors-round-quotes.sci @@ -0,0 +1,7 @@ +border.left:10 +border.top:20 +border.right:30 +border.bottom:40 +horizontalTileRule:Round +verticalTileRule:Repeat +source:"colors.png" diff --git a/tests/auto/declarative/qsgborderimage/tst_qsgborderimage.cpp b/tests/auto/declarative/qsgborderimage/tst_qsgborderimage.cpp index 75cc6a0..d1fe084 100644 --- a/tests/auto/declarative/qsgborderimage/tst_qsgborderimage.cpp +++ b/tests/auto/declarative/qsgborderimage/tst_qsgborderimage.cpp @@ -324,8 +324,10 @@ void tst_qsgborderimage::sciSource_data() QTest::addColumn("valid"); QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors-round.sci").toString() << true; + QTest::newRow("local quoted filename") << QUrl::fromLocalFile(SRCDIR "/data/colors-round-quotes.sci").toString() << true; QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.sci").toString() << false; QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true; + QTest::newRow("remote filename quoted") << SERVER_ADDR "/colors-round-quotes.sci" << true; QTest::newRow("remote image") << SERVER_ADDR "/colors-round-remote.sci" << true; QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false; } diff --git a/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-quotes.sci b/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-quotes.sci new file mode 100644 index 0000000..294f3cf --- /dev/null +++ b/tests/auto/qtquick1/qdeclarativeborderimage/data/colors-round-quotes.sci @@ -0,0 +1,7 @@ +border.left:10 +border.top:20 +border.right:30 +border.bottom:40 +horizontalTileRule:Round +verticalTileRule:Repeat +source:"colors.png" diff --git a/tests/auto/qtquick1/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp b/tests/auto/qtquick1/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp index d563146..9ef2aae 100644 --- a/tests/auto/qtquick1/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp +++ b/tests/auto/qtquick1/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp @@ -333,8 +333,10 @@ void tst_qdeclarativeborderimage::sciSource_data() QTest::addColumn("valid"); QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors-round.sci").toString() << true; + QTest::newRow("local quoted filename") << QUrl::fromLocalFile(SRCDIR "/data/colors-round-quotes.sci").toString() << true; QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.sci").toString() << false; QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true; + QTest::newRow("remote filename quoted") << SERVER_ADDR "/colors-round-quotes.sci" << true; QTest::newRow("remote image") << SERVER_ADDR "/colors-round-remote.sci" << true; QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << false; } -- 2.7.4