[Libreoffice-commits] core.git: desktop/source

Miklos Vajna vmiklos at collabora.co.uk
Wed Apr 29 11:42:36 PDT 2015


 desktop/source/lib/init.cxx |   37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

New commits:
commit d4a12421f2b0aafe97f8ab78017261969c36ae0e
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Apr 29 20:25:52 2015 +0200

    desktop: pJSON may be 0 in jsonToPropertyValues()
    
    Change-Id: I1ed9a4e1f1ecabf48ed3edb7cf6623261e2f4570

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 67e4750..44cf2b0 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -706,25 +706,28 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* pThis, int nType, int nChar
 
 static void jsonToPropertyValues(const char* pJSON, uno::Sequence<beans::PropertyValue>& rPropertyValues)
 {
-    boost::property_tree::ptree aTree;
-    std::stringstream aStream(pJSON);
-    boost::property_tree::read_json(aStream, aTree);
-
     std::vector<beans::PropertyValue> aArguments;
-    for (const std::pair<std::string, boost::property_tree::ptree>& rPair : aTree)
+    if (pJSON)
     {
-        const std::string& rType = rPair.second.get<std::string>("type");
-        const std::string& rValue = rPair.second.get<std::string>("value");
-
-        beans::PropertyValue aValue;
-        aValue.Name = OUString::fromUtf8(rPair.first.c_str());
-        if (rType == "string")
-            aValue.Value <<= OUString::fromUtf8(rValue.c_str());
-        else if (rType == "boolean")
-            aValue.Value <<= OString(rValue.c_str()).toBoolean();
-        else
-            SAL_WARN("desktop.lib", "jsonToPropertyValues: unhandled type '"<<rType<<"'");
-        aArguments.push_back(aValue);
+        boost::property_tree::ptree aTree;
+        std::stringstream aStream(pJSON);
+        boost::property_tree::read_json(aStream, aTree);
+
+        for (const std::pair<std::string, boost::property_tree::ptree>& rPair : aTree)
+        {
+            const std::string& rType = rPair.second.get<std::string>("type");
+            const std::string& rValue = rPair.second.get<std::string>("value");
+
+            beans::PropertyValue aValue;
+            aValue.Name = OUString::fromUtf8(rPair.first.c_str());
+            if (rType == "string")
+                aValue.Value <<= OUString::fromUtf8(rValue.c_str());
+            else if (rType == "boolean")
+                aValue.Value <<= OString(rValue.c_str()).toBoolean();
+            else
+                SAL_WARN("desktop.lib", "jsonToPropertyValues: unhandled type '"<<rType<<"'");
+            aArguments.push_back(aValue);
+        }
     }
     rPropertyValues = comphelper::containerToSequence(aArguments);
 }


More information about the Libreoffice-commits mailing list