+static IDropTarget* WrapDropTarget(IDropTarget* inner) +{
- DropTargetWrapper* This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
- if (This)
- {
This->iface = (IDropTarget){ &DropTargetWrapper_VTbl };
This->iface.lpVtbl = &DropTargetWrapper_VTbl;
- hr = CoMarshalInterface(stream, &IID_IDropTarget, unk, MSHCTX_LOCAL, NULL, MSHLFLAGS_TABLESTRONG);
- IUnknown_Release(unk);
hr = CoMarshalInterface(stream, &IID_IDropTarget, (IUnknown*)wrapper, MSHCTX_LOCAL, NULL, MSHLFLAGS_TABLESTRONG);
if(SUCCEEDED(hr)) { hr = create_map_from_stream(stream, &map); if(SUCCEEDED(hr)) {
IDropTarget_AddRef(pDropTarget); SetPropW(hwnd, prop_oledroptarget, pDropTarget);
You probably want to set the window prop to the wrapper here. Either way you still need the AddRef (on the wrapper if you set that), it gets released in RevokeDragDrop.
Huw.
On 05/24/2011 03:37 AM, Huw Davies wrote:
+static IDropTarget* WrapDropTarget(IDropTarget* inner) +{
- DropTargetWrapper* This = HeapAlloc(GetProcessHeap(), 0, sizeof(*This));
- if (This)
- {
This->iface = (IDropTarget){&DropTargetWrapper_VTbl };
This->iface.lpVtbl =&DropTargetWrapper_VTbl;
- hr = CoMarshalInterface(stream,&IID_IDropTarget, unk, MSHCTX_LOCAL, NULL, MSHLFLAGS_TABLESTRONG);
- IUnknown_Release(unk);
hr = CoMarshalInterface(stream,&IID_IDropTarget, (IUnknown*)wrapper, MSHCTX_LOCAL, NULL, MSHLFLAGS_TABLESTRONG);
if(SUCCEEDED(hr)) { hr = create_map_from_stream(stream,&map); if(SUCCEEDED(hr)) {
IDropTarget_AddRef(pDropTarget); SetPropW(hwnd, prop_oledroptarget, pDropTarget);
You probably want to set the window prop to the wrapper here. Either way you still need the AddRef (on the wrapper if you set that), it gets released in RevokeDragDrop.
Huw.
The AddRef is done in WrapDropTarget(), seems like the appropriate place for it. Quite right on the rest though, thanks.
On 05/25/2011 12:36 PM, Adam Martinson wrote:
On 05/24/2011 03:37 AM, Huw Davies wrote:
+static IDropTarget* WrapDropTarget(IDropTarget* inner) +{
- DropTargetWrapper* This = HeapAlloc(GetProcessHeap(), 0,
sizeof(*This));
- if (This)
- {
This->iface = (IDropTarget){&DropTargetWrapper_VTbl };
This->iface.lpVtbl =&DropTargetWrapper_VTbl;
- hr = CoMarshalInterface(stream,&IID_IDropTarget, unk,
MSHCTX_LOCAL, NULL, MSHLFLAGS_TABLESTRONG);
- IUnknown_Release(unk);
- hr = CoMarshalInterface(stream,&IID_IDropTarget,
(IUnknown*)wrapper, MSHCTX_LOCAL, NULL, MSHLFLAGS_TABLESTRONG);
if(SUCCEEDED(hr)) { hr = create_map_from_stream(stream,&map); if(SUCCEEDED(hr)) {
IDropTarget_AddRef(pDropTarget); SetPropW(hwnd, prop_oledroptarget, pDropTarget);
You probably want to set the window prop to the wrapper here. Either way you still need the AddRef (on the wrapper if you set that), it gets released in RevokeDragDrop.
Huw.
The AddRef is done in WrapDropTarget(), seems like the appropriate place for it. Quite right on the rest though, thanks.
Oops no, the window prop should be pDropTarget, not the wrapper. The wrapper is only used for the marshalling.
On Wed, May 25, 2011 at 12:45:15PM -0500, Adam Martinson wrote:
On 05/25/2011 12:36 PM, Adam Martinson wrote:
The AddRef is done in WrapDropTarget(), seems like the appropriate place for it. Quite right on the rest though, thanks.
Oops no, the window prop should be pDropTarget, not the wrapper. The wrapper is only used for the marshalling.
That window prop could probably go away, I only put it there because that's what Windows does, I doubt there's an app that relies on it though. However if it stays you do need the AddRef!
Huw.
On 05/26/2011 06:47 AM, Huw Davies wrote:
On Wed, May 25, 2011 at 12:45:15PM -0500, Adam Martinson wrote:
On 05/25/2011 12:36 PM, Adam Martinson wrote:
The AddRef is done in WrapDropTarget(), seems like the appropriate place for it. Quite right on the rest though, thanks.
Oops no, the window prop should be pDropTarget, not the wrapper. The wrapper is only used for the marshalling.
That window prop could probably go away, I only put it there because that's what Windows does, I doubt there's an app that relies on it though. However if it stays you do need the AddRef!
Huw.
Best to mirror Windows as close as possible. The AddRef() is done in WrapDropTarget(). On failure IDropTarget::Release() is done on the wrapper, which removes the ref on the original.
On Thu, May 26, 2011 at 06:51:13AM -0500, Adam Martinson wrote:
On 05/26/2011 06:47 AM, Huw Davies wrote:
On Wed, May 25, 2011 at 12:45:15PM -0500, Adam Martinson wrote:
On 05/25/2011 12:36 PM, Adam Martinson wrote:
The AddRef is done in WrapDropTarget(), seems like the appropriate place for it. Quite right on the rest though, thanks.
Oops no, the window prop should be pDropTarget, not the wrapper. The wrapper is only used for the marshalling.
That window prop could probably go away, I only put it there because that's what Windows does, I doubt there's an app that relies on it though. However if it stays you do need the AddRef!
Huw.
Best to mirror Windows as close as possible. The AddRef() is done in WrapDropTarget(). On failure IDropTarget::Release() is done on the wrapper, which removes the ref on the original.
You're storing a 2nd instance of the ptr (the first being in the wrapper), conventionally you take a 2nd ref. When you remove the window prop you release and when you destroy the wrapper you release again.
Huw.
On 05/26/2011 06:56 AM, Huw Davies wrote:
On Thu, May 26, 2011 at 06:51:13AM -0500, Adam Martinson wrote:
On 05/26/2011 06:47 AM, Huw Davies wrote:
On Wed, May 25, 2011 at 12:45:15PM -0500, Adam Martinson wrote:
On 05/25/2011 12:36 PM, Adam Martinson wrote:
The AddRef is done in WrapDropTarget(), seems like the appropriate place for it. Quite right on the rest though, thanks.
Oops no, the window prop should be pDropTarget, not the wrapper. The wrapper is only used for the marshalling.
That window prop could probably go away, I only put it there because that's what Windows does, I doubt there's an app that relies on it though. However if it stays you do need the AddRef!
Huw.
Best to mirror Windows as close as possible. The AddRef() is done in WrapDropTarget(). On failure IDropTarget::Release() is done on the wrapper, which removes the ref on the original.
You're storing a 2nd instance of the ptr (the first being in the wrapper), conventionally you take a 2nd ref. When you remove the window prop you release and when you destroy the wrapper you release again.
Huw.
Ah, right, looks like I'm leaking the wrapper this way.