Changeset 13811


Ignore:
Timestamp:
Jan 20, 2013, 4:10:47 AM (8 years ago)
Author:
jordan
Message:

(gtk) silence a couple of potential GFileInfo console warnings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/tr-core.c

    r13797 r13811  
    647647get_file_mtime (GFile * file)
    648648{
    649   time_t mtime;
    650   GFileInfo * info = g_file_query_info (file, G_FILE_ATTRIBUTE_TIME_MODIFIED, 0, NULL, NULL);
    651   mtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
    652   g_object_unref (G_OBJECT (info));
     649  GFileInfo * info;
     650  time_t mtime = 0;
     651
     652  info = g_file_query_info (file, G_FILE_ATTRIBUTE_TIME_MODIFIED, 0, NULL, NULL);
     653  if (info != NULL)
     654    {
     655      mtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
     656      g_object_unref (G_OBJECT (info));
     657    }
     658
    653659  return mtime;
    654660}
     
    657663rename_torrent_and_unref_file (GFile * file)
    658664{
    659   GError * error = NULL;
    660   GFileInfo * info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME, 0, NULL, NULL);
    661   const char * old_name = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME);
    662   char * new_name = g_strdup_printf ("%s.added", old_name);
    663   GFile * new_file = g_file_set_display_name (file, new_name, NULL, &error);
    664   if (error != NULL)
    665     g_message ("Unable to rename \"%s\" as \"%s\": %s", old_name, new_name, error->message);
    666   if (new_file != NULL)
    667     g_object_unref (G_OBJECT (new_file));
    668   g_free (new_name);
    669   g_object_unref (G_OBJECT (info));
    670   g_object_unref (G_OBJECT (file));
    671   g_clear_error (&error);
     665  GFileInfo * info;
     666
     667  info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME, 0, NULL, NULL);
     668  if (info != NULL)
     669    {
     670      GError * error;
     671      const char * old_name;
     672      char * new_name;
     673      GFile * new_file;
     674
     675      old_name = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME);
     676      new_name = g_strdup_printf ("%s.added", old_name);
     677      new_file = g_file_set_display_name (file, new_name, NULL, &error);
     678
     679      if (error != NULL)
     680        {
     681          g_message ("Unable to rename \"%s\" as \"%s\": %s", old_name, new_name, error->message);
     682          g_error_free (error);
     683        }
     684
     685      if (new_file != NULL)
     686        g_object_unref (G_OBJECT (new_file));
     687      g_free (new_name);
     688      g_object_unref (G_OBJECT(info));
     689    }
     690
     691  g_object_unref (G_OBJECT(file));
    672692}
    673693
Note: See TracChangeset for help on using the changeset viewer.