Pārlūkot izejas kodu

fix handling of QPair<QString, QString> in the reflection subsystem

The earlier code used comma as a separator and backslash for escaping,
which was neither tested or complete. Revamp it to use newline as the
separator, which should not need escaping as it is unlikely to be
present in the passed values. See #1944
Ashish Kulkarni 10 gadi atpakaļ
vecāks
revīzija
eae59b40df
1 mainītis faili ar 6 papildinājumiem un 7 dzēšanām
  1. 6 7
      src/lib/reflect.hh

+ 6 - 7
src/lib/reflect.hh

@@ -110,16 +110,15 @@ struct DLL_LOCAL ReflectImpl< QPair<QString, QString> >: public ReflectSimple {
 	ReflectImpl(QPair<QString, QString> & _): p(_) {};
 	ReflectImpl(QPair<QString, QString> & _): p(_) {};
 
 
 	QString get() {
 	QString get() {
-		return p.first.replace("\\", "\\\\").replace(",", "\\,") + "," +
-			p.second.replace("\\", "\\\\").replace(",", "\\,");
+		return p.first + "\n" + p.second;
 	}
 	}
 
 
 	void set(const QString & value, bool * ok) {
 	void set(const QString & value, bool * ok) {
-		QStringList l = value.split(",");
-		if (l.size() != 0) {*ok=false; return;}
-		*ok=true;
-		p.first = l[0].replace("\\,",",").replace("\\\\","\\");
-		p.second = l[1].replace("\\,",",").replace("\\\\","\\");
+		QStringList l = value.split("\n");
+		if (l.size() != 2) {*ok=false; return;}
+		*ok      = true;
+		p.first  = l[0];
+		p.second = l[1];
 	}
 	}
 };
 };