QML: add a memory pool to the Json* classes.

The memory pool is not too efficient, but will keep objects from
leaking.

Change-Id: I68a55bc7a6ea56463652245abeea8954b693c1d7
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
This commit is contained in:
Erik Verbruggen
2013-07-10 11:50:46 +02:00
parent 7702ad52ce
commit 762099487c
3 changed files with 52 additions and 16 deletions

View File

@@ -250,6 +250,8 @@ QStringList QmlBundle::maybeReadTrie(Trie &trie, Utils::JsonObjectValue *config,
bool QmlBundle::readFrom(QString path, QStringList *errors)
{
Utils::JsonMemoryPool pool;
using namespace Utils;
QFile f(path);
if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
@@ -257,7 +259,7 @@ bool QmlBundle::readFrom(QString path, QStringList *errors)
(*errors) << QString::fromLatin1("Could not open file at %1 .").arg(path);
return false;
}
JsonObjectValue *config = JsonValue::create(QString::fromUtf8(f.readAll()))->toObject();
JsonObjectValue *config = JsonValue::create(QString::fromUtf8(f.readAll()), &pool)->toObject();
if (config == 0) {
if (errors)
(*errors) << QString::fromLatin1("Could not parse json object in file at %1 .").arg(path);