From ee563973094a8235631d5208bd672f8cbbe15fdc Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: 2011年12月18日 00:02:19 +0100 Subject: Eliminate C++ exceptions from graphical system implementation The rationale is that everything is simpler without C++ exceptions. No exceptions are raised in the C++ code and errors are handler in the tradition C fashion. lua_error is not directly called from C++ functions that may allocate a non POD object on the stack. If the C++ "new" operator raise an exception the program will abort. The idea is that handle such an improbable occurrence greatly complicates the code. Where big chunks of memory are allocated the nothrow variant of "new" is used, the returned pointer is verified and an error is raised if the allocation failed. In the Windows code the bitmap allocation for image may raise an unhandled exception in there is not enough memory. The memory allocation is done inside the AGG library so it difficult to change its behavior. --- agg-plot/lua-plot.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'agg-plot/lua-plot.cpp') diff --git a/agg-plot/lua-plot.cpp b/agg-plot/lua-plot.cpp index 252b2c56..8ea2ab81 100644 --- a/agg-plot/lua-plot.cpp +++ b/agg-plot/lua-plot.cpp @@ -165,23 +165,19 @@ plot_free (lua_State *L) void plot_add_gener_cpp (lua_State *L, sg_plot *p, bool as_line, - gslshell::ret_status& st) + gslshell::ret_status& st) { - try { - agg::rgba8 color; - sg_object* obj = parse_graph_args(L, color); - - AGG_LOCK(); - p->add(obj, color, as_line); - AGG_UNLOCK(); - - if (p->sync_mode()) - plot_flush (L); - } - catch (std::exception& e) - { - st.error(e.what(), "plot add or addline"); - } + agg::rgba8 color; + sg_object* obj = parse_graph_args(L, color, st); + + if (!obj) return; + + AGG_LOCK(); + p->add(obj, color, as_line); + AGG_UNLOCK(); + + if (p->sync_mode()) + plot_flush (L); } static void -- cgit v1.2.3

AltStyle によって変換されたページ (->オリジナル) /