Fix picture's content being cleared automatically

This commit is contained in:
david-swift 2024-08-21 17:11:35 +02:00
parent fa344522a2
commit 901e19c052

View File

@ -18,8 +18,14 @@ extension Picture {
return inspect { storage, updateProperties in
if updateProperties {
let pointer = storage.opaquePointer
guard let data, data != storage.fields[oldData] as? Data else {
gtk_picture_set_paintable(pointer, gdk_paintable_new_empty(0, 0))
guard let data else {
if storage.fields[oldData] != nil {
gtk_picture_set_paintable(pointer, gdk_paintable_new_empty(0, 0))
storage.fields[oldData] = nil
}
return
}
guard data != storage.fields[oldData] as? Data else {
return
}
let bytes = data.withUnsafeBytes { ptr in