[evolution-data-server] Add error checks around factory subprocess backend loading
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Add error checks around factory subprocess backend loading
- Date: Thu, 28 Apr 2016 12:57:19 +0000 (UTC)
commit a722c400b0e6f3edd06e390f292a1c3ee859d822
Author: Milan Crha <mcrha redhat com>
Date: Thu Apr 28 14:55:58 2016 +0200
Add error checks around factory subprocess backend loading
Instead of crashing, report errors to the caller.
.../libedata-book/e-subprocess-book-factory.c | 10 ++++++----
calendar/libedata-cal/e-subprocess-cal-factory.c | 10 ++++++----
libebackend/e-subprocess-factory.c | 17 +++++++++++++----
3 files changed, 25 insertions(+), 12 deletions(-)
---
diff --git a/addressbook/libedata-book/e-subprocess-book-factory.c
b/addressbook/libedata-book/e-subprocess-book-factory.c
index bef12d6..ae4beea 100644
--- a/addressbook/libedata-book/e-subprocess-book-factory.c
+++ b/addressbook/libedata-book/e-subprocess-book-factory.c
@@ -123,19 +123,21 @@ subprocess_book_factory_ref_backend (ESourceRegistry *registry,
ESource *source,
const gchar *backend_factory_type_name)
{
- EBookBackend *backend;
EBookBackendFactoryClass *backend_factory_class;
GType backend_factory_type;
backend_factory_type = g_type_from_name (backend_factory_type_name);
+ if (!backend_factory_type)
+ return NULL;
+
backend_factory_class = g_type_class_ref (backend_factory_type);
+ if (!backend_factory_class)
+ return NULL;
- backend = g_object_new (
+ return g_object_new (
backend_factory_class->backend_type,
"registry", registry,
"source", source, NULL);
-
- return E_BACKEND (backend);
}
static void
diff --git a/calendar/libedata-cal/e-subprocess-cal-factory.c
b/calendar/libedata-cal/e-subprocess-cal-factory.c
index a0288ac..8d94929 100644
--- a/calendar/libedata-cal/e-subprocess-cal-factory.c
+++ b/calendar/libedata-cal/e-subprocess-cal-factory.c
@@ -97,20 +97,22 @@ subprocess_cal_factory_ref_backend (ESourceRegistry *registry,
ESource *source,
const gchar *backend_factory_type_name)
{
- ECalBackend *backend;
ECalBackendFactoryClass *backend_factory_class;
GType backend_factory_type;
backend_factory_type = g_type_from_name (backend_factory_type_name);
+ if (!backend_factory_type)
+ return NULL;
+
backend_factory_class = g_type_class_ref (backend_factory_type);
+ if (!backend_factory_class)
+ return NULL;
- backend = g_object_new (
+ return g_object_new (
backend_factory_class->backend_type,
"kind", backend_factory_class->component_kind,
"registry", registry,
"source", source, NULL);
-
- return E_BACKEND (backend);
}
static void
diff --git a/libebackend/e-subprocess-factory.c b/libebackend/e-subprocess-factory.c
index 8a935ae..d59d9bc 100644
--- a/libebackend/e-subprocess-factory.c
+++ b/libebackend/e-subprocess-factory.c
@@ -267,13 +267,19 @@ e_subprocess_factory_ref_initable_backend (ESubprocessFactory *subprocess_factor
backend = g_hash_table_lookup (priv->backends, uid);
if (backend != NULL) {
g_object_ref (backend);
-
goto exit;
}
module = g_hash_table_lookup (priv->modules, module_filename);
if (module == NULL) {
module = e_module_load_file (module_filename);
+ if (!module) {
+ g_set_error (
+ error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
+ _("Module '%s' for source UID '%s' cannot be loaded"), module_filename, uid);
+ goto exit;
+ }
+
g_hash_table_insert (priv->modules, g_strdup (module_filename), module);
}
@@ -288,11 +294,14 @@ e_subprocess_factory_ref_initable_backend (ESubprocessFactory *subprocess_factor
class = E_SUBPROCESS_FACTORY_GET_CLASS (subprocess_factory);
- backend = class->ref_backend (
- registry, source, backend_factory_type_name);
+ backend = class->ref_backend (registry, source, backend_factory_type_name);
- if (backend == NULL)
+ if (backend == NULL) {
+ g_set_error (
+ error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
+ _("Failed to create backend of type '%s' for source UID '%s'"),
backend_factory_type_name, uid);
goto exit;
+ }
if (G_IS_INITABLE (backend)) {
GInitable *initable = G_INITABLE (backend);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]