Outlook remains in memory... and OL2000 crahes

L

LukeV

Ok, let me start over. The code below shows that I do handle the
ExplorerClose event. Everything works like a charm with OL2002, as long as I
set m_spExplorer = NULL in OnExplorerClose(). If I don't OL2002 remains in
memory for a few seconds and OL2000 remains way longer. If I don't set
m_spExplorer = NULL, then OL2000 will crash. Crashes will occur if I change
the selection in the Folder List view, like say selecting Journal (has to be
a special folder) and then selecting Inbox.

When the crash occur, the next time OL2000 is restarted, the plugin's menu
item will be duplicated. If I do a Reset of the menu, and that I do change
the selection in the Folder List, then OL2000 won't crash!

I really don't know what to do... help!

CComPtr<Outlook::_Explorer> m_spExplorer;

OnConnection()
{
...
m_spExplorer = NULL;
CComPtr<_Explorer> spExplorer = NULL;

spApp->ActiveExplorer( &spExplorer );
ATLASSERT(spExplorer);
m_spExplorer = spExplorer;

if( spExplorer )
{
hr = spExplorer->get_CommandBars(&spCmdBars);
if(FAILED(hr))
return hr;
ATLASSERT(spCmdBars);
}
...
hr = ExplorerBeforeFolderSwitch::DispEventAdvise((IDispatch*)m_spExplorer);
if(FAILED(hr))
return hr;

hr = ExplorerClose::DispEventAdvise((IDispatch*)m_spExplorer);
if(FAILED(hr))
return hr;
...
}

OnBeforeSwitchFolder()
{
NewFolder->QueryInterface( IID_MAPIFolder, (void**)&pFolder );

m_pCurrFolder = pFolder;

UpdateUI();
}

OnExplorerClose()
{
hr = ExplorerClose::DispEventUnadvise((IDispatch*)m_spExplorer);
hr =
ExplorerBeforeFolderSwitch::DispEventUnadvise((IDispatch*)m_spExplorer);

m_spExplorer = NULL;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top