From 5e4dd1ccc3277d871153ac3155b1d1443920f9b8 Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Thu, 25 Jun 2009 19:49:40 +0200 Subject: [PATCH 1/1] Remove C-style comment lines from stylesheets We also now remove all sections we parse and handle from the stylesheet prior to handing it over to QApplication, so we can use incompatible extensions. --- src/uisupport/qssparser.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/uisupport/qssparser.cpp b/src/uisupport/qssparser.cpp index 91ecac5a..f46147b3 100644 --- a/src/uisupport/qssparser.cpp +++ b/src/uisupport/qssparser.cpp @@ -55,13 +55,17 @@ void QssParser::processStyleSheet(QString &ss) { if(ss.isEmpty()) return; - // Now we have the stylesheet itself in ss, start parsing + // Remove C-style comments /* */ or // + QRegExp commentRx("(//.*(\\n|$)|/\\*.*\\*/)"); + commentRx.setMinimal(true); + ss.remove(commentRx); + // Palette definitions first, so we can apply roles later on QRegExp paletterx("(Palette[^{]*)\\{([^}]+)\\}"); int pos = 0; while((pos = paletterx.indexIn(ss, pos)) >= 0) { parsePaletteData(paletterx.cap(1).trimmed(), paletterx.cap(2).trimmed()); - pos += paletterx.matchedLength(); + ss.remove(pos, paletterx.matchedLength()); } // Now we can parse the rest of our custom blocks @@ -75,9 +79,8 @@ void QssParser::processStyleSheet(QString &ss) { //else // TODO: add moar here - pos += blockrx.matchedLength(); + ss.remove(pos, blockrx.matchedLength()); } - } void QssParser::parseChatLineData(const QString &decl, const QString &contents) { -- 2.20.1