Reference::~Reference() { unadvise(); if (m_pDispatch != 0) { m_pDispatch->Release(); } m_pUnknown->Release(); delete m_pClass; }
bool IEDebugger::unadvise(IDebugApplicationNode* node, bool isRoot, bool recurse) { CComPtr<IConnectionPointContainer> connectionPointContainer = NULL; HRESULT hr = node->QueryInterface(IID_IConnectionPointContainer, (void**)&connectionPointContainer); if (FAILED(hr)) { Logger::error("IEDebugger.unadvise(): QI(IID_IConnectionPointContainer) failed", hr); return false; } CComPtr<IConnectionPoint> nodeConnectionPoint = NULL; hr = connectionPointContainer->FindConnectionPoint(IID_IDebugApplicationNodeEvents, &nodeConnectionPoint); if (FAILED(hr)) { Logger::error("IEDebugger.unadvise(): FindConnectionPoint() failed", hr); return false; } DWORD cookie = 0; if (isRoot) { cookie = m_rootCookie; m_rootNode->Release(); m_rootNode = NULL; } else { std::map<IDebugApplicationNode*, DWORD>::iterator iterator = m_adviseCookies->find(node); if (iterator != m_adviseCookies->end()) { cookie = iterator->second; iterator->first->Release(); m_adviseCookies->erase(iterator); } } if (cookie) { hr = nodeConnectionPoint->Unadvise(cookie); if (FAILED(hr)) { Logger::error("IEDebugger.unadvise(): Unadvise() failed", hr); } } if (recurse) { CComPtr<IEnumDebugApplicationNodes> nodes = NULL; hr = node->EnumChildren(&nodes); if (FAILED(hr)) { Logger::error("IEDebugger.unadvise(): EnumChildren() failed", hr); } else { IDebugApplicationNode* current = NULL; ULONG count = 0; hr = nodes->Next(1, ¤t, &count); while (SUCCEEDED(hr) && count) { unadvise(current, false, true); current->Release(); hr = nodes->Next(1, ¤t, &count); } } } return true; }
void IEDebugger::setContext(CrossfireContext* value) { if (m_context == value) { return; } m_context = value; if (m_rootNode) { unadvise(m_rootNode, true, true); } if (value) { CComPtr<IRemoteDebugApplication> application = NULL; HRESULT hr = m_context->getDebugApplication(&application); if (SUCCEEDED(hr)) { CComPtr<IDebugApplicationNode> rootNode = NULL; hr = application->GetRootNode(&rootNode); if (FAILED(hr)) { Logger::error("IEDebugger.setContext(): GetRootNode() failed", hr); return; } advise(rootNode, true, true); } } }
STDMETHODIMP IEDebugger::onRemoveChild(IDebugApplicationNode *prddpChild) { unadvise(prddpChild, false, false); return S_OK; }