SF.net SVN: geany: [2768] branches/editor-struct
ntrel at users.sourceforge.net
ntrel at xxxxx
Fri Jul 11 14:12:08 UTC 2008
Revision: 2768
http://geany.svn.sourceforge.net/geany/?rev=2768&view=rev
Author: ntrel
Date: 2008-07-11 07:11:53 -0700 (Fri, 11 Jul 2008)
Log Message:
-----------
Create the doc->editor field in editor_create(). This means any
checks for doc->editor->scintilla != NULL will segfault for invalid
documents - check against doc->is_valid or doc->editor != NULL
instead.
Modified Paths:
--------------
branches/editor-struct/ChangeLog
branches/editor-struct/src/document.c
branches/editor-struct/src/editor.c
branches/editor-struct/src/editor.h
branches/editor-struct/src/ui_utils.c
Modified: branches/editor-struct/ChangeLog
===================================================================
--- branches/editor-struct/ChangeLog 2008-07-10 14:12:09 UTC (rev 2767)
+++ branches/editor-struct/ChangeLog 2008-07-11 14:11:53 UTC (rev 2768)
@@ -1,3 +1,12 @@
+2008-07-11 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
+
+ * src/document.c, src/editor.c, src/editor.h, src/ui_utils.c:
+ Create the doc->editor field in editor_create(). This means any
+ checks for doc->editor->scintilla != NULL will segfault for invalid
+ documents - check against doc->is_valid or doc->editor != NULL
+ instead.
+
+
2008-07-08 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/document.h, src/editor.h, src/plugindata.h:
Modified: branches/editor-struct/src/document.c
===================================================================
--- branches/editor-struct/src/document.c 2008-07-10 14:12:09 UTC (rev 2767)
+++ branches/editor-struct/src/document.c 2008-07-11 14:11:53 UTC (rev 2768)
@@ -324,23 +324,18 @@
static void init_doc_struct(GeanyDocument *new_doc)
{
Document *full_doc = DOCUMENT(new_doc);
- GeanyEditor *editor = new_doc->editor;
memset(full_doc, 0, sizeof(Document));
new_doc->is_valid = FALSE;
new_doc->has_tags = FALSE;
- editor->auto_indent = (editor_prefs.indent_mode != INDENT_NONE);
- editor->line_wrapping = editor_prefs.line_wrapping;
new_doc->readonly = FALSE;
new_doc->file_name = NULL;
new_doc->file_type = NULL;
new_doc->tm_file = NULL;
new_doc->encoding = NULL;
new_doc->has_bom = FALSE;
- new_doc->editor->scintilla = NULL;
- editor->scroll_percent = -1.0F;
- editor->line_breaking = FALSE;
+ new_doc->editor = NULL;
new_doc->mtime = 0;
new_doc->changed = FALSE;
new_doc->last_check = time(NULL);
@@ -363,7 +358,7 @@
for (i = 0; i < documents_array->len; i++)
{
- if (documents[i]->editor->scintilla == NULL)
+ if (documents[i]->editor == NULL)
{
return (gint) i;
}
@@ -417,7 +412,7 @@
this->file_name = g_strdup(utf8_filename);
- this->editor->scintilla = editor_create_new_sci(this);
+ this->editor = editor_create(this);
document_apply_update_prefs(this);
@@ -495,15 +490,16 @@
g_free(doc->real_path);
tm_workspace_remove_object(doc->tm_file, TRUE, TRUE);
+ g_free(doc->editor);
+ doc->editor = NULL;
+
doc->is_valid = FALSE;
- doc->editor->scintilla = NULL;
doc->file_name = NULL;
doc->real_path = NULL;
doc->file_type = NULL;
doc->encoding = NULL;
doc->has_bom = FALSE;
doc->tm_file = NULL;
- doc->editor->scroll_percent = -1.0F;
document_undo_clear(doc);
if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook)) == 0)
{
@@ -2168,7 +2164,7 @@
}
fdoc->redo_actions = NULL;
- if (! main_status.quitting && doc->editor->scintilla != NULL)
+ if (! main_status.quitting && doc->editor != NULL)
document_set_text_changed(doc, FALSE);
/*geany_debug("%s: new undo stack height: %d, new redo stack height: %d", __func__,
Modified: branches/editor-struct/src/editor.c
===================================================================
--- branches/editor-struct/src/editor.c 2008-07-10 14:12:09 UTC (rev 2767)
+++ branches/editor-struct/src/editor.c 2008-07-11 14:11:53 UTC (rev 2768)
@@ -3554,7 +3554,7 @@
/* Create new editor widget (scintilla).
* @note The @c "sci-notify" signal is connected separately. */
-ScintillaObject *editor_create_new_sci(GeanyDocument *doc)
+static ScintillaObject *create_new_sci(GeanyDocument *doc)
{
ScintillaObject *sci;
@@ -3597,3 +3597,18 @@
}
+GeanyEditor *editor_create(GeanyDocument *doc)
+{
+ GeanyEditor *editor = g_new0(GeanyEditor, 1);
+
+ editor->document = doc;
+
+ editor->auto_indent = (editor_prefs.indent_mode != INDENT_NONE);
+ editor->line_wrapping = editor_prefs.line_wrapping;
+ editor->scroll_percent = -1.0F;
+ editor->line_breaking = FALSE;
+
+ editor->scintilla = create_new_sci(doc);
+ return editor;
+}
+
Modified: branches/editor-struct/src/editor.h
===================================================================
--- branches/editor-struct/src/editor.h 2008-07-10 14:12:09 UTC (rev 2767)
+++ branches/editor-struct/src/editor.h 2008-07-11 14:11:53 UTC (rev 2768)
@@ -125,7 +125,7 @@
-ScintillaObject *editor_create_new_sci(GeanyDocument *doc);
+GeanyEditor *editor_create(GeanyDocument *doc);
void on_editor_notification(GtkWidget* editor, gint scn, gpointer lscn, gpointer user_data);
Modified: branches/editor-struct/src/ui_utils.c
===================================================================
--- branches/editor-struct/src/ui_utils.c 2008-07-10 14:12:09 UTC (rev 2767)
+++ branches/editor-struct/src/ui_utils.c 2008-07-11 14:11:53 UTC (rev 2768)
@@ -270,7 +270,7 @@
/* We copy the current style, and update the font in all open tabs. */
for(i = 0; i < documents_array->len; i++)
{
- if (documents[i]->editor->scintilla)
+ if (documents[i]->editor)
{
editor_set_font(documents[i], fname, size);
}
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