But, not only does mgGetLastError not work for mgDelete,
Unfortunately not all functions that can fail log a message for mgGetLastError. Some do, some don't.
Your code certainly looks correct. Can you tell us what version of the OpenFlight API you are using? I tried (a variant of) your code using 4.2 and see that mgGetExtRec + mgDelete is removing the tag-along extension record correctly.
FYI, IÃ¢â¬â¢m pushing the records onto a vector and deleting them after the walk to avoid any potential weirdness that might arise from deleting records during the walk. Is that necessary?
In this case it is not necessary but I don't think it can hurt. If your extension records are "tag-along" records, deleting them during the mgWalk won't hurt. Only when you delete stand-alone (node) extensions records, mgWalk can get wonky if you delete during the traversal (in the pre-function at least).
In conclusion, I don't see anything wrong with your code. Try deleting the tag-along extensions during the mgWalk and see if mgDelete gives you different results. I'd be interested if it did.
Let us know what you find out. And tell us what version of the API you are using. I can check for known bugs in past versions if I know which one you're using.
I am using version 4.2.
After I delete the extension tags, I call
if (!mgExportDb(db_rec, options.outputFullPath, MEFN_OPENFLIGHT, MEFV_1570, MG_NULL))
The purpose of my tool is to export current files to an older version to be compatible with our legacy software. I also tried deleting the tags during mgWalk and the results were the same when I opened up the files in Creator - the tags were still enabled.
Hmmm... there goes my theory that the older version might have had a bug...
Everything you are doing should work.
Are you doing this in a stand-alone app or Creator plugin?
In either case, are the extension DLLs that created this extension data being loaded (in your app or in Creator)? Perhaps without the DLLs in memory, the API can't quite understand what you are doing.
It's a stand alone app and the DLLs are loading successfully (at least, that's what the messages that are being printed out say).
How about we approach this question from a different angle. Under what conditions does mgDelete fail? If I know that, perhaps I can investigate the problem a little further on my end.
Sorry for lack of response recently.
Have you made any progress in the mean time?
After inspecting the code, there are many functions in the mgDelete chain that can derail the function from completing. The theme seems to be that the API can't figure out what the extension data is - which does happen when the DLL that "owns" these extensions cannot be loaded. I will try to rig up a stand-alone app here in the office today to try to replicate this. I have a test plugin (in Creator) that does NOT exhibit this problem. Perhaps there is something missing here when Creator is not involved.
You are not trying to modify a node that is "under" an external reference by any chance? i.e. you open the master file and walk to a node that is under an x-ref? When you do this, you cannot modify the node in the x-ref, only nodes that are directly in the master file.
I haven't made any progress. Would it be possible for me to send you a zip of my extension DLLs and my visual studio (2010) project with code?
If you are on maintenance, the best way to do this would be to pack up the files and open a support issue with Presagis Customer Support. That way it all gets tracked, etc and you are guaranteed that we will look at it.
If you are not on maintenance, you can zip up and attach to this thread and I'll have a look when I can but can make no promises.
In my tool, both DLLs containing my extension information are loading correctly. I call...
which returns successfully. As the nodes were walked, For each node type in my tree, I have code like this...
and deleteExtRecord looks like this...
where g_deleteRecords is a
Then, after mgWalk finishes, I run this...
But, not only does mgGetLastError not work for mgDelete, but every delete is failing for some reason. Any ideas? FYI, I'm pushing the records onto a vector and deleting them after the walk to avoid any potential weirdness that might arise from deleting records during the walk. Is that necessary?