Browse Source

instantiate non-mandatory children that already exist

Julius Pfrommer 7 years ago
parent
commit
6b4947ad33
1 changed files with 4 additions and 7 deletions
  1. 4 7
      src/server/ua_services_nodemanagement.c

+ 4 - 7
src/server/ua_services_nodemanagement.c

@@ -341,6 +341,10 @@ copyChildNode(UA_Server *server, UA_Session *session,
         return retval;
     }
 
+    /* Is the child mandatory? If not, skip */
+    if(!mandatoryChild(server, session, &rd->nodeId.nodeId))
+        return UA_STATUSCODE_GOOD;
+
     /* No existing child with that browsename. Create it. */
     if(rd->nodeClass == UA_NODECLASS_METHOD) {
         /* Add a reference to the method in the objecttype */
@@ -416,13 +420,6 @@ copyChildNodes(UA_Server *server, UA_Session *session,
     UA_StatusCode retval = UA_STATUSCODE_GOOD;
     for(size_t i = 0; i < br.referencesSize; ++i) {
         UA_ReferenceDescription *rd = &br.references[i];
-
-        /* Is the child mandatory? If not, skip */
-        if(!mandatoryChild(server, session, &rd->nodeId.nodeId))
-            continue;
-
-        /* TODO: If a child is optional, check whether optional children that
-         * were manually added fit the constraints. */
         retval |= copyChildNode(server, session, destinationNodeId, 
                                 rd, instantiationCallback);
     }