diff --git a/src/ipc.cpp b/src/ipc.cpp index 76714a9..687f169 100644 --- a/src/ipc.cpp +++ b/src/ipc.cpp @@ -52,6 +52,8 @@ inline rect_t parse_rect_from_json(const Json::Value& value) { static std::shared_ptr parse_container_from_json(const Json::Value& o) { #define i3IPC_TYPE_STR "PARSE CONTAINER FROM JSON" + if (o.isNull()) + return std::shared_ptr(); std::shared_ptr container (new container_t()); IPC_JSON_ASSERT_TYPE_OBJECT(o, "o") @@ -114,6 +116,8 @@ static std::shared_ptr parse_container_from_json(const Json::Value } static std::shared_ptr parse_workspace_from_json(const Json::Value& value) { + if (value.isNull()) + return std::shared_ptr(); Json::Value num = value["num"]; Json::Value name = value["name"]; Json::Value visible = value["visible"]; @@ -122,7 +126,7 @@ static std::shared_ptr parse_workspace_from_json(const Json::Value Json::Value rect = value["rect"]; Json::Value output = value["output"]; - std::shared_ptr p; + std::shared_ptr p (new workspace_t()); p->num = num.asInt(); p->name = name.asString(); p->visible = visible.asBool(); @@ -134,12 +138,14 @@ static std::shared_ptr parse_workspace_from_json(const Json::Value } static std::shared_ptr parse_output_from_json(const Json::Value& value) { + if (value.isNull()) + return std::shared_ptr(); Json::Value name = value["name"]; Json::Value active = value["active"]; Json::Value current_workspace = value["current_workspace"]; Json::Value rect = value["rect"]; - std::shared_ptr p; + std::shared_ptr p (new output_t()); p->name = name.asString(); p->active = active.asBool(); p->current_workspace = (current_workspace.isNull() ? std::string() : current_workspace.asString());