Skip to content

Commit 7efaba6

Browse files
committed
Fix gio::FileEnumeratorExt::close(): return value does not indicate success or error
Signed-off-by: fbrouille <[email protected]>
1 parent 611dc0d commit 7efaba6

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

gio/Gir.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,12 @@ manual_traits = ["FileDescriptorBasedExtManual"]
886886
[[object]]
887887
name = "Gio.FileEnumerator"
888888
status = "generate"
889+
[[object.function]]
890+
name = "close"
891+
[object.function.return]
892+
# Return value does not indicate success or error: despite the documentation, this function could return TRUE and an error in same time.
893+
# see https://gitlab.gnome.org/GNOME/glib/-/blob/dc6f9447cd2a01012731422afed6facff1eea81a/gio/gfileenumerator.c#L290-297
894+
use_return_for_result = true
889895
manual_traits = ["FileEnumeratorExtManual"]
890896
[[object.function]]
891897
name = "iterate"

gio/src/auto/file_enumerator.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,16 @@ impl FileEnumerator {
2121

2222
pub trait FileEnumeratorExt: IsA<FileEnumerator> + 'static {
2323
#[doc(alias = "g_file_enumerator_close")]
24-
fn close(&self, cancellable: Option<&impl IsA<Cancellable>>) -> Result<(), glib::Error> {
24+
fn close(&self, cancellable: Option<&impl IsA<Cancellable>>) -> Result<bool, glib::Error> {
2525
unsafe {
2626
let mut error = std::ptr::null_mut();
27-
let is_ok = ffi::g_file_enumerator_close(
27+
let ret = ffi::g_file_enumerator_close(
2828
self.as_ref().to_glib_none().0,
2929
cancellable.map(|p| p.as_ref()).to_glib_none().0,
3030
&mut error,
3131
);
32-
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
3332
if error.is_null() {
34-
Ok(())
33+
Ok(from_glib(ret))
3534
} else {
3635
Err(from_glib_full(error))
3736
}

0 commit comments

Comments
 (0)