浏览代码

Utils: simplify comment skipping regexp

We have low-effort support for skipping comments in JSON (since neither
JSON nor Qt's JSON parser has support for comments). Unfortunately, it
was dropping lines that merely contained "//" within strings.

Simplify the regexp, so that only lines are skipped that consist of
whitespace between line start and comment begin. That's all we need.

This fixes some cases of storage.json loading failures.
Vincent Lang 9 年之前
父节点
当前提交
f5cda9ea65
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/utils/Utils.cpp

+ 1 - 1
src/utils/Utils.cpp

@@ -32,7 +32,7 @@ QJsonDocument Utils::OpenJsonDocument(const QString& path, QJsonParseError* err)
 {
   QFile fp(path);
   QByteArray fdata;
-  QRegExp commentMatch("^\\s*(\\S+\\s*=([^\\//]|\\//?)*)?(//.*)?$");
+  QRegExp commentMatch("^\\s*//");
 
   if (fp.open(QFile::ReadOnly))
   {