Skip to content

Commit a82eb0f

Browse files
authored
GtkBackend: Fix crash in Picker init when selection is nil (#139)
* Fix crash in Picker init when selection is nil * Add PickerExample * Revert "Add PickerExample" This reverts commit 55ca328. * Fix crash in Picker init when selection is nil
1 parent f149f08 commit a82eb0f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sources/GtkBackend/GtkBackend.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ public final class GtkBackend: AppBackend {
754754
)
755755

756756
picker.notifySelected = { picker, _ in
757-
if picker.selected == GTK_INVALID_LIST_POSITION {
757+
if picker.selected == Int(Int32(bitPattern: GTK_INVALID_LIST_POSITION)) {
758758
onChange(nil)
759759
} else {
760760
onChange(picker.selected)
@@ -765,7 +765,7 @@ public final class GtkBackend: AppBackend {
765765
public func setSelectedOption(ofPicker picker: Widget, to selectedOption: Int?) {
766766
let picker = picker as! DropDown
767767
if selectedOption != picker.selected {
768-
picker.selected = selectedOption ?? Int(GTK_INVALID_LIST_POSITION)
768+
picker.selected = selectedOption ?? Int(Int32(bitPattern: GTK_INVALID_LIST_POSITION))
769769
}
770770
}
771771

0 commit comments

Comments
 (0)