[retro-gtk] core: Let init() throw errors



commit d7d3f64b1bf1da155ba322fc10aeddcebc057ee8
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Thu Jul 20 11:20:31 2017 +0200

    core: Let init() throw errors
    
    This will help to convey a failure when loading the games to the user of
    the library.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=777489

 demos/retro-demo.c  |    9 ++++++++-
 retro-gtk/core.vala |    9 ++-------
 2 files changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/demos/retro-demo.c b/demos/retro-demo.c
index 225b740..28091b7 100644
--- a/demos/retro-demo.c
+++ b/demos/retro-demo.c
@@ -28,6 +28,7 @@ retro_demo_open (GApplication  *application,
 {
   RetroDemoApplication *self;
   char *module_path;
+  GError *error = NULL;
 
   self = RETRO_DEMO_APPLICATION (application);
 
@@ -44,7 +45,13 @@ retro_demo_open (GApplication  *application,
   if (self->core == NULL)
     return;
 
-  retro_core_init (self->core);
+  retro_core_init (self->core, &error);
+  if (error != NULL) {
+    g_debug ("Couldn't initialize the Libretro core: %s", error->message);
+    g_error_free (error);
+
+    return;
+  }
 
   g_application_activate (application);
 }
diff --git a/retro-gtk/core.vala b/retro-gtk/core.vala
index c55eb74..5a909c0 100644
--- a/retro-gtk/core.vala
+++ b/retro-gtk/core.vala
@@ -255,7 +255,7 @@ public class Core : Object {
         *
         * Must be called before loading a game and running the core.
         */
-       public void init () {
+       public void init () throws Error {
                set_environment_interface ();
                push_cb_data ();
                module.init ();
@@ -265,12 +265,7 @@ public class Core : Object {
 
                is_initiated = true;
 
-               try {
-                       load_medias ();
-               }
-               catch (Error e) {
-                       debug (e.message);
-               }
+               load_medias ();
        }
 
        public extern void set_medias ([CCode (array_null_terminated = true, array_length = false)] string[] 
uris);


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