[gnome-builder] libide: handle NULL source language a bit more gracefully
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide: handle NULL source language a bit more gracefully
- Date: Mon, 23 Mar 2015 23:49:54 +0000 (UTC)
commit 48702d3647ab8366e0d41a76f3437f63dc934dc7
Author: Christian Hergert <christian hergert me>
Date: Mon Mar 2 23:24:32 2015 -0800
libide: handle NULL source language a bit more gracefully
libide/gca/ide-gca-service.c | 14 ++++++++++++--
libide/ide-language.c | 9 ++++++---
libide/ide-source-view.c | 3 ++-
3 files changed, 20 insertions(+), 6 deletions(-)
---
diff --git a/libide/gca/ide-gca-service.c b/libide/gca/ide-gca-service.c
index 08a50c0..d9a2c04 100644
--- a/libide/gca/ide-gca-service.c
+++ b/libide/gca/ide-gca-service.c
@@ -35,7 +35,8 @@ G_DEFINE_TYPE (IdeGcaService, ide_gca_service, IDE_TYPE_SERVICE)
static const gchar *
remap_language (const gchar *lang_id)
{
- g_return_val_if_fail (lang_id, NULL);
+ if (!lang_id)
+ return NULL;
if (g_str_equal (lang_id, "chdr") ||
g_str_equal (lang_id, "objc") ||
@@ -94,9 +95,18 @@ ide_gca_service_get_proxy_async (IdeGcaService *self,
g_return_if_fail (language_id);
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
+ task = g_task_new (self, cancellable, callback, user_data);
+
language_id = remap_language (language_id);
- task = g_task_new (self, cancellable, callback, user_data);
+ if (!language_id)
+ {
+ g_task_return_new_error (task,
+ G_IO_ERROR,
+ G_IO_ERROR_FAILED,
+ _("No language specified"));
+ return;
+ }
if (!gDBus)
{
diff --git a/libide/ide-language.c b/libide/ide-language.c
index 0b08782..150f2e6 100644
--- a/libide/ide-language.c
+++ b/libide/ide-language.c
@@ -61,13 +61,16 @@ ide_language_get_source_language (IdeLanguage *self)
{
IdeLanguagePrivate *priv = ide_language_get_instance_private (self);
GtkSourceLanguageManager *languages;
- GtkSourceLanguage *language;
+ GtkSourceLanguage *language = NULL;
if (IDE_LANGUAGE_GET_CLASS (self)->get_source_language)
return IDE_LANGUAGE_GET_CLASS (self)->get_source_language (self);
- languages = gtk_source_language_manager_get_default ();
- language = gtk_source_language_manager_get_language (languages, priv->id);
+ if (priv->id)
+ {
+ languages = gtk_source_language_manager_get_default ();
+ language = gtk_source_language_manager_get_language (languages, priv->id);
+ }
return language;
}
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index e2bcb1c..edca35e 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -303,7 +303,8 @@ ide_source_view_reload_snippets (IdeSourceView *self)
manager = ide_context_get_snippets_manager (context);
source_language = gtk_source_buffer_get_language (GTK_SOURCE_BUFFER (priv->buffer));
- snippets = ide_source_snippets_manager_get_for_language (manager, source_language);
+ if (source_language != NULL)
+ snippets = ide_source_snippets_manager_get_for_language (manager, source_language);
}
g_object_set (priv->snippets_provider, "snippets", snippets, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]