English

FAQ: The MFC samples with MapObjects show memory leaks. How do I fix this?

Question

The MFC samples with MapObjects show memory leaks. How do I fix this?

Answer

An incorrect method is currently used to create fonts in several of the MFC samples in MapObjects 2. These errors are noticeable specifically in the following files:

\CGuide\Step 10 - Printing and Preview\EasyMapView.cpp

\CGuide\Step 9 - Event Tracking\EasyMapView.cpp

\Common\MapHelper.cpp

Your code should resemble the following snippet:

Code:

CMoFont fnt;

// similar to CreateDispatch
fnt.InitializeFont();

fnt.SetName(TEXT("Wingdings"));

CMoSymbol sym(tLayer.GetSymbol(0));
sym.SetColor(moRed);
sym.SetStyle(moTrueTypeMarker);
sym.SetFont(fnt);
sym.SetSize(12);
sym.SetCharacterIndex(221);

fnt.ReleaseFont();


In sum, the following line of code..

Code:

sym.SetFont(fnt.GetFontDispatch());


should be replaced with ..
Code:

sym.SetFont(fnt);



Related Information