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

[release/9.0] Fix GetFormats and GetDataPresent #12193

Open
wants to merge 1 commit into
base: release/9.0
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -515,17 +515,11 @@ public string[] GetFormats(bool autoConvert)

enumFORMATETC.Value->Reset();

Com.FORMATETC[] formatEtc = [default];
HRESULT hr;
Com.FORMATETC formatEtc = default;

fixed (Com.FORMATETC* pFormatEtc = formatEtc)
while (enumFORMATETC.Value->Next(1, &formatEtc) == HRESULT.S_OK)
{
hr = enumFORMATETC.Value->Next(1, pFormatEtc);
}

if (hr == HRESULT.S_OK)
{
string name = DataFormats.GetFormat(formatEtc[0].cfFormat).Name;
string name = DataFormats.GetFormat(formatEtc.cfFormat).Name;
if (autoConvert)
{
string[] mappedFormats = GetMappedFormats(name)!;
Expand All @@ -538,6 +532,8 @@ public string[] GetFormats(bool autoConvert)
{
distinctFormats.Add(name);
}

formatEtc = default;
}

return [.. distinctFormats];
Expand All @@ -564,7 +560,9 @@ private bool GetDataPresentInner(string format)

using var nativeDataObject = _nativeDataObject.GetInterface();
HRESULT hr = nativeDataObject.Value->QueryGetData(formatEtc);
return hr.Succeeded;

// APIs will return S_FALSE, which is "success"
return hr == HRESULT.S_OK;
}
}
}
Expand Down