+ /* Plugin state can include external files which are named after the ID.
+ *
+ * If regenerate_xml_or_string_ids() is set, the ID will already have
+ * been changed, so we need to use the old ID from the XML to load the
+ * state and then update the ID.
+ *
+ * When copying a plugin-state, route_ui takes care of of updating the ID,
+ * but we need to call set_insert_id() to clear the cached plugin-state
+ * and force a change.
+ */
+ if (!regenerate_xml_or_string_ids ()) {
+ (*i)->set_insert_id (new_id);
+ } else {
+ (*i)->set_insert_id (old_id);
+ }
+