[anjuta] snippet-manager: Fixed crash for inserting in Scintilla



commit 813c6873a513f394317ab4b1c05da9a739de8827
Author: Dragos Dena <dragos dena gmail com>
Date:   Thu Aug 12 03:50:44 2010 +0300

    snippet-manager: Fixed crash for inserting in Scintilla

 plugins/snippets-manager/snippet.c                 |    4 ++--
 plugins/snippets-manager/snippets-db.c             |    3 ++-
 .../snippets-interaction-interpreter.c             |   11 +++++++----
 3 files changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/plugins/snippets-manager/snippet.c b/plugins/snippets-manager/snippet.c
index 1e53dde..20b3cfc 100644
--- a/plugins/snippets-manager/snippet.c
+++ b/plugins/snippets-manager/snippet.c
@@ -1073,7 +1073,7 @@ snippet_get_default_content (AnjutaSnippet *snippet,
                              const gchar *indent)
 {
 	gchar* buffer = NULL, *temp = NULL;
-	
+
 	/* Assertions */
 	g_return_val_if_fail (ANJUTA_IS_SNIPPET (snippet), NULL);
 
@@ -1095,7 +1095,7 @@ snippet_get_default_content (AnjutaSnippet *snippet,
 	}
 
 	snippet->priv->default_computed = TRUE;
-	
+
 	return buffer;
 }
 
diff --git a/plugins/snippets-manager/snippets-db.c b/plugins/snippets-manager/snippets-db.c
index 77127a7..f64a5e0 100644
--- a/plugins/snippets-manager/snippets-db.c
+++ b/plugins/snippets-manager/snippets-db.c
@@ -867,7 +867,8 @@ snippets_db_get_snippet (SnippetsDB* snippets_db,
 	
 	/* Assertions */
 	g_return_val_if_fail (ANJUTA_IS_SNIPPETS_DB (snippets_db), NULL);
-	g_return_val_if_fail (trigger_key != NULL, NULL);
+	if (trigger_key == NULL)
+		return NULL;
 
 	/* Get the editor language if not provided */
 	if (language == NULL)
diff --git a/plugins/snippets-manager/snippets-interaction-interpreter.c b/plugins/snippets-manager/snippets-interaction-interpreter.c
index 48fc39a..6078d13 100644
--- a/plugins/snippets-manager/snippets-interaction-interpreter.c
+++ b/plugins/snippets-manager/snippets-interaction-interpreter.c
@@ -775,9 +775,12 @@ snippets_interaction_insert_snippet (SnippetsInteraction *snippets_interaction,
 	cur_line    = ianjuta_editor_get_text (priv->cur_editor, line_begin, cur_pos, NULL);
 
 	/* Calculate the current indentation */
-	indent = g_strdup (cur_line);
-	while (cur_line[i] == ' ' || cur_line[i] == '\t')
-		i ++;
+	if (cur_line != NULL)
+		indent = g_strdup (cur_line);
+	else
+		indent = g_strdup ("");
+	while (indent[i] == ' ' || indent[i] == '\t')
+		i ++;	
 	indent[i] = 0;
 
 	/* Get the default content of the snippet */
@@ -785,7 +788,7 @@ snippets_interaction_insert_snippet (SnippetsInteraction *snippets_interaction,
 	                                                       G_OBJECT (snippets_db), 
 	                                                       indent);
 	g_return_if_fail (snippet_default_content != NULL);
-	
+
 	/* Insert the default content into the editor */
 	ianjuta_document_begin_undo_action (IANJUTA_DOCUMENT (priv->cur_editor), NULL);
 	ianjuta_editor_insert (priv->cur_editor, 



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