Frequently asked question

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

Last Published: April 25, 2020

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);



Article ID:000004420

Software:
  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic