@@ -52,6 +52,8 @@ inline rect_t parse_rect_from_json(const Json::Value& value) {
5252
5353static std::shared_ptr<container_t > parse_container_from_json (const Json::Value& o) {
5454#define i3IPC_TYPE_STR " PARSE CONTAINER FROM JSON"
55+ if (o.isNull ())
56+ return std::shared_ptr<container_t >();
5557 std::shared_ptr<container_t > container (new container_t ());
5658 IPC_JSON_ASSERT_TYPE_OBJECT (o, " o" )
5759
@@ -114,6 +116,8 @@ static std::shared_ptr<container_t> parse_container_from_json(const Json::Value
114116}
115117
116118static std::shared_ptr<workspace_t > parse_workspace_from_json (const Json::Value& value) {
119+ if (value.isNull ())
120+ return std::shared_ptr<workspace_t >();
117121 Json::Value num = value[" num" ];
118122 Json::Value name = value[" name" ];
119123 Json::Value visible = value[" visible" ];
@@ -122,7 +126,7 @@ static std::shared_ptr<workspace_t> parse_workspace_from_json(const Json::Value
122126 Json::Value rect = value[" rect" ];
123127 Json::Value output = value[" output" ];
124128
125- std::shared_ptr<workspace_t > p;
129+ std::shared_ptr<workspace_t > p ( new workspace_t ()) ;
126130 p->num = num.asInt ();
127131 p->name = name.asString ();
128132 p->visible = visible.asBool ();
@@ -134,12 +138,14 @@ static std::shared_ptr<workspace_t> parse_workspace_from_json(const Json::Value
134138}
135139
136140static std::shared_ptr<output_t > parse_output_from_json (const Json::Value& value) {
141+ if (value.isNull ())
142+ return std::shared_ptr<output_t >();
137143 Json::Value name = value[" name" ];
138144 Json::Value active = value[" active" ];
139145 Json::Value current_workspace = value[" current_workspace" ];
140146 Json::Value rect = value[" rect" ];
141147
142- std::shared_ptr<output_t > p;
148+ std::shared_ptr<output_t > p ( new output_t ()) ;
143149 p->name = name.asString ();
144150 p->active = active.asBool ();
145151 p->current_workspace = (current_workspace.isNull () ? std::string () : current_workspace.asString ());
0 commit comments