hi, I have created a function to create a new layer and want to add the selected artwork to this new layer but I am facing a problem. here is the snippet,
void create_layer(void);
static const char* layer_title = "XYZ"
void Class_name::create_layer()
{
ASErr error = kNoErr;
AILayerHandle layerHandle;
ASErr error = sAILayer->InsertLayer(NULL, kPlaceAboveAll, &layerHandle);
if (error) return;
ai::UnicodeString layerTitle(layer_title);
sAILayer->SetLayerTitle(layerHandle, layerTitle);
}
when I call this function from AIMenumessag, it creates the layer, but when I call this function from any other place, a "Reading access violation " error occurs. can anybody help me to fix this problem and how to add the selected artwork to the newly created layer?