mirror of
https://github.com/Open-Shell/Open-Shell-Menu.git
synced 2026-04-17 13:23:04 +10:00
Cleanup of the accessibility COM objects (#53)
Fixed issue related to the cleanup of the accessibility COM objects that may cause Explorer to crash. Submitted by Ivo Beltchev. Fixes #53
This commit is contained in:
@@ -4426,13 +4426,28 @@ LRESULT CMenuContainer::OnCreate( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
|
|||||||
if (m_Options&CONTAINER_SEARCH)
|
if (m_Options&CONTAINER_SEARCH)
|
||||||
s_SearchMenu=m_hWnd;
|
s_SearchMenu=m_hWnd;
|
||||||
s_HotPos=GetMessagePos();
|
s_HotPos=GetMessagePos();
|
||||||
|
m_pAccessible=NULL;
|
||||||
if (GetSettingBool(L"EnableAccessibility"))
|
if (GetSettingBool(L"EnableAccessibility"))
|
||||||
{
|
{
|
||||||
m_pAccessible=new CMenuAccessible(this);
|
if (SUCCEEDED(m_pAccessibleContext.CoCreateInstance(CLSID_ContextSwitcher)))
|
||||||
|
{
|
||||||
|
CreateAccessibleData createData={this};
|
||||||
|
ComCallData callData={};
|
||||||
|
callData.pUserDefined=&createData;
|
||||||
|
if (SUCCEEDED(m_pAccessibleContext->ContextCallback(CreateAccessible,&callData,IID_IAccessible,4,NULL)))
|
||||||
|
{
|
||||||
|
if (FAILED(CoGetInterfaceAndReleaseStream(createData.pStream,IID_IAccessible,(void**)&m_pAccessible)))
|
||||||
|
{
|
||||||
|
m_pAccessibleContext=NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_pAccessibleContext=NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
NotifyWinEvent(EVENT_SYSTEM_MENUPOPUPSTART,m_hWnd,OBJID_CLIENT,CHILDID_SELF);
|
NotifyWinEvent(EVENT_SYSTEM_MENUPOPUPSTART,m_hWnd,OBJID_CLIENT,CHILDID_SELF);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
m_pAccessible=NULL;
|
|
||||||
m_pDropTargetProxy=new CDropTargetProxy(this);
|
m_pDropTargetProxy=new CDropTargetProxy(this);
|
||||||
RegisterDragDrop(m_hWnd,m_pDropTargetProxy);
|
RegisterDragDrop(m_hWnd,m_pDropTargetProxy);
|
||||||
if (!m_bSubMenu && s_pFrameworkInputPane)
|
if (!m_bSubMenu && s_pFrameworkInputPane)
|
||||||
@@ -4441,6 +4456,23 @@ LRESULT CMenuContainer::OnCreate( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HRESULT __stdcall CMenuContainer::CreateAccessible( ComCallData *pData )
|
||||||
|
{
|
||||||
|
CreateAccessibleData *pCreateData=(CreateAccessibleData*)pData->pUserDefined;
|
||||||
|
CComPtr<CMenuAccessible> pAccessible=new CMenuAccessible(pCreateData->pMenu);
|
||||||
|
HRESULT hr=CoMarshalInterThreadInterfaceInStream(IID_IAccessible,pAccessible,&pCreateData->pStream);
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
pAccessible->Reset();
|
||||||
|
}
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT __stdcall CMenuContainer::ReleaseAccessible( ComCallData *pData )
|
||||||
|
{
|
||||||
|
return CoDisconnectContext(INFINITE);
|
||||||
|
}
|
||||||
|
|
||||||
bool CMenuContainer::GetItemRect( int index, RECT &rc )
|
bool CMenuContainer::GetItemRect( int index, RECT &rc )
|
||||||
{
|
{
|
||||||
if (index>=0 && index<(int)m_Items.size())
|
if (index>=0 && index<(int)m_Items.size())
|
||||||
@@ -6111,7 +6143,8 @@ LRESULT CMenuContainer::OnDestroy( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL
|
|||||||
if (m_pAccessible)
|
if (m_pAccessible)
|
||||||
{
|
{
|
||||||
NotifyWinEvent(EVENT_SYSTEM_MENUPOPUPEND,m_hWnd,OBJID_CLIENT,CHILDID_SELF);
|
NotifyWinEvent(EVENT_SYSTEM_MENUPOPUPEND,m_hWnd,OBJID_CLIENT,CHILDID_SELF);
|
||||||
m_pAccessible->Reset();
|
m_pAccessibleContext->ContextCallback(ReleaseAccessible,NULL,IID_IAccessible,4,NULL);
|
||||||
|
m_pAccessibleContext=NULL;
|
||||||
m_pAccessible=NULL;
|
m_pAccessible=NULL;
|
||||||
}
|
}
|
||||||
if (m_pDropTargetHelper && m_pDragObject)
|
if (m_pDropTargetHelper && m_pDragObject)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "TouchHelper.h"
|
#include "TouchHelper.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <ctxtcall.h>
|
||||||
|
|
||||||
//#define PREVENT_CLOSING // define this to prevent the menu from closing when it is deactivated (useful for debugging)
|
//#define PREVENT_CLOSING // define this to prevent the menu from closing when it is deactivated (useful for debugging)
|
||||||
//#define REPEAT_ITEMS 10 // define this to repeat each menu item (useful to simulate large menus)
|
//#define REPEAT_ITEMS 10 // define this to repeat each menu item (useful to simulate large menus)
|
||||||
@@ -628,7 +629,8 @@ private:
|
|||||||
CAbsolutePidl m_Path2[2];
|
CAbsolutePidl m_Path2[2];
|
||||||
CComPtr<IShellItem> m_pDropFolder[2]; // the primary folder (used only as a drop target)
|
CComPtr<IShellItem> m_pDropFolder[2]; // the primary folder (used only as a drop target)
|
||||||
CComPtr<IShellView> m_pShellView; // keep the view alive because some buggy namespace extensions clean up if there is no view
|
CComPtr<IShellView> m_pShellView; // keep the view alive because some buggy namespace extensions clean up if there is no view
|
||||||
CComPtr<CMenuAccessible> m_pAccessible;
|
CComPtr<IContextCallback> m_pAccessibleContext;
|
||||||
|
CComPtr<IAccessible> m_pAccessible;
|
||||||
CComPtr<CDropTargetProxy> m_pDropTargetProxy;
|
CComPtr<CDropTargetProxy> m_pDropTargetProxy;
|
||||||
DWORD m_InputCookie;
|
DWORD m_InputCookie;
|
||||||
std::vector<int> m_ColumnOffsets;
|
std::vector<int> m_ColumnOffsets;
|
||||||
@@ -983,6 +985,14 @@ private:
|
|||||||
};
|
};
|
||||||
static void CloseSubMenus( int flags, CMenuContainer *pAfter );
|
static void CloseSubMenus( int flags, CMenuContainer *pAfter );
|
||||||
|
|
||||||
|
struct CreateAccessibleData
|
||||||
|
{
|
||||||
|
CMenuContainer *pMenu;
|
||||||
|
IStream *pStream;
|
||||||
|
};
|
||||||
|
static HRESULT __stdcall CreateAccessible( ComCallData *pData );
|
||||||
|
static HRESULT __stdcall ReleaseAccessible( ComCallData *pData );
|
||||||
|
|
||||||
// To control the placement of the start menu, send ClassicStartMenu.StartMenuMsg message right after the start menu is created but before it is displayed
|
// To control the placement of the start menu, send ClassicStartMenu.StartMenuMsg message right after the start menu is created but before it is displayed
|
||||||
// The lParam must point to StartMenuParams
|
// The lParam must point to StartMenuParams
|
||||||
// monitorRect - the entire area available to the start menu (sub-menus will use it). It is usually the monitor area but can be less if the Desktop app is docked in Win8
|
// monitorRect - the entire area available to the start menu (sub-menus will use it). It is usually the monitor area but can be less if the Desktop app is docked in Win8
|
||||||
|
|||||||
Reference in New Issue
Block a user