Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AV - Possible bug in TCustomDropTarget.SetPerformedDropEffect #18

Closed
brianjford opened this issue Sep 30, 2016 · 2 comments
Closed

AV - Possible bug in TCustomDropTarget.SetPerformedDropEffect #18

brianjford opened this issue Sep 30, 2016 · 2 comments

Comments

@brianjford
Copy link

After upgrading to the most recent version of these controls (with the changes for Berlin 10.1) I started getting AV's when doing a drag/drop from a TVirtualTreeView into a DropHandler on another form. I tracked it down to what seems to be a change to TCustomDropTarget.SetPerformedDropEffect where two lines were added:
if Result then
ReleaseStgMedium(Medium);

This seems to be Releasing a Medium which then causes an AV when it later gets released again inside the VirtualTrees code in TVTDataObject.Destroy.

I am not an expert in Drag/Drop at all, so I'm not sure if the real error is inside the function mentioned above or it's inside the VirtualTree code (though removing the ReleaseStgMedium call from SetPerformedDropEffect has resolved my issue.

@brianjford
Copy link
Author

SetPerformedDropEffect calls TClipboardFormat.SetData which has these lines in it:

// If we didn't succeed in transfering ownership of the data medium to the
// IDataObject, we must deallocate the medium ourselves.
if (not Result) then
ReleaseStgMedium(AMedium);

The comment there seems to indicate that upon failure it should release the medium (which it does). So it does seem strange to me that once this function returns it goes back to SetPerformedDropEffect which then releases the medium in the non-failure case.. It seems like it should not be released as the IDataObject should have ownership of that medium now.

@landrix
Copy link
Owner

landrix commented Oct 20, 2016

Can you provide a demo-project?

@landrix landrix closed this as completed Oct 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants