Fix DM -r
authormtklein <mtklein@chromium.org>
Tue, 7 Apr 2015 15:48:38 +0000 (08:48 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 7 Apr 2015 15:48:39 +0000 (08:48 -0700)
source_options isn't always present.

BUG=skia:

Review URL: https://codereview.chromium.org/1067863002

dm/DMJsonWriter.cpp

index 4fe6924..04ae2ce 100644 (file)
@@ -110,12 +110,15 @@ bool JsonWriter::ReadJson(const char* path, void(*callback)(BitmapResult)) {
     BitmapResult br;
     for (unsigned i = 0; i < results.size(); i++) {
         const Json::Value& r = results[i];
-        br.name          = r["key"]["name"].asCString();
-        br.config        = r["key"]["config"].asCString();
-        br.sourceType    = r["key"]["source_type"].asCString();
-        br.sourceOptions = r["key"]["source_options"].asCString();
-        br.ext           = r["options"]["ext"].asCString();
-        br.md5           = r["md5"].asCString();
+        br.name       = r["key"]["name"].asCString();
+        br.config     = r["key"]["config"].asCString();
+        br.sourceType = r["key"]["source_type"].asCString();
+        br.ext        = r["options"]["ext"].asCString();
+        br.md5        = r["md5"].asCString();
+
+        if (!r["key"]["source_options"].isNull()) {
+            br.sourceOptions = r["key"]["source_options"].asCString();
+        }
         callback(br);
     }
     return true;