[valadoc] charts: Fix error handling if gvRenderData() returns an error
- From: Florian Brosch <flobrosch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [valadoc] charts: Fix error handling if gvRenderData() returns an error
- Date: Sun, 10 Jan 2016 22:11:26 +0000 (UTC)
commit 0bc6256c00f81cc13a25245dd95ec7ef8672ab61
Author: Philip Withnall <philip withnall collabora co uk>
Date: Wed May 13 18:40:59 2015 +0200
charts: Fix error handling if gvRenderData() returns an error
If libgvc was not built properly or is running against incorrectly versioned
plugins, gvRenderData() can fail and return a null string. Ensure libvaladoc
handles this correctly.
https://bugzilla.gnome.org/show_bug.cgi?id=711590
src/libvaladoc/charts/chart.vala | 5 +++--
src/libvaladoc/html/htmlmarkupwriter.vala | 8 +++++---
2 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/src/libvaladoc/charts/chart.vala b/src/libvaladoc/charts/chart.vala
index 03dab30..a6307d7 100644
--- a/src/libvaladoc/charts/chart.vala
+++ b/src/libvaladoc/charts/chart.vala
@@ -52,13 +52,14 @@ public class Valadoc.Charts.Chart : Api.Visitor {
context.render (graph, file_type, file);
}
- public uint8[] write_buffer (string file_type) {
+ public uint8[]? write_buffer (string file_type) {
if (context == null) {
context = factory.create_context (graph);
}
- uint8[] data;
+ uint8[]? data;
+ /* This will return null in data if it fails. */
context.render_data (graph, file_type, out data);
return data;
}
diff --git a/src/libvaladoc/html/htmlmarkupwriter.vala b/src/libvaladoc/html/htmlmarkupwriter.vala
index 113f0c6..15ed9ef 100644
--- a/src/libvaladoc/html/htmlmarkupwriter.vala
+++ b/src/libvaladoc/html/htmlmarkupwriter.vala
@@ -44,9 +44,11 @@ public class Valadoc.Html.MarkupWriter : Valadoc.MarkupWriter {
}
public MarkupWriter add_usemap (Charts.Chart chart) {
- string buf = (string) chart.write_buffer ("cmapx");
- raw_text ("\n");
- raw_text (buf);
+ string? buf = (string?) chart.write_buffer ("cmapx");
+ if (buf != null) {
+ raw_text ("\n");
+ raw_text ((!) buf);
+ }
return this;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]