yelp r3061 - in trunk: . src



Author: dscorgie
Date: Sat Feb  2 11:46:51 2008
New Revision: 3061
URL: http://svn.gnome.org/viewvc/yelp?rev=3061&view=rev

Log:
* src/yelp-man.c:
* src/yelp-transform.c:
* src/yelp-toc.c:
* src/yelp-info.c:
* src/yelp-window.c:
* src/yelp-docbook.c:
* src/yelp-document.c:
* src/yelp-document.h:
Only propagate final signals
once we have really finished
processing documents
Fixes bug #476498, hopefully
+
Fix looking for non-existant
IDs once the document loading is complete
+
Remove debug spew when trying to
add specifically defined x-yelp-index


Modified:
   trunk/ChangeLog
   trunk/src/yelp-docbook.c
   trunk/src/yelp-document.c
   trunk/src/yelp-document.h
   trunk/src/yelp-info.c
   trunk/src/yelp-man.c
   trunk/src/yelp-toc.c
   trunk/src/yelp-transform.c
   trunk/src/yelp-window.c

Modified: trunk/src/yelp-docbook.c
==============================================================================
--- trunk/src/yelp-docbook.c	(original)
+++ trunk/src/yelp-docbook.c	Sat Feb  2 11:46:51 2008
@@ -367,11 +367,12 @@
     error = yelp_error_new (_("Page not found"),
 			    _("The requested page was not found in the document %s."),
 			    priv->filename);
-    yelp_document_error_pending (YELP_DOCUMENT (docbook), error);
+    yelp_document_final_pending (YELP_DOCUMENT (docbook), error);
 
     yelp_transform_release (transform);
     priv->transform = NULL;
     priv->transform_running = FALSE;
+    priv->state = DOCBOOK_STATE_PARSED;
 
     if (priv->xmldoc)
 	xmlFreeDoc (priv->xmldoc);
@@ -598,8 +599,7 @@
 
     old_cur = priv->xmlcur;
     priv->cur_depth++;
-
-    if (id)
+    if (id && !g_str_equal (id, "x-yelp-index"))
 	yelp_document_add_page_id (document, (gchar *) id, priv->cur_page_id);
 
     for (cur = priv->xmlcur->children; cur; cur = cur->next) {

Modified: trunk/src/yelp-document.c
==============================================================================
--- trunk/src/yelp-document.c	(original)
+++ trunk/src/yelp-document.c	Sat Feb  2 11:46:51 2008
@@ -51,6 +51,8 @@
     GMutex       *mutex;
 
     gchar        *root_id;
+    YelpError    *final_error;
+
 
     GHashTable   *reqs_by_req_id;   /* Indexed by the request ID */
     GHashTable   *reqs_by_page_id;  /* Indexed by page ID, contains GSList */
@@ -78,6 +80,7 @@
 static gboolean       request_idle_title      (Request             *request);
 static gboolean       request_idle_page       (Request             *request);
 static gboolean       request_idle_error      (Request             *request);
+static gboolean       request_idle_final      (YelpDocument        *document);
 static void           request_try_free        (Request             *request);
 static void           request_free            (Request             *request);
 
@@ -545,6 +548,28 @@
     g_mutex_unlock (priv->mutex);
 }
 
+void
+yelp_document_final_pending (YelpDocument *document, YelpError *error)
+{
+    YelpDocumentPriv *priv;
+
+    g_assert (document != NULL && YELP_IS_DOCUMENT (document));
+
+    debug_print (DB_FUNCTION, "entering\n");
+    priv = document->priv;
+
+    g_mutex_lock (priv->mutex);
+    if (priv->reqs_pending) {
+	priv->final_error = error;
+	g_idle_add ((GSourceFunc) request_idle_final, document);
+    } else {
+	yelp_error_free (error);
+    }
+
+    g_mutex_unlock (priv->mutex);
+}
+
+
 /******************************************************************************/
 
 static gboolean
@@ -610,7 +635,6 @@
 	request->idle_funcs--;
 	return FALSE;
     }
-
     debug_print (DB_FUNCTION, "entering\n");
 
     document = g_object_ref (request->document);
@@ -707,6 +731,69 @@
     return FALSE;
 }
 
+
+static gboolean
+request_idle_final (YelpDocument *document)
+{
+    YelpDocumentPriv *priv;
+    YelpDocumentFunc  func = NULL;
+    YelpError *error = NULL;
+    gint req_id = 0;
+    gpointer user_data = user_data;
+    Request *request = NULL;
+    GSList *cur = NULL;
+
+    debug_print (DB_FUNCTION, "entering\n");
+
+    priv = document->priv;
+
+    g_mutex_lock (priv->mutex);
+    
+    for (cur = priv->reqs_pending; cur; cur = cur->next) {
+	request = cur->data;
+	if (request->idle_funcs != 0) {
+	    /* 
+	       While there are outstanding requests, we should wait for them
+	       to complete before signalling the error
+	    */
+	    request->idle_funcs++;
+	    g_mutex_unlock (priv->mutex);
+	    return TRUE;
+	}
+    }
+
+    for (cur = priv->reqs_pending; cur; cur = cur->next) {
+	request = cur->data;
+	
+	if (cur->next)
+	    request->error = yelp_error_copy (priv->final_error);
+	else
+	    request->error = error;
+	
+	if (request->error) {
+	    func = request->func;
+	    req_id = request->req_id;
+	    user_data = request->user_data;
+	    error = request->error;
+	    request->error = NULL;
+	    
+	    priv->reqs_pending = g_slist_remove (priv->reqs_pending, request);
+	}
+	
+	
+	if (func)
+	    func (document,
+		  YELP_DOCUMENT_SIGNAL_ERROR,
+		  req_id,
+		  error,
+		  user_data);
+    }
+    g_mutex_unlock (priv->mutex);
+    
+    g_object_unref (document);
+    return FALSE;
+}
+
 static void
 request_try_free (Request *request) {
     debug_print (DB_FUNCTION, "entering\n");

Modified: trunk/src/yelp-document.h
==============================================================================
--- trunk/src/yelp-document.h	(original)
+++ trunk/src/yelp-document.h	Sat Feb  2 11:46:51 2008
@@ -128,5 +128,7 @@
 						YelpError          *error);
 GtkTreeModel     *yelp_document_get_sections   (YelpDocument       *document);
 
+void              yelp_document_final_pending  (YelpDocument       *document,
+						YelpError          *error);
 
 #endif /* __YELP_DOCUMENT_H__ */

Modified: trunk/src/yelp-info.c
==============================================================================
--- trunk/src/yelp-info.c	(original)
+++ trunk/src/yelp-info.c	Sat Feb  2 11:46:51 2008
@@ -338,11 +338,12 @@
     error = yelp_error_new (_("Page not found"),
 			    _("The requested page was not found in the document %s."),
 			    priv->filename);
-    yelp_document_error_pending (YELP_DOCUMENT (info), error);
+    yelp_document_final_pending (YELP_DOCUMENT (info), error);
 
     yelp_transform_release (transform);
     priv->transform = NULL;
     priv->transform_running = FALSE;
+    priv->state = INFO_STATE_PARSED;
 
     if (priv->xmldoc)
 	xmlFreeDoc (priv->xmldoc);

Modified: trunk/src/yelp-man.c
==============================================================================
--- trunk/src/yelp-man.c	(original)
+++ trunk/src/yelp-man.c	Sat Feb  2 11:46:51 2008
@@ -203,7 +203,6 @@
 
     g_assert (object != NULL && YELP_IS_MAN (object));
     priv = YELP_MAN (object)->priv;
-
     g_mutex_lock (priv->mutex);
     if (priv->process_running || priv->transform_running) {
 	priv->state = MAN_STATE_STOP;
@@ -382,17 +381,16 @@
     YelpManPriv *priv = man->priv;
 
     debug_print (DB_FUNCTION, "entering\n");
-
     g_mutex_lock (priv->mutex);
-
     error = yelp_error_new (_("Page not found"),
 			    _("The requested page was not found in the document %s."),
 			    priv->filename);
-    yelp_document_error_pending (YELP_DOCUMENT (man), error);
+    yelp_document_final_pending (YELP_DOCUMENT (man), error);
 
     yelp_transform_release (transform);
     priv->transform = NULL;
     priv->transform_running = FALSE;
+    priv->state = MAN_STATE_PARSED;
 
     if (priv->xmldoc)
 	xmlFreeDoc (priv->xmldoc);

Modified: trunk/src/yelp-toc.c
==============================================================================
--- trunk/src/yelp-toc.c	(original)
+++ trunk/src/yelp-toc.c	Sat Feb  2 11:46:51 2008
@@ -167,7 +167,7 @@
     g_assert (object != NULL && YELP_IS_TOC (object));
 
     priv = YELP_TOC (object)->priv;
-
+    
     g_mutex_lock (priv->mutex);
     if (priv->process_running || priv->transform_running) {
 	priv->state = TOC_STATE_STOP;
@@ -364,13 +364,14 @@
 
     error = yelp_error_new (_("Page not found"),
 			    _("The requested page was not found in the TOC."));
-    yelp_document_error_pending (YELP_DOCUMENT (toc), error);
+    yelp_document_final_pending (YELP_DOCUMENT (toc), error);
 
     yelp_transform_release (priv->transform);
     priv->transform = NULL;
 
     priv->transform_running = FALSE;
     priv->process_running = FALSE;
+    priv->state = TOC_STATE_PARSED;
 
     if (priv->xmldoc) {
 	xmlFreeDoc (priv->xmldoc);

Modified: trunk/src/yelp-transform.c
==============================================================================
--- trunk/src/yelp-transform.c	(original)
+++ trunk/src/yelp-transform.c	Sat Feb  2 11:46:51 2008
@@ -320,6 +320,7 @@
 transform_final (YelpTransform *transform)
 {
     transform->idle_funcs--;
+
     if (transform->released)
 	return FALSE;
 

Modified: trunk/src/yelp-window.c
==============================================================================
--- trunk/src/yelp-window.c	(original)
+++ trunk/src/yelp-window.c	Sat Feb  2 11:46:51 2008
@@ -987,7 +987,7 @@
     priv = window->priv;
 
     current_base = g_strdup (priv->base_uri);
-    
+
     /* If someone asks for info:dir, they WILL get redirected to
      * our index.  Tough.
      */



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