[california] Fix critical problem with Google activator: Bug #732652
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [california] Fix critical problem with Google activator: Bug #732652
- Date: Thu, 17 Jul 2014 23:51:37 +0000 (UTC)
commit 3c66bf83e6ea7f9a74b0ca7eca39d02955b41618
Author: Jim Nelson <jim yorba org>
Date: Thu Jul 17 16:50:28 2014 -0700
Fix critical problem with Google activator: Bug #732652
Can't use Scheduled object in an async method with local variables
carried through to lambda -- reference is dropped in the interim.
.../activator-google-authenticating-pane.vala | 13 +++++--------
src/util/util-scheduled.vala | 18 ++++++++++++++++++
2 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/src/activator/google/activator-google-authenticating-pane.vala
b/src/activator/google/activator-google-authenticating-pane.vala
index cc9fbcc..026b1d7 100644
--- a/src/activator/google/activator-google-authenticating-pane.vala
+++ b/src/activator/google/activator-google-authenticating-pane.vala
@@ -49,7 +49,6 @@ public class GoogleAuthenticatingPane : Gtk.Grid, Toolkit.Card {
private Gtk.Button again_button;
private Cancellable cancellable = new Cancellable();
- private Scheduled? scheduled_jump = null;
public GoogleAuthenticatingPane() {
if (app_id == null)
@@ -87,6 +86,7 @@ public class GoogleAuthenticatingPane : Gtk.Grid, Toolkit.Card {
private async void login_async(Message credentials) {
spinner.active = true;
+ message_label.label = _("Authenticating…");
GData.ClientLoginAuthorizer authorizer = new GData.ClientLoginAuthorizer(app_id,
typeof(GData.CalendarService));
@@ -124,21 +124,18 @@ public class GoogleAuthenticatingPane : Gtk.Grid, Toolkit.Card {
else
login_failed(_("Unable to retrieve calendar list: %s").printf(err.message));
- spinner.active = false;
-
return;
}
spinner.active = false;
-
message_label.label = _("Authenticated");
// depending on network conditions, this pane can come and go quite quickly; this brief
// delay gives the user a chance to see what's transpired
- scheduled_jump = new Scheduled.once_after_msec(SUCCESS_DELAY_MSEC, () => {
- jump_to_card_by_name(GoogleCalendarListPane.ID, new GoogleCalendarListPane.Message(
- credentials.username, own_calendars, all_calendars));
- });
+ yield sleep_msec_async(SUCCESS_DELAY_MSEC);
+
+ jump_to_card_by_name(GoogleCalendarListPane.ID, new GoogleCalendarListPane.Message(
+ credentials.username, own_calendars, all_calendars));
}
private void login_failed(string msg) {
diff --git a/src/util/util-scheduled.vala b/src/util/util-scheduled.vala
index 507cc58..6f5498e 100644
--- a/src/util/util-scheduled.vala
+++ b/src/util/util-scheduled.vala
@@ -7,6 +7,24 @@
namespace California {
/**
+ * Perform an asynchronous delay for the specified number of seconds.
+*/
+public async void sleep_sec_async(uint seconds) {
+ uint id = Timeout.add_seconds(seconds, sleep_sec_async.callback);
+ yield;
+ Source.remove(id);
+}
+
+/**
+ * Perform an asynchronous delay for the specified number of milliseconds.
+*/
+public async void sleep_msec_async(uint milliseconds) {
+ uint id = Timeout.add(milliseconds, sleep_msec_async.callback);
+ yield;
+ Source.remove(id);
+}
+
+/**
* A reference-counted source ID to better control execution of Idle and Timeout callbacks in the
* event loop.
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]