[baobab/wip/vala: 14/45] threaded scanner: avoid deprecated thread API



commit e804e0ea5fcd989811740e164f56179f6677b7b4
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Jan 5 20:01:58 2012 -0500

    threaded scanner: avoid deprecated thread API
    
    The vala bindings for GThread are out of date and not easy to fix in a
    compatible way, so add some of our own.

 src/Makefile.am                  |    1 +
 src/baobab-threaded-scanner.vala |    5 +----
 src/fixes.vapi                   |    7 +++++++
 3 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index a3ac182..0aa7da2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -15,6 +15,7 @@ bin_PROGRAMS = baobab
 
 baobab_VALAFLAGS = --pkg gtk+-3.0
 baobab_SOURCES = \
+	fixes.vapi			\
 	baobab.vapi			\
 	config.vapi			\
 	baobab-chart.c			\
diff --git a/src/baobab-threaded-scanner.vala b/src/baobab-threaded-scanner.vala
index ac0810f..5fe386e 100644
--- a/src/baobab-threaded-scanner.vala
+++ b/src/baobab-threaded-scanner.vala
@@ -225,10 +225,7 @@ namespace Baobab {
 			// the thread owns a reference on the Scanner object
 			this.self = this;
 
-			try {
-				Thread.create<void*> (scan_in_thread, false);
-			} catch {
-			}
+			new GLib2.Thread ("scanner", scan_in_thread);
 
 			Timeout.add (100, process_results);
 		}
diff --git a/src/fixes.vapi b/src/fixes.vapi
new file mode 100644
index 0000000..facf725
--- /dev/null
+++ b/src/fixes.vapi
@@ -0,0 +1,7 @@
+[CCode (cprefix = "G", gir_namespace = "Gio", gir_version = "2.0", lower_case_cprefix = "g_")]
+namespace GLib2 {
+	public class Thread {
+		public delegate void* ThreadFunc ();
+		public Thread (string thread_name, ThreadFunc func);
+	}
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]