~kaihengfeng/unity/lp1292830

« back to all changes in this revision

Viewing changes to UnityCore/GnomeSessionManager.cpp

GnomeSessionManager: add gcancellable to instance and use it for calls with temporary proxies

This fixes various crashes when the session manager is destroyed while a temporary proxy
call is still in progress, and the callback is called afterwards.

Approved by: Eleni Maria Stea

Show diffs side-by-side

added added

removed removed

Lines of Context:
130
130
 
131
131
        glib::Variant tmp(g_variant_get_child_value(variant, 1), glib::StealRef());
132
132
        SetupLogin1Proxy(tmp.GetObjectPath());
133
 
      });
 
133
      }, cancellable_);
134
134
    }
135
135
  }
136
136
 
424
424
 
425
425
    if (cb)
426
426
      cb(ret, e);
427
 
  });
 
427
  }, cancellable_);
428
428
}
429
429
 
430
430
void GnomeManager::Impl::CallUPowerMethod(std::string const& method, glib::DBusProxy::ReplyCallback const& cb)
443
443
    {
444
444
      cb(ret);
445
445
    }
446
 
  });
 
446
  }, cancellable_);
447
447
}
448
448
 
449
449
void GnomeManager::Impl::CallLogindMethod(std::string const& method, GVariant* parameters, glib::DBusProxy::CallFinishedCallback const& cb)
465
465
    {
466
466
      cb(ret, e);
467
467
    }
468
 
  });
 
468
  }, cancellable_);
469
469
}
470
470
 
471
471
void GnomeManager::Impl::CallConsoleKitMethod(std::string const& method, GVariant* parameters)
482
482
    {
483
483
      LOG_ERROR(logger) << "Fallback call failed: " << e.Message();
484
484
    }
485
 
  });
 
485
  }, cancellable_);
486
486
}
487
487
 
488
488
void GnomeManager::Impl::CallDisplayManagerSeatMethod(std::string const& method, GVariant* parameters)
499
499
    {
500
500
      LOG_ERROR(logger) << "DisplayManager Seat call failed: " << e.Message();
501
501
    }
502
 
  });
 
502
  }, cancellable_);
503
503
}
504
504
 
505
505
void GnomeManager::Impl::LockScreen(bool prompt)
552
552
  glib::Variant inhibitors(g_dbus_connection_call_sync(bus, test_mode_ ? testing::DBUS_NAME.c_str() : "org.gnome.SessionManager",
553
553
                                                       "/org/gnome/SessionManager", "org.gnome.SessionManager",
554
554
                                                       "IsInhibited", g_variant_new("(u)", Inhibited::LOGOUT), nullptr,
555
 
                                                       G_DBUS_CALL_FLAGS_NONE, 500, nullptr, &error));
 
555
                                                       G_DBUS_CALL_FLAGS_NONE, 500, cancellable_, &error));
556
556
 
557
557
  if (error)
558
558
  {
600
600
  glib::Variant user_path(g_dbus_connection_call_sync(bus, "org.freedesktop.Accounts",
601
601
                                                      "/org/freedesktop/Accounts", "org.freedesktop.Accounts",
602
602
                                                      "FindUserByName", g_variant_new("(s)",g_get_user_name()), nullptr,
603
 
                                                      G_DBUS_CALL_FLAGS_NONE, 500, nullptr, &error));
 
603
                                                      G_DBUS_CALL_FLAGS_NONE, 500, cancellable_, &error));
604
604
 
605
605
  if (error)
606
606
  {
611
611
  glib::Variant autologin(g_dbus_connection_call_sync(bus, "org.freedesktop.Accounts",
612
612
                                                      user_path.GetObjectPath().c_str(), "org.freedesktop.DBus.Properties",
613
613
                                                      "Get", g_variant_new("(ss)", "org.freedesktop.Accounts.User", "AutomaticLogin"), nullptr,
614
 
                                                      G_DBUS_CALL_FLAGS_NONE, 500, nullptr, &error));
 
614
                                                      G_DBUS_CALL_FLAGS_NONE, 500, cancellable_, &error));
615
615
 
616
616
  if (error)
617
617
  {