adwaita-swift
adwaita-swift copied to clipboard
Convert Int.max to CInt cause crash :)
Describe the bug
.frame(maxWidth: .max)
cause crash because .max became from Int which Int64 on aarch64 and x86_64 arches :) but we try to convert it to CInt which Int32 under the hood :)
To Reproduce
- Create some view (Text for example)
- Append
.frame(maxWidth: .max)to it (because there is no .infinity variant from SwiftUI) - Run app
- Get crash :)
Expected behavior
Not crash :)
Additional context
I suppose that we need to perform a lossy conversion from Int (which is a synonym for Int64) to CInt (a synonym for Int32) when casting, or not use Int in functions which use CInt at all :)
Workaround:
.frame(maxHeight: Int(CInt.max))
Thanks for the report! I'll fix this (currently I don't have access to my laptop).
I think you're expecting setting the maximum width to infinity make the view expand horizontally? If this is your goal, use hexpand(_:) instead. frame(maxWidth:) only makes sense when restricting the width.
I fixed this in https://github.com/AparokshaUI/adwaita-swift/commit/018d21ee65116c7e815be47fda04f5a6d7f75951 (1.0.0 branch). It will be fixed in the 1.0.0 release.