SF.net SVN: geany: [2697] branches/document-pointer
eht16 at users.sourceforge.net
eht16 at xxxxx
Mon Jun 16 18:32:05 UTC 2008
Revision: 2697
http://geany.svn.sourceforge.net/geany/?rev=2697&view=rev
Author: eht16
Date: 2008-06-16 11:31:59 -0700 (Mon, 16 Jun 2008)
Log Message:
-----------
Fix wrong and add missing checks.
Modified Paths:
--------------
branches/document-pointer/ChangeLog
branches/document-pointer/src/callbacks.c
branches/document-pointer/src/document.c
branches/document-pointer/src/encodings.c
branches/document-pointer/src/prefs.c
branches/document-pointer/src/search.c
Modified: branches/document-pointer/ChangeLog
===================================================================
--- branches/document-pointer/ChangeLog 2008-06-15 17:57:57 UTC (rev 2696)
+++ branches/document-pointer/ChangeLog 2008-06-16 18:31:59 UTC (rev 2697)
@@ -1,3 +1,10 @@
+2008-06-16 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
+
+ * src/encodings.c, src/prefs.c, src/callbacks.c, src/search.c,
+ src/document.c:
+ Fix wrong and add missing checks.
+
+
2008-06-15 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/*:
Modified: branches/document-pointer/src/callbacks.c
===================================================================
--- branches/document-pointer/src/callbacks.c 2008-06-15 17:57:57 UTC (rev 2696)
+++ branches/document-pointer/src/callbacks.c 2008-06-16 18:31:59 UTC (rev 2697)
@@ -971,8 +971,8 @@
if (! ignore_callback)
{
GeanyDocument *doc = document_get_current();
- if (doc == NULL) return;
- editor_set_line_wrapping(doc, ! doc->line_wrapping);
+ if (doc != NULL)
+ editor_set_line_wrapping(doc, ! doc->line_wrapping);
}
}
@@ -984,7 +984,8 @@
if (! ignore_callback)
{
GeanyDocument *doc = document_get_current();
- if (doc == NULL) return;
+ if (doc == NULL)
+ return;
doc->readonly = ! doc->readonly;
sci_set_readonly(doc->sci, doc->readonly);
ui_update_tab_status(doc);
@@ -1000,8 +1001,8 @@
if (! ignore_callback)
{
GeanyDocument *doc = document_get_current();
- if (doc == NULL) return;
- doc->auto_indent = ! doc->auto_indent;
+ if (doc != NULL)
+ doc->auto_indent = ! doc->auto_indent;
}
}
@@ -1014,7 +1015,8 @@
gchar *search_text;
GeanyDocument *doc = document_get_current();
- if (doc == NULL) return;
+ if (doc == NULL)
+ return;
if (sci_can_copy(doc->sci))
{ /* take selected text if there is a selection */
@@ -1041,7 +1043,7 @@
GTK_MENU_ITEM(lookup_widget(main_widgets.editor_menu, "goto_tag_definition1")));
GeanyDocument *doc = document_get_current();
- g_return_if_fail(doc);
+ g_return_if_fail(doc != NULL);
sci_set_current_position(doc->sci, editor_info.click_pos, FALSE);
symbols_goto_tag(editor_info.current_word, definition);
@@ -1632,7 +1634,8 @@
{
GeanyDocument *doc = document_get_current();
- if (doc == NULL) return;
+ if (doc == NULL)
+ return;
if (doc->readonly)
{
utils_beep();
@@ -2062,6 +2065,9 @@
{
GeanyDocument *doc = document_get_current();
+ if (doc == NULL || ignore_callback)
+ return;
+
editor_set_use_tabs(doc, TRUE);
ui_update_statusbar(doc, -1);
}
@@ -2073,6 +2079,9 @@
{
GeanyDocument *doc = document_get_current();
+ if (doc == NULL || ignore_callback)
+ return;
+
editor_set_use_tabs(doc, FALSE);
ui_update_statusbar(doc, -1);
}
@@ -2084,6 +2093,9 @@
{
GeanyDocument *doc = document_get_current();
+ if (doc == NULL || ignore_callback)
+ return;
+
editor_strip_trailing_spaces(doc);
}
@@ -2133,7 +2145,7 @@
return;
doc = document_get_current();
- g_return_if_fail(doc);
+ g_return_if_fail(doc != NULL);
doc->line_breaking = !doc->line_breaking;
}
Modified: branches/document-pointer/src/document.c
===================================================================
--- branches/document-pointer/src/document.c 2008-06-15 17:57:57 UTC (rev 2696)
+++ branches/document-pointer/src/document.c 2008-06-16 18:31:59 UTC (rev 2697)
@@ -195,11 +195,12 @@
{
guint i;
- if (! sci) return NULL;
+ if (sci == NULL)
+ return NULL;
for (i = 0; i < documents_array->len; i++)
{
- if (documents[i]->index == -1 && documents[i]->sci == sci)
+ if (documents[i]->index != -1 && documents[i]->sci == sci)
return documents[i];
}
return NULL;
@@ -209,7 +210,8 @@
/* returns the index of the notebook page from the document index */
gint document_get_notebook_page(GeanyDocument *doc)
{
- if (doc == NULL) return -1;
+ if (doc == NULL)
+ return -1;
return gtk_notebook_page_num(GTK_NOTEBOOK(main_widgets.notebook),
GTK_WIDGET(doc->sci));
@@ -455,14 +457,13 @@
gchar *fname;
GeanyDocument *this;
gint new_idx;
- gint tabnum;
gint cur_pages = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
if (cur_pages == 1)
{
GeanyDocument *doc = document_get_current();
/* remove the empty document and open a new one */
- if (doc->file_name == NULL && ! doc->changed)
+ if (doc != NULL && doc->file_name == NULL && ! doc->changed)
document_remove_page(0);
}
@@ -491,7 +492,7 @@
treeviews_openfiles_add(this); /* sets this->iter */
- tabnum = notebook_new_tab(this);
+ notebook_new_tab(this);
/* select document in sidebar */
{
@@ -2244,7 +2245,8 @@
Document *fdoc = DOCUMENT(doc);
undo_action *action;
- if (doc == NULL) return;
+ if (doc == NULL)
+ return;
action = g_new0(undo_action, 1);
action->type = type;
@@ -2264,7 +2266,8 @@
{
Document *fdoc = DOCUMENT(doc);
- if (doc == NULL) return FALSE;
+ if (doc == NULL)
+ return FALSE;
if (g_trash_stack_height(&fdoc->undo_actions) > 0 || sci_can_undo(doc->sci))
return TRUE;
@@ -2290,7 +2293,8 @@
Document *fdoc = DOCUMENT(doc);
undo_action *action;
- if (doc == NULL) return;
+ if (doc == NULL)
+ return;
action = g_trash_stack_pop(&fdoc->undo_actions);
@@ -2349,7 +2353,8 @@
{
Document *fdoc = DOCUMENT(doc);
- if (doc == NULL) return FALSE;
+ if (doc == NULL)
+ return FALSE;
if (g_trash_stack_height(&fdoc->redo_actions) > 0 || sci_can_redo(doc->sci))
return TRUE;
@@ -2363,7 +2368,8 @@
Document *fdoc = DOCUMENT(doc);
undo_action *action;
- if (doc == NULL) return;
+ if (doc == NULL)
+ return;
action = g_trash_stack_pop(&fdoc->redo_actions);
@@ -2655,8 +2661,10 @@
gchar *locale_filename;
gboolean ret = FALSE;
- if (file_prefs.disk_check_timeout == 0) return FALSE;
- if (doc == NULL) return FALSE;
+ if (file_prefs.disk_check_timeout == 0)
+ return FALSE;
+ if (doc == NULL)
+ return FALSE;
/* ignore documents that have never been saved to disk */
if (doc->real_path == NULL) return FALSE;
Modified: branches/document-pointer/src/encodings.c
===================================================================
--- branches/document-pointer/src/encodings.c 2008-06-15 17:57:57 UTC (rev 2696)
+++ branches/document-pointer/src/encodings.c 2008-06-16 18:31:59 UTC (rev 2697)
@@ -234,15 +234,21 @@
void encodings_select_radio_item(const gchar *charset)
{
gint i;
+
+ if (ignore_callback)
+ return;
+
g_return_if_fail(charset != NULL);
i = 0;
while (i < GEANY_ENCODINGS_MAX)
{
- if (utils_str_equal(charset, encodings[i].charset)) break;
+ if (utils_str_equal(charset, encodings[i].charset))
+ break;
i++;
}
- if (i == GEANY_ENCODINGS_MAX) i = GEANY_ENCODING_UTF_8; /* fallback to UTF-8 */
+ if (i == GEANY_ENCODINGS_MAX)
+ i = GEANY_ENCODING_UTF_8; /* fallback to UTF-8 */
/* ignore_callback has to be set by the caller */
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(radio_items[i]), TRUE);
Modified: branches/document-pointer/src/prefs.c
===================================================================
--- branches/document-pointer/src/prefs.c 2008-06-15 17:57:57 UTC (rev 2696)
+++ branches/document-pointer/src/prefs.c 2008-06-16 18:31:59 UTC (rev 2697)
@@ -1058,7 +1058,8 @@
}
case 2:
{
- if (strcmp(fontbtn, interface_prefs.msgwin_font) == 0) break;
+ if (strcmp(fontbtn, interface_prefs.msgwin_font) == 0)
+ break;
g_free(interface_prefs.msgwin_font);
interface_prefs.msgwin_font = g_strdup(fontbtn);
ui_widget_modify_font_from_string(msgwindow.tree_compiler, interface_prefs.msgwin_font);
Modified: branches/document-pointer/src/search.c
===================================================================
--- branches/document-pointer/src/search.c 2008-06-15 17:57:57 UTC (rev 2696)
+++ branches/document-pointer/src/search.c 2008-06-16 18:31:59 UTC (rev 2697)
@@ -234,7 +234,7 @@
GtkClipboard *clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
#endif
- g_return_if_fail(doc == NULL);
+ g_return_if_fail(doc != NULL);
#ifdef G_OS_UNIX
s=gtk_clipboard_wait_for_text(clipboard);
@@ -1408,7 +1408,8 @@
for (i = 0; i < documents_array->len; i++)
{
if (DOC_VALID(documents[i]))
- if (find_document_usage(documents[i], search_text, flags) > 0) found = TRUE;
+ if (find_document_usage(documents[i], search_text, flags) > 0)
+ found = TRUE;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list