[latexila] PostProcessor: take_messages() vfunc
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] PostProcessor: take_messages() vfunc
- Date: Sun, 5 Oct 2014 16:28:23 +0000 (UTC)
commit 732f1bbba339c969d553550bf8946a3e0272158c
Author: Sébastien Wilmet <swilmet gnome org>
Date: Tue Sep 30 10:12:55 2014 +0200
PostProcessor: take_messages() vfunc
docs/reference/latexila-sections.txt | 1 +
.../latexila-post-processor-all-output.c | 16 ++++++++-
src/liblatexila/latexila-post-processor-latex.c | 16 ++++++++-
src/liblatexila/latexila-post-processor.c | 36 ++++++++++++++++++--
src/liblatexila/latexila-post-processor.h | 4 ++
5 files changed, 68 insertions(+), 5 deletions(-)
---
diff --git a/docs/reference/latexila-sections.txt b/docs/reference/latexila-sections.txt
index 199f43e..8abaf5d 100644
--- a/docs/reference/latexila-sections.txt
+++ b/docs/reference/latexila-sections.txt
@@ -147,6 +147,7 @@ latexila_post_processor_start
latexila_post_processor_process_line
latexila_post_processor_end
latexila_post_processor_get_messages
+latexila_post_processor_take_messages
<SUBSECTION Standard>
LATEXILA_IS_POST_PROCESSOR
LATEXILA_IS_POST_PROCESSOR_CLASS
diff --git a/src/liblatexila/latexila-post-processor-all-output.c
b/src/liblatexila/latexila-post-processor-all-output.c
index 1a1d7cb..942bcbb 100644
--- a/src/liblatexila/latexila-post-processor-all-output.c
+++ b/src/liblatexila/latexila-post-processor-all-output.c
@@ -63,12 +63,25 @@ latexila_post_processor_all_output_get_messages (LatexilaPostProcessor *post_pro
return pp->priv->messages;
}
+static GQueue *
+latexila_post_processor_all_output_take_messages (LatexilaPostProcessor *post_processor)
+{
+ LatexilaPostProcessorAllOutput *pp = LATEXILA_POST_PROCESSOR_ALL_OUTPUT (post_processor);
+ GQueue *ret;
+
+ ret = pp->priv->messages;
+ pp->priv->messages = NULL;
+
+ return ret;
+}
+
static void
latexila_post_processor_all_output_finalize (GObject *object)
{
LatexilaPostProcessorAllOutput *pp = LATEXILA_POST_PROCESSOR_ALL_OUTPUT (object);
- g_queue_free_full (pp->priv->messages, (GDestroyNotify) latexila_build_msg_free);
+ if (pp->priv->messages != NULL)
+ g_queue_free_full (pp->priv->messages, (GDestroyNotify) latexila_build_msg_free);
G_OBJECT_CLASS (latexila_post_processor_all_output_parent_class)->finalize (object);
}
@@ -83,6 +96,7 @@ latexila_post_processor_all_output_class_init (LatexilaPostProcessorAllOutputCla
post_processor_class->process_line = latexila_post_processor_all_output_process_line;
post_processor_class->get_messages = latexila_post_processor_all_output_get_messages;
+ post_processor_class->take_messages = latexila_post_processor_all_output_take_messages;
}
static void
diff --git a/src/liblatexila/latexila-post-processor-latex.c b/src/liblatexila/latexila-post-processor-latex.c
index 049c798..f795a23 100644
--- a/src/liblatexila/latexila-post-processor-latex.c
+++ b/src/liblatexila/latexila-post-processor-latex.c
@@ -1370,12 +1370,25 @@ latexila_post_processor_latex_get_messages (LatexilaPostProcessor *post_processo
return pp->priv->messages;
}
+static GQueue *
+latexila_post_processor_latex_take_messages (LatexilaPostProcessor *post_processor)
+{
+ LatexilaPostProcessorLatex *pp = LATEXILA_POST_PROCESSOR_LATEX (post_processor);
+ GQueue *ret;
+
+ ret = pp->priv->messages;
+ pp->priv->messages = NULL;
+
+ return ret;
+}
+
static void
latexila_post_processor_latex_finalize (GObject *object)
{
LatexilaPostProcessorLatex *pp = LATEXILA_POST_PROCESSOR_LATEX (object);
- g_queue_free_full (pp->priv->messages, (GDestroyNotify) latexila_build_msg_free);
+ if (pp->priv->messages != NULL)
+ g_queue_free_full (pp->priv->messages, (GDestroyNotify) latexila_build_msg_free);
if (pp->priv->cur_msg != NULL)
latexila_build_msg_free (pp->priv->cur_msg);
@@ -1405,6 +1418,7 @@ latexila_post_processor_latex_class_init (LatexilaPostProcessorLatexClass *klass
pp_class->end = latexila_post_processor_latex_end;
pp_class->process_line = latexila_post_processor_latex_process_line;
pp_class->get_messages = latexila_post_processor_latex_get_messages;
+ pp_class->take_messages = latexila_post_processor_latex_take_messages;
}
static void
diff --git a/src/liblatexila/latexila-post-processor.c b/src/liblatexila/latexila-post-processor.c
index 5fe1eaa..4ac8516 100644
--- a/src/liblatexila/latexila-post-processor.c
+++ b/src/liblatexila/latexila-post-processor.c
@@ -24,10 +24,15 @@
*
* When running a build tool, a post-processor is used to filter the output to
* display only the relevant messages. The output can come from the
- * stdout/stderr of a build job command, or the contents of a log file, etc.
+ * stdout/stderr of a build job command, or the contents of a log file, etc. In
+ * LaTeXila only the former is currently used, but it would be more robust to
+ * read the LaTeX log file.
*
* For the no-output post-processor type, you should not need to create a
* #LatexilaPostProcessor object, since the result is empty.
+ *
+ * The implementations sometimes assume that a post-processor can be used at
+ * most one time.
*/
#include "latexila-post-processor.h"
@@ -233,6 +238,12 @@ latexila_post_processor_get_messages_default (LatexilaPostProcessor *pp)
return NULL;
}
+static GQueue *
+latexila_post_processor_take_messages_default (LatexilaPostProcessor *pp)
+{
+ return NULL;
+}
+
static void
latexila_post_processor_class_init (LatexilaPostProcessorClass *klass)
{
@@ -247,6 +258,7 @@ latexila_post_processor_class_init (LatexilaPostProcessorClass *klass)
klass->process_line = latexila_post_processor_process_line_default;
klass->end = latexila_post_processor_end_default;
klass->get_messages = latexila_post_processor_get_messages_default;
+ klass->take_messages = latexila_post_processor_take_messages_default;
g_object_class_install_property (object_class,
PROP_HAS_DETAILS,
@@ -547,8 +559,8 @@ latexila_post_processor_end (LatexilaPostProcessor *pp)
*
* The current solution is "good enough". And "good enough" is... "good enough".
*
- * Returns: (transfer none): the tree of filtered messages. Element types:
- * #LatexilaBuildMsg.
+ * Returns: (transfer none) (nullable): the tree of filtered messages, or %NULL.
+ * Element types: #LatexilaBuildMsg.
*/
const GQueue *
latexila_post_processor_get_messages (LatexilaPostProcessor *pp)
@@ -557,3 +569,21 @@ latexila_post_processor_get_messages (LatexilaPostProcessor *pp)
return LATEXILA_POST_PROCESSOR_GET_CLASS (pp)->get_messages (pp);
}
+
+/**
+ * latexila_post_processor_take_messages: (skip)
+ * @pp: a #LatexilaPostProcessor.
+ *
+ * Takes ownership of the messages. Since #GQueue is not reference counted, @pp
+ * is emptied and is thus useless after calling this function.
+ *
+ * Returns: (transfer full) (nullable): the tree of filtered messages, or %NULL.
+ * Element types: #LatexilaBuildMsg.
+ */
+GQueue *
+latexila_post_processor_take_messages (LatexilaPostProcessor *pp)
+{
+ g_return_val_if_fail (LATEXILA_IS_POST_PROCESSOR (pp), NULL);
+
+ return LATEXILA_POST_PROCESSOR_GET_CLASS (pp)->take_messages (pp);
+}
diff --git a/src/liblatexila/latexila-post-processor.h b/src/liblatexila/latexila-post-processor.h
index 4816018..269bddc 100644
--- a/src/liblatexila/latexila-post-processor.h
+++ b/src/liblatexila/latexila-post-processor.h
@@ -74,6 +74,8 @@ struct _LatexilaPostProcessorClass
void (* end) (LatexilaPostProcessor *pp);
const GQueue * (* get_messages) (LatexilaPostProcessor *pp);
+
+ GQueue * (* take_messages) (LatexilaPostProcessor *pp);
};
GType latexila_post_processor_get_type (void) G_GNUC_CONST;
@@ -103,6 +105,8 @@ void latexila_post_processor_end (LatexilaP
const GQueue * latexila_post_processor_get_messages (LatexilaPostProcessor *pp);
+GQueue * latexila_post_processor_take_messages (LatexilaPostProcessor *pp);
+
G_END_DECLS
#endif /* __LATEXILA_POST_PROCESSOR_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]