Repository: 4ian/GDevelop
File: newIDE/app/src/EditorFunctions/index.js (JavaScript)

Code before:
        );
        const deleteThisGroup = SafeExtractor.extractBooleanProperty(
          changed_group,
          'delete_this_group'
        );
        const objects = SafeExtractor.extractArrayProperty(
          changed_group,
          'objects'
        );
        if (groupName === null) {
          warnings.push(
            `Missing "group_name" in an item of \`changed_groups\`. It was ignored and not changed. Make sure you follow the exact format for changing group properties.`
          );
          return;
        }

        let foundGroup: gdObjectGroup;
        if (!groups.has(groupName)) {
          // Create the group if it does not exist yet.
          foundGroup = groups.insertNew(groupName, groups.count());
        } else {
          foundGroup = groups.get(groupName);
        }

        if (deleteThisGroup) {
          foundGroup.delete();
          changes.push(
            `Deleted group "${groupName}" from scene "${scene_name}".`
          );
        } else {
          if (newGroupName) {
            foundGroup.setName(newGroupName);
            changes.push(
              `Renamed group "${groupName}" to "${newGroupName}" in scene "${scene_name}".`
            );
          }
          if (objects) {
            const newObjectNames = objects
              .map(object =>
                SafeExtractor.extractStringProperty(object, 'object_name')
              )
              .filter(Boolean);
            // Remove objects that are not in the list, and add new objects.
            const currentObjectNames = foundGroup
              .getAllObjectsNames()
              .toJSArray();
            currentObjectNames.forEach(objectName => {
              if (!newObjectNames.includes(objectName)) {
                foundGroup.removeObject(objectName);
              }
            });

Review comment (bug):
This will probably crash the app/mess up the memory because you release an object that is still owned by the list of groups. You need to call `remove` on the ObjectGroupsContainer

Code after:
            }

            changes.push(
              `Modified "${propertyName}" property of the "${effectName}" effect to "${newValue}".`
            );
          });
        }

        if (newlyCreatedEffect) {
          const effectMetadata = gd.MetadataProvider.getEffectMetadata(
            project.getCurrentPlatform(),
            newlyCreatedEffect.getEffectType()
          );
          if (gd.MetadataProvider.isBadEffectMetadata(effectMetadata)) {
            // Should not happen.
          } else {
            changes.push(
              `Created new "${newlyCreatedEffect.getName()}" effect on layer "${layerName}" at position ${new_effect_position ||
                0}. It properties are: ${serializeEffectProperties(
                newlyCreatedEffect,
                effectMetadata
              )
                // This stringify might not give the prettiest output, this could be improved.
                .map(serializedProperty => JSON.stringify(serializedProperty))
                .join(', ')}.`
            );
          }
        }
      });
    }

    if (changed_groups) {
      const groups = scene.getObjects().getObjectGroups();
      changed_groups.forEach(changed_group => {
        const groupName = SafeExtractor.extractStringProperty(
          changed_group,
          'group_name'
        );
        const newGroupName = SafeExtractor.extractStringProperty(
          changed_group,
          'new_group_name'
        );
        const deleteThisGroup = SafeExtractor.extractBooleanProperty(
          changed_group,
          'delete_this_group'
        );
        const objects = SafeExtractor.extractArrayProperty(
          changed_group,
          'objects'
        );
        if (groupName === null) {