]> sigrok.org Git - libsigrokflow.git/commitdiff
Srf::init(): Throw an exception upon multiple init() calls.
authorUwe Hermann <redacted>
Tue, 8 Jan 2019 22:17:27 +0000 (23:17 +0100)
committerUwe Hermann <redacted>
Tue, 8 Jan 2019 23:57:10 +0000 (00:57 +0100)
src/main.cpp

index ab9435b129bbdad2dbb258a84423af71e3bdce11..45d2308fe3a99387229095d4d1aaf84f7325aee1 100644 (file)
@@ -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) :