Problem loading IVGProperties in CorelDRAW 2019

Hello,

We are developing a plugin for CorelDRAW and we use the IVGProperties struct retrieved from the document and from shapes to save some custom data.

The data kept in this struct is persistent, and saved when the document is saved as .cdr.

The problem is that CorelDRAW 2019 can't load all of the data from .cdr files.. It seems to stop loading when it tries to read a VT_ARRAY variant from the IVGProperties struct, so all data after (and including) the array are skipped. So if the IVGProperties contain, say, 20 entries when saving the file, and entry no. 10 happens to be an array variant, the same properties after loading will contain only 9 entries.

The problem only occurs while loading a file; everything works correctly as long as the document remains open, and it still works if it is saved in a previous .cdr version and then opened with an older version of CorelDRAW.

The code we use to set the array data to the IVGProperties is shown below. This snippet saves a std::vector of BYTEs (ar) to a shape's IVGProperties (pProperties) using bstrKey as the key of the specific entry:

    _variant_t variantData;
    variantData.vt = VT_ARRAY | VT_UI1;
    variantData.parray = ::SafeArrayCreateVector(VT_UI1, 0L, ar.size());

    if (variantData.parray && variantData.parray->pvData)
    {
        if (::SafeArrayLock(variantData.parray) == S_OK)
        {
            int nBytes = ar.size() * sizeof(BYTE);
            memcpy_s((BYTE *) variantData.parray->pvData, nBytes, (BYTE *)&*(ar.begin()), nBytes);

            ::SafeArrayUnlock(variantData.parray);
        }
    }

    pProperties->PutItem(bstrKey, 0L, variantData);

Has anyone else encountered such an issue? Any help or advice with this will be much appreciated.