Hi Jon,
I tried both: Choosing and loading the MDL from the MDL-Menu and by command-line "MDL Load <mdl-Name>", but the result is the same (that Microstation crashes).
It's a tricky problem to solve without sitting beside you to see your code and computer. Could it be a timing issue? What does your code do in MdlMain()?
I don't know what you mean with "Timing issue", but I will try to explain shortly what happens.
Here is the MdlMain-Code:
extern "C" DLLEXPORT int MdlMain (int argc, char *argv[])
{
RscFileHandle rfHandle;
SymbolSet *setP;
mdlResource_openFile (&rfHandle, NULL, FALSE);
setP = mdlCExpression_initializeSet (VISIBILITY_DIALOG_BOX, 0, FALSE);
mdlDialog_hookPublish (sizeof(uHooks)/sizeof(DialogHookInfo),uHooks);
mdlDialog_publishBasicVariable (setP, mdlCExpression_getType(TYPECODE_DOUBLE), "current_x", ¤t_x);
mdlDialog_publishBasicVariable (setP, mdlCExpression_getType(TYPECODE_DOUBLE), "current_y", ¤t_y);
mdlDialog_publishBasicVariable (setP, mdlCExpression_getType(TYPECODE_DOUBLE), "current_z", ¤t_z);
initSurface();
mdlDialog_open (NULL, DIALOGID_Coord);
return (SUCCESS);
}
The published variables "current_x/y/z" are used to Show the user the actual coordinates of the mouse.
I assume, that the problematical function is the "initSurface"-function which loads a complex structure from an ASCII-file into a global variable of this structure, which is used later to make some calculations wether the mouse (= current coordinates) are in or outside certain Areas. For this complex structure there is dynamic Memory-allocation necessary.
I have now two different Versions for the MDL, one that works with the C++ functions "new" and "delete" for the Memory-handling (which has this strange behaviour only to run in Debugging-mode) and another Version that uses the MDL-functions "dlmSystem_mdlCalloc" and "dlmSystem_mdlFree" instead of the C++-functions, because I thought, that this would solve the Problem.
The class for the complex structure and the connected member-function itself (including reading from file, calculation of inside/outside Areas ...) in C++-Version was tested outside MDL and Microstation-surrounding in Visual Studio 2005 and worked fine.
The second Version with the MDL-functions for Memory-handling crashes in Debugging-mode at the Point were there are type-casts done.
From the Basic-class "CBasicGeometry" there are derived classes e.g. "CTriangle" . Inside the structure there is a pointer to an Array of CBasicGeometry-elements:
...
int numbasic; //Number of CBasicGeometry-objects
CBasicGeometry **pBasic; //Pointer to vector of pointers to CBasicGeometry-objects
...
Inside the overloaded "Operator ="-function there is e.g. a type-cast necessary as follows:
...
case 300: //CTriangle-element
//pBasic[i]=new CTriangle; //C++
pBasic[i]=(CTriangle*) dlmSystem_mdlCalloc(1, sizeof(CTriangle)); //v8i-MDL
(static_cast<CTriangle*>(pBasic[i]))->operator = (static_cast<const CTriangle&>(*psurf.pBasic[i])); //here it crashes, although this worked fine in C++
break;
...
Is there a Special MDL-function for type-conversions necessary instead of the C++ cast-functions?
Many thanks for you help and best regards,
Ines Wieland