Changeset 14112


Ignore:
Timestamp:
Jul 8, 2013, 7:34:58 PM (9 years ago)
Author:
jordan
Message:

fix a minor GAppInfo memory leak in transmission-gtk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/main.c

    r14018 r14112  
    294294***/
    295295
     296static gboolean
     297has_magnet_link_handler (void)
     298{
     299  GAppInfo * app_info = g_app_info_get_default_for_uri_scheme ("magnet");
     300  const gboolean has_handler = app_info != NULL;
     301  g_clear_object (&app_info);
     302  return has_handler;
     303}
     304
    296305static void
    297306register_magnet_link_handler (void)
    298307{
    299   GAppInfo * app_info = g_app_info_get_default_for_uri_scheme ("magnet");
    300   if (app_info == NULL)
    301     {
    302       /* there's no default magnet handler, so register ourselves for the job... */
    303       GError * error = NULL;
    304       app_info = g_app_info_create_from_commandline ("transmission-gtk", "transmission-gtk", G_APP_INFO_CREATE_SUPPORTS_URIS, NULL);
    305       g_app_info_set_as_default_for_type (app_info, "x-scheme-handler/magnet", &error);
    306       if (error != NULL)
    307         {
    308           g_warning (_("Error registering Transmission as x-scheme-handler/magnet handler: %s"), error->message);
    309           g_clear_error (&error);
    310         }
    311     }
     308  GError * error;
     309  GAppInfo * app;
     310  const char * const content_type = "x-scheme-handler/magnet";
     311
     312  error = NULL;
     313  app = g_app_info_create_from_commandline ("transmission-gtk",
     314                                            "transmission-gtk",
     315                                            G_APP_INFO_CREATE_SUPPORTS_URIS,
     316                                            &error);
     317  g_app_info_set_as_default_for_type (app, content_type, &error);
     318  if (error != NULL)
     319    {
     320      g_warning (_("Error registering Transmission as a %s handler: %s"),
     321                 content_type,
     322                 error->message);
     323      g_error_free (error);
     324    }
     325
     326  g_clear_object (&app);
     327}
     328static void
     329ensure_magnet_handler_exists (void)
     330{
     331  if (!has_magnet_link_handler ())
     332    register_magnet_link_handler ();
    312333}
    313334
     
    530551
    531552  /* if there's no magnet link handler registered, register us */
    532   register_magnet_link_handler ();
     553  ensure_magnet_handler_exists ();
    533554}
    534555
Note: See TracChangeset for help on using the changeset viewer.