~haowenl/vorg

7e7a49e98f93f454b63d0467e6d1fd57553347c0 — Haowen Liu a month ago ddcb35f
Correct use of dispose vs finalize
M src/vorg-application.c => src/vorg-application.c +5 -8
@@ 119,16 119,13 @@ vorg_application_init (VorgApplication *self)
}

static void
vorg_application_finalize (GObject *object)
vorg_application_dispose (GObject *object)
{
  VorgApplication *self = VORG_APPLICATION (object);
  if (self->current_dir != NULL)
    {
      g_object_unref (self->current_dir);
    }
  g_object_unref (self->repo);
  g_clear_object (&self->repo);
  g_clear_object (&self->current_dir);

  G_OBJECT_CLASS (vorg_application_parent_class)->finalize (object);
  G_OBJECT_CLASS (vorg_application_parent_class)->dispose (object);
}

static void


@@ 137,7 134,7 @@ vorg_application_class_init (VorgApplicationClass *klass)
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
  GApplicationClass *app_class = G_APPLICATION_CLASS (klass);

  object_class->finalize = vorg_application_finalize;
  object_class->dispose = vorg_application_dispose;

  app_class->activate = vorg_application_activate;
}

M src/vorg-browse.c => src/vorg-browse.c +5 -1
@@ 117,7 117,11 @@ vorg_browse_widget_from_video (GObject *item,
                               __attribute__ ((unused)) gpointer user_data)
{
  VorgVideo *video = VORG_VIDEO (item);
  return gtk_label_new (vorg_video_get_path (video));
  GtkWidget *box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
  gtk_box_append (GTK_BOX (box), GTK_WIDGET (gtk_picture_new_for_filename (
                                     vorg_video_get_thumbnail (video))));

  return box;
}

/**

M src/vorg-browse.ui => src/vorg-browse.ui +3 -1
@@ 4,7 4,9 @@
  <requires lib="adwaita" version="1.1" />
  <template class="VorgBrowse" parent="GtkBox">
    <child>
      <object class="GtkFlowBox" id="browse_flowbox"></object>
      <object class="GtkFlowBox" id="browse_flowbox">
        <property name="selection-mode">single</property>
      </object>
    </child>
  </template>
</interface>
\ No newline at end of file

M src/vorg-edit.c => src/vorg-edit.c +0 -7
@@ 76,12 76,6 @@ vorg_edit_init (VorgEdit *self)
}

static void
vorg_edit_finalize (GObject *object)
{
  G_OBJECT_CLASS (vorg_edit_parent_class)->finalize (object);
}

static void
vorg_edit_get_property (GObject *obj, guint prop_id, GValue *value,
                        GParamSpec *pspec)
{


@@ 141,7 135,6 @@ vorg_edit_class_init (VorgEditClass *klass)
#include "vorg-edit.resource"
#undef TOKEN

  gobject_class->finalize = vorg_edit_finalize;
  gobject_class->get_property = vorg_edit_get_property;
  gobject_class->set_property = vorg_edit_set_property;


M src/vorg-multi-entry.c => src/vorg-multi-entry.c +3 -3
@@ 196,12 196,12 @@ vorg_multi_entry_init (VorgMultiEntry *self)
}

static void
vorg_multi_entry_finalize (GObject *object)
vorg_multi_entry_dispose (GObject *object)
{
  VorgMultiEntry *self = VORG_MULTI_ENTRY (object);
  g_object_unref (self->store);

  G_OBJECT_CLASS (vorg_multi_entry_parent_class)->finalize (object);
  G_OBJECT_CLASS (vorg_multi_entry_parent_class)->dispose (object);
}

static void


@@ 255,7 255,7 @@ vorg_multi_entry_class_init (VorgMultiEntryClass *klass)
#include "vorg-multi-entry.resource"
#undef TOKEN

  gobject_class->finalize = vorg_multi_entry_finalize;
  gobject_class->dispose = vorg_multi_entry_dispose;
  gobject_class->get_property = vorg_multi_entry_get_property;
  gobject_class->set_property = vorg_multi_entry_set_property;


M src/vorg-repo.c => src/vorg-repo.c +12 -4
@@ 76,13 76,20 @@ vorg_repo_init (VorgRepo *self)
}

static void
vorg_repo_finalize (GObject *object)
vorg_repo_dispose (GObject *object)
{
  VorgRepo *self = VORG_REPO (object);
  g_clear_object (&self->db);
  g_clear_object (&self->store);
  g_clear_object (&self->current_file);

  g_clear_pointer (&self->db, g_object_unref);
  g_clear_pointer (&self->store, g_object_unref);
  g_clear_pointer (&self->current_file, g_object_unref);
  G_OBJECT_CLASS (vorg_repo_parent_class)->dispose (object);
}

static void
vorg_repo_finalize (GObject *object)
{
  VorgRepo *self = VORG_REPO (object);
  g_clear_pointer (&self->current_sha, g_free);

  G_OBJECT_CLASS (vorg_repo_parent_class)->finalize (object);


@@ 120,6 127,7 @@ vorg_repo_class_init (VorgRepoClass *klass)
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);

  gobject_class->finalize = vorg_repo_finalize;
  gobject_class->dispose = vorg_repo_dispose;
  gobject_class->get_property = vorg_repo_get_property;
  gobject_class->set_property = vorg_repo_set_property;


M src/vorg-store.c => src/vorg-store.c +5 -5
@@ 72,13 72,13 @@ vorg_store_init (VorgStore *self)
}

static void
vorg_store_finalize (GObject *object)
vorg_store_dispose (GObject *object)
{
  VorgStore *self = VORG_STORE (object);

  g_clear_pointer (&self->store, g_object_unref);
  g_clear_object (&self->store);

  G_OBJECT_CLASS (vorg_store_parent_class)->finalize (object);
  G_OBJECT_CLASS (vorg_store_parent_class)->dispose (object);
}

static void


@@ 111,7 111,7 @@ vorg_store_class_init (VorgStoreClass *klass)
{
  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);

  gobject_class->finalize = vorg_store_finalize;
  gobject_class->dispose = vorg_store_dispose;
  gobject_class->get_property = vorg_store_get_property;
  gobject_class->set_property = vorg_store_set_property;



@@ 220,7 220,7 @@ vorg_store_get_cache_home ()
 */
gchar *
vorg_store_get_path_from_sha (VorgStore *self, const gchar *sha,
                             const gchar *ext)
                              const gchar *ext)
{
  gchar lead[3] = { sha[0], sha[1], '\0' };
  g_autofree gchar *store_path = g_file_get_path (self->store);

M src/vorg-video.c => src/vorg-video.c +0 -1
@@ 65,7 65,6 @@ static void
vorg_video_finalize (GObject *object)
{
  VorgVideo *self = VORG_VIDEO (object);

  g_clear_pointer (&self->path, g_free);
  g_clear_pointer (&self->thumbnail, g_free);


M src/vorg-window.c => src/vorg-window.c +0 -7
@@ 63,12 63,6 @@ vorg_window_init (VorgWindow *self)
}

static void
vorg_window_finalize (GObject *object)
{
  G_OBJECT_CLASS (vorg_window_parent_class)->finalize (object);
}

static void
vorg_window_get_property (GObject *obj, guint prop_id, GValue *value,
                          GParamSpec *pspec)
{


@@ 122,7 116,6 @@ vorg_window_class_init (VorgWindowClass *klass)
#include "vorg-window.resource"
#undef TOKEN

  gobject_class->finalize = vorg_window_finalize;
  gobject_class->get_property = vorg_window_get_property;
  gobject_class->set_property = vorg_window_set_property;