QCss: properly parse functions which contains additional spaces
When there were additional spaces between the function definition and the first parameter, the parser failed to parse it when it contained another function (e.g. 'qlineargradient(... rgb() ...)'). The reason for this was that ::until() needs the function at index-1 so it can correctly count the opening parenthesis. Fixes: QTBUG-61795 Change-Id: I992f556e7f8cd45550f83bc90aa8de2b4e905574 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>bb10
parent
473d9a5fc7
commit
bbe08d6b68
|
|
@ -2707,8 +2707,10 @@ bool Parser::parseFunction(QString *name, QString *args)
|
|||
{
|
||||
*name = lexem();
|
||||
name->chop(1);
|
||||
// until(RPAREN) needs FUNCTION token at index-1 to work properly
|
||||
int start = index;
|
||||
skipSpace();
|
||||
const int start = index;
|
||||
std::swap(start, index);
|
||||
if (!until(RPAREN)) return false;
|
||||
for (int i = start; i < index - 1; ++i)
|
||||
args->append(symbols.at(i).lexem());
|
||||
|
|
|
|||
|
|
@ -1509,6 +1509,12 @@ void tst_QCssParser::gradient_data()
|
|||
"spread: repeat, stop:0.2 rgb(1, 2, 3), stop:0.5 rgba(1, 2, 3, 4))" << "conical" << QPointF(4, 2) << QPointF()
|
||||
<< 2 << qreal(0.2) << QColor(1, 2, 3) << qreal(0.5) << QColor(1, 2, 3, 4);
|
||||
|
||||
// spaces before first function parameter lead to parser errors
|
||||
QTest::newRow("QTBUG-61795") <<
|
||||
"selection-background-color: qconicalgradient( cx: 4, cy : 2, angle: 23, "
|
||||
"spread: repeat, stop:0.2 rgb( 1, 2, 3), stop:0.5 rgba( 1, 2, 3, 4))" << "conical" << QPointF(4, 2) << QPointF()
|
||||
<< 2 << qreal(0.2) << QColor(1, 2, 3) << qreal(0.5) << QColor(1, 2, 3, 4);
|
||||
|
||||
/* won't pass: stop values are expected to be sorted
|
||||
QTest::newRow("unsorted-stop") <<
|
||||
"selection-background: lineargradient(x1:0, y1:0, x2:0, y2:1, "
|
||||
|
|
|
|||
Loading…
Reference in New Issue