From: Uwe Hermann Date: Tue, 8 Jan 2019 22:17:27 +0000 (+0100) Subject: Srf::init(): Throw an exception upon multiple init() calls. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=fa243f2cb5596e9aeb012a82eacb938d77447e27;p=libsigrokflow.git Srf::init(): Throw an exception upon multiple init() calls. --- diff --git a/src/main.cpp b/src/main.cpp index ab9435b..45d2308 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,6 +30,11 @@ using namespace std::placeholders; void init() { + static bool srf_initialized = false; + + if (srf_initialized) + throw runtime_error("libsigrokflow is already initialized"); + #ifdef HAVE_LIBSIGROKCXX Gst::Plugin::register_static(GST_VERSION_MAJOR, GST_VERSION_MINOR, "sigrok_legacy_capture_device", @@ -54,6 +59,8 @@ void init() sigc::ptr_fun(&LegacyDecoder::register_element), "0.01", "GPL", "sigrok", "libsigrokflow", "http://sigrok.org"); #endif + + srf_initialized = true; } Sink::Sink(GstBaseSink *gobj) :