[gnome-boxes] Make use of new AsyncLauncher API
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Make use of new AsyncLauncher API
- Date: Wed, 23 Mar 2016 13:45:24 +0000 (UTC)
commit 5f5508c66a39960c7b45f0998bccdc0fcb6021dd
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Wed Mar 23 12:57:08 2016 +0000
Make use of new AsyncLauncher API
This, combined with previous patches, fixes the issue of boxes not
actually getting deleted if user exits Boxes quickly after deleting the
boxes.
https://bugzilla.gnome.org/show_bug.cgi?id=761479
src/app.vala | 3 +++
src/libvirt-machine.vala | 8 ++++----
src/os-database.vala | 4 ++--
src/unattended-file.vala | 2 +-
src/util.vala | 2 +-
src/wizard.vala | 2 +-
6 files changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/src/app.vala b/src/app.vala
index de39397..841c731 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -39,12 +39,14 @@ private class Boxes.App: Gtk.Application {
private HashTable<string,CollectionSource> sources;
public GVir.Connection default_connection { owned get { return LibvirtBroker.get_default
().get_connection ("QEMU Session"); } }
public CollectionSource default_source { get { return sources.get (DEFAULT_SOURCE_NAME); } }
+ public AsyncLauncher async_launcher;
public App () {
application_id = "org.gnome.Boxes";
flags |= ApplicationFlags.HANDLES_COMMAND_LINE;
app = this;
+ async_launcher = AsyncLauncher.get_default ();
windows = new List<Boxes.AppWindow> ();
sources = new HashTable<string,CollectionSource> (str_hash, str_equal);
brokers = new HashTable<string,Broker> (str_hash, str_equal);
@@ -282,6 +284,7 @@ private class Boxes.App: Gtk.Application {
window.notificationbar.dismiss_all ();
window.wizard_window.wizard.cleanup ();
}
+ async_launcher.await_all ();
suspend_machines ();
}
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index ec4ea6d..ce72c57 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -277,7 +277,7 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
if (disk == null)
return;
- yield run_in_thread ( () => {
+ yield App.app.async_launcher.launch ( () => {
stat.disk = disk.get_stats ();
} );
var prev = stats[STATS_SIZE - 1];
@@ -299,7 +299,7 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
if (net == null)
return;
- yield run_in_thread ( () => {
+ yield App.app.async_launcher.launch ( () => {
stat.net = net.get_stats ();
} );
var prev = stats[STATS_SIZE - 1];
@@ -435,7 +435,7 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
return null;
var stream = connection.get_stream (0);
- yield run_in_thread (()=> {
+ yield App.app.async_launcher.launch (()=> {
domain.screenshot (stream, 0, 0);
});
@@ -467,7 +467,7 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
/* Run all the slow operations in a separate thread
to avoid blocking the UI */
- run_in_thread.begin ( () => {
+ App.app.async_launcher.launch.begin ( () => {
try {
// This undefines the domain, causing it to be transient if it was running
domain.delete (DomainDeleteFlags.SAVED_STATE |
diff --git a/src/os-database.vala b/src/os-database.vala
index 9d9c2ee..69df942 100644
--- a/src/os-database.vala
+++ b/src/os-database.vala
@@ -37,12 +37,12 @@ private class Boxes.OSDatabase : GLib.Object {
db_loading = true;
var loader = new Loader ();
try {
- yield run_in_thread (() => { loader.process_default_path (); });
+ yield App.app.async_launcher.launch (() => { loader.process_default_path (); });
} catch (GLib.Error e) {
warning ("Error loading default libosinfo database: %s", e.message);
}
try {
- yield run_in_thread (() => { loader.process_path (get_logos_db ()); }); // Load our custom
database
+ yield App.app.async_launcher.launch (() => { loader.process_path (get_logos_db ()); }); // Load
our custom database
} catch (GLib.Error e) {
warning ("Error loading GNOME Boxes libosinfo database: %s", e.message);
}
diff --git a/src/unattended-file.vala b/src/unattended-file.vala
index 55e8680..8aa679a 100644
--- a/src/unattended-file.vala
+++ b/src/unattended-file.vala
@@ -19,7 +19,7 @@ private interface Boxes.UnattendedFile : GLib.Object {
debug ("Copying unattended file '%s' into disk drive/image '%s'", dest_name, disk_file);
if (is_libarchive_compatible (disk_file)) {
- yield run_in_thread(() => {
+ yield App.app.async_launcher.launch(() => {
copy_with_libarchive (disk_file, source_file.get_path (), dest_name);
});
} else
diff --git a/src/util.vala b/src/util.vala
index c2c5a99..2906d70 100644
--- a/src/util.vala
+++ b/src/util.vala
@@ -252,7 +252,7 @@ namespace Boxes {
// make sure vala makes a copy of argv that will be kept alive until run_in_thread finishes
string[] argv_copy = argv;
- yield run_in_thread (() => {
+ yield AsyncLauncher.get_default ().launch (() => {
exec_sync (argv_copy, out std_output, out std_error);
});
diff --git a/src/wizard.vala b/src/wizard.vala
index b579579..b971607 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -516,7 +516,7 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
try {
var config = null as GVirConfig.Domain;
- yield run_in_thread (() => {
+ yield App.app.async_launcher.launch (() => {
config = libvirt_machine.domain.get_config (GVir.DomainXMLFlags.INACTIVE);
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]