xamarin / Xamarin.PropertyEditing

MIT License
24 stars 16 forks source link

[main] Add cast to fix bug with numeric conversion #795

Closed vs-mobiletools-engineering-service2 closed 2 years ago

vs-mobiletools-engineering-service2 commented 2 years ago

With the macos P13 API type changes, an issue was introduced since casting an ObjCRuntime.nfloat to an nint (aka IntPtr) doesn't work properly - (nint)(ObjCRuntime.nfloat)23 for instance will evaluate to 0x4037000000000000, the floating point bits are just reinterpreted as an int rather than actually being converted.

That in turn caused huge sizes for width and height causing new CGBitmapContext to throw an exception.

Adding the double cast here fixes this, for now.

Soon ObjCRuntime.nfloat will go away, replaced by System.Runtime.InteropServices.NFloat, but for now this workaround makes us work.

Fixes: AB#1487089 AB#1487070 AB#1487089

Backport of #794