[anjuta] language-support-cp-java: fix crasher when swapping header/source
- From: Carl-Anton Ingmarsson <carlantoni src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] language-support-cp-java: fix crasher when swapping header/source
- Date: Sun, 3 Feb 2013 20:44:58 +0000 (UTC)
commit 5345707ec012068574d4571080dac3d0fb13b787
Author: Carl-Anton Ingmarsson <ca ingmarsson gmail com>
Date: Sun Feb 3 21:43:29 2013 +0100
language-support-cp-java: fix crasher when swapping header/source
If the current document is not yet stored and therefore does not have
a corresponding GFile the code would still proceed and call functions on the
NULL pointer.
plugins/language-support-cpp-java/plugin.c | 23 +++++++++++++----------
1 files changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/plugins/language-support-cpp-java/plugin.c b/plugins/language-support-cpp-java/plugin.c
index 657264a..8f7227d 100644
--- a/plugins/language-support-cpp-java/plugin.c
+++ b/plugins/language-support-cpp-java/plugin.c
@@ -240,14 +240,20 @@ const gchar* HEADER_EXT[] =
static GFile*
language_support_get_header_file (IAnjutaEditor* editor)
{
- GFile *file = ianjuta_file_get_file (IANJUTA_FILE (editor), NULL);
- GFile *parent = g_file_get_parent (file);
- gchar *parent_uri = g_file_get_uri (parent);
- gchar *basename = g_file_get_basename (file);
+ GFile *file, *parent;
+ gchar *parent_uri, *basename, *ext;
+ GFile *ret = NULL;
+
+ file = ianjuta_file_get_file (IANJUTA_FILE (editor), NULL);
+ if (!file)
+ return NULL;
+
+ parent = g_file_get_parent (file);
+ parent_uri = g_file_get_uri (parent);
+ basename = g_file_get_basename (file);
g_object_unref (file);
g_object_unref (parent);
- gchar *ext = strstr (basename, ".");
- GFile *ret = NULL;
+ ext = strstr (basename, ".");
if (ext)
{
@@ -881,13 +887,10 @@ on_swap_activate (GtkAction* action, gpointer data)
if (!lang_plugin->current_editor || !docman)
return;
-// file = ianjuta_file_get_file (IANJUTA_FILE (lang_plugin->current_editor),
-// NULL);
-
file = language_support_get_header_file (
IANJUTA_EDITOR (lang_plugin->current_editor));
- if (g_file_query_exists (file, NULL))
+ if (file)
{
ianjuta_document_manager_goto_file_line (docman,
file,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]