adwaita-swift icon indicating copy to clipboard operation
adwaita-swift copied to clipboard

Convert Int.max to CInt cause crash :)

Open iDevPro opened this issue 1 year ago • 1 comments
trafficstars

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

  1. Create some view (Text for example)
  2. Append .frame(maxWidth: .max) to it (because there is no .infinity variant from SwiftUI)
  3. Run app
  4. 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))

iDevPro avatar Jul 26 '24 07:07 iDevPro

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.

david-swift avatar Jul 26 '24 10:07 david-swift

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.

david-swift avatar Aug 25 '24 09:08 david-swift