String resources data loss

I was using the String resources and Dialog resources, and after lots of Dialog creations and editing, at one point I noticed that all my String resource entries were gone. I think it's unsafe to mix all the resource types in the Resources tab. I hope there will be some kind of separation implemented for this in the future :slight_smile:

How did it happen? Were you editing the dialog resources manually?

I'm not sure when exactly it happened during the editing (I spent at least an hour playing with it all), but I'm pretty sure I didn't accidentally delete them. I did edit the resources both manually and with GUI editor. Perhaps I accidentally corrupted the XML tags and it got overwritten by the editor during GUI editing the Dialogs?

I've managed to find a 100% reliable but partial repro! Partial because the String Resource XML gets corrupted (and then causes runtime error on DOpus.Strings.Get) but no definite data loss occurs in this case (i.e., useful text is not deleted).

Attached is a minimum repro button which contains (unused) dummy dialog and a test String Resource:
String resource loss test.dcf (1.3 KB)

Repro steps:

  1. Run the button and observe the messagebox displaying the String Resource content. OK so far.
  2. Take a look at the button's XML String Resource section and take a note of the String Resource at the end:
<resource type="strings">
    <strings lang="english">
        <string id="Test" text="String resource retrieved successfully." />
    </strings>
</resource>
  1. Now open the dummy "dialog1" which is already there in the GUI Script Dialog Editor and change something, for example set the Title to "bla".
  2. Close the GUI Script Dialog Editor and take a look at the XML Resource, specifically at our String Resource, now it looks like this:
<resource lang="english" type="strings">
    <strings>
        <string id="Test">String resource retrieved successfully.</string>
    </strings>
</resource>
  1. If you try to run our button, it will fail with a runtime error.

I'll report if I manage to find 100% reliable repro for complete data loss (i.e., String Resource entirely gone).

Many thanks for tracking this down.

To solve the remaining mystery: The string loss will happen if you then edit the dialog a second time.

There's a mismatch between how Opus expects the data to be when it loads it, and how it saves it out again. Specifically, the lang="english" attribute is expected to be on the strings node when loading (and according to the manual), but if Opus edits the resources and re-saves them, it moves the lang attribute to the resource node.

In the next version, we will fix the saving code so it re-saves the XML correctly. We will also make the loading code cope with both situations, so you can salvage strings in resources that have been through the dialog editor once but not lost entirely by a second edit.

1 Like