Bug with Drawables missing componentIDs?

I ran into a problem serialising Drawables.

Say you write out with:

Drawable* d = someCode(); if (d) { // ASSUME no images inside ValueTree vt = d->createValueTree(0); vt.writeToStream(st); }

and read back with,

ValueTree vt = ValueTree::readFromStream(st); Drawable* d = Drawable::createFromValueTree(vt, 0);

it doesn’t work. This is because the original Drawables did not contain valid component ids. Im not sure how these ids are meant to have been assigned. In my case i create the original Drawable from a SVG.

I can fix my problem by assigning arbitrary component IDs to the Drawable before any of this serialisation happens. Something like:

static void bindComponentID(Component* c, int& id) { // make up unique component ids c->setComponentID(String(++id)); int n = c->getNumChildComponents(); for (int i = 0; i < n; ++i) bindComponentID(c->getChildComponent(i), id); }

is ok to get around this locally.

– hugh.

Yeah, the components would all need a valid ID. I originally wrote it for use in a GUI designer where everything would automatically be given an ID.