I have followed the Sax2 JumpStart example (http://msdn2.microsoft.com/en-us/library/ms994335.aspx), to implement a xml Parser in my project. The projects uses DirectX to create a device and use it, and a console to show a log (the console only works in debug).
The parser works well, but when in close my application, the device closes correctly, but the console remains opened. Commenting the parser solves the problem. In release the application closes completely without problems.
I was wondering if the ISAXXMLReader i use, could be leaving something in memory, altough it is strange that in realese it works correctly. Is this normal? Should I really worry about this? It is really annoying to not be able to close the application correctly in debug.
The code that calls the parser is this:
bool CargadorMapasXML::parseaMapa(const char * nombreMapa, logica::Nivel *nivel, gui::NivelGui *nivelGui, EFlagParseo flag)
{
//We initiliaze the com
CoInitialize(NULL);
ISAXXMLReader* pRdr = NULL;
HRESULT hr = CoCreateInstance(
__uuidof(SAXXMLReader),
NULL,
CLSCTX_ALL,
__uuidof(ISAXXMLReader),
(void **)&pRdr);
//If it has not failed
if(!FAILED(hr))
{
try
{
//We create the handler and assign it to the reader
MapaXMLHandler * pMXH = new MapaXMLHandler();
hr = pRdr->putContentHandler(pMXH);
//Some information the handler needs
pMXH->setNivel(nivel);
pMXH->setNivelGui(nivelGui);
pMXH->setFlag(flag);
//Convert the name of the mpa to "static wchar_t"
static wchar_t URL[1000];
mbstowcs( URL, nombreMapa, 999 );
//#ifdef _DEBUG
//wprintf(L"\nParsing document: %s\n", URL);
//#endif
//We parse it
hr = pRdr->parseURL(URL);
//Free the reader
pRdr->Release();
//Destroy the reader
delete pMXH;
}
catch (int e)
{
return false;
}
}
if (FAILED(hr))
return false;
CoUninitialize();
return true;
}