Start a new topic

mgSetName g1 problem

Original Post by: jsnuffer Tue Jan 5 19:18:37 2010


If I call:


mgSetName( rec, "g1" );


the API throws an exception and sets mgGetLastError to "ID already exists: g1". However, there is no other ID called g1.


This also occurs with name="g2", but not with any other name I have encountered.


I'm renaming such names to e.g. "G1" at the moment, which works.


Is this a known issue? Is there a workaround?


Original Post by: SteveThompson Tue Jan 5 22:10:34 2010


Sorry this is not clear in the documentation.


You note this section in the user docs:

PREFIX=pref a string used with new node types to set the prefix used for auto-generated

node names. For example, the prefix for a fltGroup is g: new groups are

named g1, g2, and so forth.


Perhaps I can use this to overide the auto-generated names to something less likely to clash with my client’s pre-existing data.

This section only pertains to extension nodes you create. You cannot change the default prefixes used to create OpenFlight nodes in this way. i.e., you cannot change how the gX nodes are named.


You could add your own version of mgNewDb, call it, say, myNewDb which would do this:

mgrec* myNewDb (const char* name)

{

mgrec* db = mgNewDb (name);

mgrec* g1 = mgGetChild (db);

mgDelete (g1);

return db;

}

Then instead of calling mgNewDb in your code, call myNewDb and it will return an empty database as you want.

Original Post by: jsnuffer Tue Jan 5 21:22:40 2010


I'm using v4.0


I imagine you are correct and that these automatic groups underlie my problem.


These groups do not seem to be documented in the API reference manual, in fact the only place l

I can find a description of this anywhere in the documentation is under "recordDef" on p184 of the API User's Guide Vol 2:


PREFIX=pref a string used with new node types to set the prefix used for auto-generated

node names. For example, the prefix for a fltGroup is g: new groups are

named g1, g2, and so forth.


Perhaps I can use this to overide the auto-generated names to something less likely to clash with my client's pre-existing data.


Thanks for your help.

Original Post by: SteveThompson Tue Jan 5 20:39:34 2010


Are you sure there is no such "g1" in the database? Note that when you do mgNewDb() you do get two groups below the db as shown in the attached image. I have not heard of this problem before.


Also what version of the API are you using?

Login to post a comment