[ImageIO] We don't typically own input parameters. (#17613)

We don't typically own input parameters, so make sure to pass 'false' for the
'owns' parameter to Runtime.GetNSObject.

This fixes a crash due to overreleasing these objects.

Also make the block creation code optimizable.
This commit is contained in:
Rolf Bjarne Kvinge 2023-02-24 19:55:12 +01:00 коммит произвёл GitHub
Родитель ee5d176bfc
Коммит cfee729c01
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 3 добавлений и 2 удалений

Просмотреть файл

@ -127,14 +127,15 @@ namespace ImageIO {
[MonoPInvokeCallback (typeof (TrampolineCallback))]
static bool TagEnumerator (IntPtr block, NativeHandle key, NativeHandle value)
{
var nsKey = Runtime.GetNSObject<NSString> (key, true)!;
var nsValue = Runtime.GetINativeObject<CGImageMetadataTag> (value, true)!;
var nsKey = Runtime.GetNSObject<NSString> (key, false)!;
var nsValue = Runtime.GetINativeObject<CGImageMetadataTag> (value, false)!;
var del = BlockLiteral.GetTarget<CGImageMetadataTagBlock> (block);
return del (nsKey, nsValue);
}
static unsafe readonly TrampolineCallback static_action = TagEnumerator;
[BindingImpl (BindingImplOptions.Optimizable)]
public void EnumerateTags (NSString? rootPath, CGImageMetadataEnumerateOptions? options, CGImageMetadataTagBlock block)
{
using var o = options?.ToDictionary ();