mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
[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 svn path=/trunk/; revision=67311
This commit is contained in:
parent
147890023b
commit
604568dbaf
2 changed files with 22 additions and 8 deletions
|
@ -34,7 +34,7 @@ typedef struct
|
||||||
UINT Status;
|
UINT Status;
|
||||||
} LANSTATUSUI_CONTEXT;
|
} LANSTATUSUI_CONTEXT;
|
||||||
|
|
||||||
class CLanStatus :
|
class CLanStatus final :
|
||||||
public IOleCommandTarget
|
public IOleCommandTarget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -1149,16 +1149,12 @@ ULONG
|
||||||
WINAPI
|
WINAPI
|
||||||
CLanStatus::Release()
|
CLanStatus::Release()
|
||||||
{
|
{
|
||||||
#if 0 // WTF?!
|
|
||||||
ULONG refCount = InterlockedDecrement(&m_ref);
|
ULONG refCount = InterlockedDecrement(&m_ref);
|
||||||
|
|
||||||
if (!refCount)
|
if (!refCount)
|
||||||
delete this;
|
delete this;
|
||||||
|
|
||||||
return refCount;
|
return refCount;
|
||||||
#else
|
|
||||||
return 1;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT
|
HRESULT
|
||||||
|
|
|
@ -111,6 +111,8 @@ class CNetConUiObject final :
|
||||||
virtual HRESULT STDMETHODCALLTYPE Extract(LPCWSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize);
|
virtual HRESULT STDMETHODCALLTYPE Extract(LPCWSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
~CNetConUiObject();
|
||||||
|
|
||||||
LONG m_ref;
|
LONG m_ref;
|
||||||
PCUITEMID_CHILD m_pidl;
|
PCUITEMID_CHILD m_pidl;
|
||||||
IUnknown *m_pUnknown;
|
IUnknown *m_pUnknown;
|
||||||
|
@ -139,13 +141,21 @@ HRESULT ShowNetConnectionStatus(IOleCommandTarget * lpOleCmd, INetConnection * p
|
||||||
|
|
||||||
CNetworkConnections::CNetworkConnections() :
|
CNetworkConnections::CNetworkConnections() :
|
||||||
m_ref(0),
|
m_ref(0),
|
||||||
m_pidlRoot(_ILCreateNetConnect()),
|
m_pidlRoot(_ILCreateNetConnect())
|
||||||
m_lpOleCmd(NULL)
|
|
||||||
{
|
{
|
||||||
|
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()
|
CNetworkConnections::~CNetworkConnections()
|
||||||
{
|
{
|
||||||
|
if (m_lpOleCmd)
|
||||||
|
m_lpOleCmd->Release();
|
||||||
SHFree(m_pidlRoot);
|
SHFree(m_pidlRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -670,6 +680,14 @@ CNetConUiObject::CNetConUiObject(PCUITEMID_CHILD pidl, IOleCommandTarget *lpOleC
|
||||||
m_pUnknown(NULL),
|
m_pUnknown(NULL),
|
||||||
m_lpOleCmd(lpOleCmd)
|
m_lpOleCmd(lpOleCmd)
|
||||||
{
|
{
|
||||||
|
if (m_lpOleCmd)
|
||||||
|
m_lpOleCmd->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
CNetConUiObject::~CNetConUiObject()
|
||||||
|
{
|
||||||
|
if (m_lpOleCmd)
|
||||||
|
m_lpOleCmd->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
|
@ -856,7 +874,7 @@ ShowNetConnectionStatus(
|
||||||
if (pNetConnect->GetProperties(&pProperties) != S_OK)
|
if (pNetConnect->GetProperties(&pProperties) != S_OK)
|
||||||
return E_FAIL;
|
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);
|
NcFreeNetconProperties(pProperties);
|
||||||
return hr;
|
return hr;
|
||||||
|
|
Loading…
Reference in a new issue