These two lines of code build OK but cause an Internal Error: Access Violation at runtime …
PickListLibrary lib; PickListLibrary::GetPickListLibFromDgn (ISessionMgr::GetActiveDgnFile (), lib);
struct PickListLibrary : public RefCountedBase tells us that PickListLibrary is a reference-counted class. I would expect there to be a static public Create() method to get a smart pointer (PickListLibraryPtr). However, there's no MakeAbstract() or other means in the class declaration to make PickListLibrary abstract.
struct PickListLibrary : public RefCountedBase
PickListLibrary
static public Create()
PickListLibraryPtr)
MakeAbstract()
Non-intuitively, the following does work...
PickListLibraryP lib { PickListLibrary::CreatePickListLibrary () }; PickListLibrary::GetPickListLibFromDgn (ISessionMgr::GetActiveDgnFile (), *lib); // Use lib->Xxx() // delete lib?
But what do I have: a normal pointer or a smart pointer? That is, should I delete lib or not?
delete lib
Hi Jon,
Thank you for reporting the issue. Could you please send me an example for the first code? I have used it in many places while I haven't met the runtime error which you got.
Regards,
Colin
Colin Wang said: Could you please send me an example for the first code?
Here's a modified version of your PickList NativeExample project. There's an additional command INSTANCE that tests static and dynamic creation of a PickListLibrary. Dynamic allocation works; static allocation fails at runtime.
NativeExampleLASolutions.zip
Regards, Jon Summers LA Solutions
Thank you, Jon. We are working on it.
The change will be released in Update 13.
There won’t be code like: PickListLibrary lib; //This line will cause compiling error
or
PickListLibraryP lib { PickListLibrary::CreatePickListLibrary () };
It must be: PickListLibraryPtr pickListLib = PickListLibrary::CreatePickListLibrary();
Thanks & Regards,
Answer Verified By: Jon Summers