• Matthias Clasen's avatar
    file chooser button: Fix some refcounting confusion · defc0cf5
    Matthias Clasen authored
    GtkFileSystem has a complicated way to handle cancellables.
    You keep the cancellable pointer that is returned by
    _gtk_file_system_get_info and similar methods so that you can
    cancel the operation, but you do not own a reference to it.
    The only place where it is ok to unref a cancellable is in
    your callback, which gets handed a cancellable that you need
    to unref at the end. You are expected to compare it to the
    pointer you stashed away to find out if the operation has
    already been superseded by a newer call, in which case you
    disregard the results.
    
    GtkFileChooserButton was following these rules for most of
    the cancellables it keeps around, but it was sometimes unreffing
    the cancellables that are stored in the model, which could lead
    to refcount confusion and crashes. This commit makes it follow
    the rules for that case too, which fixes the crash in the bug
    below, and does not show up any leaks in valgrind under light
    testing.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=737804
    defc0cf5
gtkfilechooserbutton.c 87 KB