Author: tfaber Date: Sun Apr 19 21:07:35 2015 New Revision: 67311
URL: http://svn.reactos.org/svn/reactos?rev=67311&view=rev Log: [NETSHELL] - Keep a CLanStatus instance around in CNetworkConnections (as before r65758) and properly manage its lifetime. Fixes Status context menu item for network connections. CORE-9564
Modified: trunk/reactos/dll/shellext/netshell/lanstatusui.cpp trunk/reactos/dll/shellext/netshell/shfldr_netconnect.cpp
Modified: trunk/reactos/dll/shellext/netshell/lanstatusui.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/netshell/lanst... ============================================================================== --- trunk/reactos/dll/shellext/netshell/lanstatusui.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/shellext/netshell/lanstatusui.cpp [iso-8859-1] Sun Apr 19 21:07:35 2015 @@ -34,7 +34,7 @@ UINT Status; } LANSTATUSUI_CONTEXT;
-class CLanStatus : +class CLanStatus final : public IOleCommandTarget { public: @@ -1149,16 +1149,12 @@ WINAPI CLanStatus::Release() { -#if 0 // WTF?! ULONG refCount = InterlockedDecrement(&m_ref);
if (!refCount) delete this;
return refCount; -#else - return 1; -#endif }
HRESULT
Modified: trunk/reactos/dll/shellext/netshell/shfldr_netconnect.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/shellext/netshell/shfld... ============================================================================== --- trunk/reactos/dll/shellext/netshell/shfldr_netconnect.cpp [iso-8859-1] (original) +++ trunk/reactos/dll/shellext/netshell/shfldr_netconnect.cpp [iso-8859-1] Sun Apr 19 21:07:35 2015 @@ -111,6 +111,8 @@ virtual HRESULT STDMETHODCALLTYPE Extract(LPCWSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize);
private: + ~CNetConUiObject(); + LONG m_ref; PCUITEMID_CHILD m_pidl; IUnknown *m_pUnknown; @@ -139,13 +141,21 @@
CNetworkConnections::CNetworkConnections() : m_ref(0), - m_pidlRoot(_ILCreateNetConnect()), - m_lpOleCmd(NULL) -{ + m_pidlRoot(_ILCreateNetConnect()) +{ + HRESULT hr; + hr = CoCreateInstance(CLSID_LanConnectStatusUI, NULL, CLSCTX_INPROC_SERVER, IID_IOleCommandTarget, reinterpret_cast<PVOID*>(&m_lpOleCmd)); + if (FAILED(hr)) + { + ERR("CoCreateInstance failed with %lx\n", hr); + m_lpOleCmd = NULL; + } }
CNetworkConnections::~CNetworkConnections() { + if (m_lpOleCmd) + m_lpOleCmd->Release(); SHFree(m_pidlRoot); }
@@ -670,6 +680,14 @@ m_pUnknown(NULL), m_lpOleCmd(lpOleCmd) { + if (m_lpOleCmd) + m_lpOleCmd->AddRef(); +} + +CNetConUiObject::~CNetConUiObject() +{ + if (m_lpOleCmd) + m_lpOleCmd->Release(); }
/************************************************************************ @@ -856,7 +874,7 @@ if (pNetConnect->GetProperties(&pProperties) != S_OK) return E_FAIL;
- hr = lpOleCmd->Exec(&pProperties->guidId, 2, OLECMDEXECOPT_DODEFAULT, NULL, NULL); + hr = lpOleCmd->Exec(&pProperties->guidId, OLECMDID_NEW, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
NcFreeNetconProperties(pProperties); return hr;