SF.net SVN: geany-plugins:[1423] trunk/geany-plugins/geanygendoc/src/ggd.c

colombanw at users.sourceforge.net colombanw at xxxxx
Fri Jun 4 16:26:58 UTC 2010


Revision: 1423
          http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1423&view=rev
Author:   colombanw
Date:     2010-06-04 16:26:58 +0000 (Fri, 04 Jun 2010)

Log Message:
-----------
GeanyGenDoc: Prevent crash if there is no tags at all

Fix crash when trying to generate documentation for a document with
doc->tm_file == NULL, which is the case e.g. for None file type.

Modified Paths:
--------------
    trunk/geany-plugins/geanygendoc/src/ggd.c

Modified: trunk/geany-plugins/geanygendoc/src/ggd.c
===================================================================
--- trunk/geany-plugins/geanygendoc/src/ggd.c	2010-06-03 21:24:51 UTC (rev 1422)
+++ trunk/geany-plugins/geanygendoc/src/ggd.c	2010-06-04 16:26:58 UTC (rev 1423)
@@ -507,15 +507,17 @@
                     const gchar    *doc_type)
 {
   gboolean          success = FALSE;
-  const TMTag      *tag;
-  GPtrArray        *tag_array;
+  const TMTag      *tag = NULL;
+  GPtrArray        *tag_array = NULL;
   GgdFileType      *filetype;
   GgdDocType       *doctype;
   
   g_return_val_if_fail (DOC_VALID (doc), FALSE);
   
-  tag_array = doc->tm_file->tags_array;
-  tag = ggd_tag_find_from_line (tag_array, line + 1 /* it is a SCI line */);
+  if (doc->tm_file) {
+    tag_array = doc->tm_file->tags_array;
+    tag = ggd_tag_find_from_line (tag_array, line + 1 /* it is a SCI line */);
+  }
   if (! tag || (tag->type & tm_tag_file_t)) {
     msgwin_status_add (_("No valid tag at line %d."), line);
   } else {
@@ -559,7 +561,12 @@
   
   g_return_val_if_fail (DOC_VALID (doc), FALSE);
   
-  if (get_config (doc, doc_type, &filetype, &doctype)) {
+  if (! doc->tm_file) {
+    /* FIXME: we're on string freeze then don't add a new string; simply re-use
+     * an existing one. Need to fix this after string freeze. */
+    /*msgwin_status_add (_("No tags in the document"));*/
+    msgwin_status_add (_("No valid tag at line %d."), 1);
+  } else if (get_config (doc, doc_type, &filetype, &doctype)) {
     GList    *tag_list;
     
     /* get a sorted list of tags to be sure to insert by the end of the


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Plugins-Commits mailing list