Kaydet (Commit) 4b1e4056 authored tarafından Nick Treleaven's avatar Nick Treleaven

Fix redo, reload commands.

Fix focusing editor on notebook tab click.
Minor formatting and use NZV, DOC_FILENAME macros.
Make doc_at() debug function check idx is within range.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/branches/document-pointer@2702 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 57b3fb52
...@@ -292,7 +292,7 @@ on_redo1_activate (GtkMenuItem *menuitem, ...@@ -292,7 +292,7 @@ on_redo1_activate (GtkMenuItem *menuitem,
gpointer user_data) gpointer user_data)
{ {
GeanyDocument *doc = document_get_current(); GeanyDocument *doc = document_get_current();
if (doc == NULL && (document_can_redo(doc))) if (doc != NULL && document_can_redo(doc))
document_redo(doc); document_redo(doc);
} }
...@@ -329,7 +329,7 @@ on_copy1_activate (GtkMenuItem *menuitem, ...@@ -329,7 +329,7 @@ on_copy1_activate (GtkMenuItem *menuitem,
if (GTK_IS_EDITABLE(focusw)) if (GTK_IS_EDITABLE(focusw))
gtk_editable_copy_clipboard(GTK_EDITABLE(focusw)); gtk_editable_copy_clipboard(GTK_EDITABLE(focusw));
else else
if (IS_SCINTILLA(focusw) && doc!= NULL) if (IS_SCINTILLA(focusw) && doc != NULL)
sci_copy(doc->sci); sci_copy(doc->sci);
else else
if (GTK_IS_TEXT_VIEW(focusw)) if (GTK_IS_TEXT_VIEW(focusw))
...@@ -1952,8 +1952,7 @@ on_context_action1_activate (GtkMenuItem *menuitem, ...@@ -1952,8 +1952,7 @@ on_context_action1_activate (GtkMenuItem *menuitem,
/* use the filetype specific command if available, fallback to global command otherwise */ /* use the filetype specific command if available, fallback to global command otherwise */
if (doc->file_type != NULL && if (doc->file_type != NULL &&
doc->file_type->context_action_cmd != NULL && NZV(doc->file_type->context_action_cmd))
*doc->file_type->context_action_cmd != '\0')
{ {
command = g_strdup(doc->file_type->context_action_cmd); command = g_strdup(doc->file_type->context_action_cmd);
} }
......
...@@ -657,7 +657,7 @@ GeanyDocument *document_new_file(const gchar *filename, GeanyFiletype *ft, const ...@@ -657,7 +657,7 @@ GeanyDocument *document_new_file(const gchar *filename, GeanyFiletype *ft, const
} }
msgwin_status_add(_("New file \"%s\" opened."), msgwin_status_add(_("New file \"%s\" opened."),
(doc->file_name != NULL) ? doc->file_name : GEANY_STRING_UNTITLED); DOC_FILENAME(doc));
return doc; return doc;
} }
...@@ -1234,7 +1234,7 @@ gboolean document_reload_file(GeanyDocument *doc, const gchar *forced_enc) ...@@ -1234,7 +1234,7 @@ gboolean document_reload_file(GeanyDocument *doc, const gchar *forced_enc)
gint pos = 0; gint pos = 0;
GeanyDocument *new_doc; GeanyDocument *new_doc;
if (doc != NULL) if (doc == NULL)
return FALSE; return FALSE;
/* try to set the cursor to the position before reloading */ /* try to set the cursor to the position before reloading */
...@@ -2467,7 +2467,7 @@ GdkColor *document_get_status_color(GeanyDocument *doc) ...@@ -2467,7 +2467,7 @@ GdkColor *document_get_status_color(GeanyDocument *doc)
#ifdef GEANY_DEBUG #ifdef GEANY_DEBUG
GeanyDocument *doc_at(gint idx) GeanyDocument *doc_at(gint idx)
{ {
return (idx >= 0) ? documents[idx] : NULL; return (idx >= 0 && idx < (gint) documents_array->len) ? documents[idx] : NULL;
} }
#endif #endif
......
...@@ -81,7 +81,7 @@ static void focus_sci(GtkWidget *widget, gpointer user_data) ...@@ -81,7 +81,7 @@ static void focus_sci(GtkWidget *widget, gpointer user_data)
{ {
GeanyDocument *doc = document_get_current(); GeanyDocument *doc = document_get_current();
if (doc != NULL) if (doc == NULL)
return; return;
gtk_widget_grab_focus(GTK_WIDGET(doc->sci)); gtk_widget_grab_focus(GTK_WIDGET(doc->sci));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment