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

Mac: DataObject.GetData() should not crash when data is zero #1792

Merged
merged 1 commit into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Eto.Mac/Forms/DataObjectHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public byte[] GetData(string type)
if (availableType != null)
{
var data = Control.GetDataForType(availableType);
if (data == null)
if (data == null || data.Bytes == IntPtr.Zero)
return null;
var bytes = new byte[data.Length];
Marshal.Copy(data.Bytes, bytes, 0, (int)data.Length);
Expand Down
3 changes: 2 additions & 1 deletion src/Eto.Mac/Forms/MacView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,8 @@ protected void SetupDragPasteboard(NSPasteboard pasteboard)
if (s_etoDragItemType == null)
s_etoDragItemType = UTType.CreatePreferredIdentifier(UTType.TagClassNSPboardType, "eto.dragitem", UTType.Item);

pasteboard.SetStringForType(string.Empty, s_etoDragItemType);
// don't send an empty string, some code can't handle null data.
pasteboard.SetStringForType(".", s_etoDragItemType);
}

public virtual void DoDragDrop(DataObject data, DragEffects allowedAction, Image image, PointF origin)
Expand Down