changeset 850:df0c73ee7afa

Prevent creation of multiple GuiAdapter instances
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 17 Jun 2019 16:12:52 +0200
parents df6c52402484
children 101073b3e855
files Applications/Generic/GuiAdapter.h
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/Generic/GuiAdapter.h	Sat Jun 15 20:37:48 2019 +0200
+++ b/Applications/Generic/GuiAdapter.h	Mon Jun 17 16:12:52 2019 +0200
@@ -207,10 +207,14 @@
   public:
 #if ORTHANC_ENABLE_THREADS == 1
     GuiAdapter(LockingEmitter& lockingEmitter) : lockingEmitter_(lockingEmitter)
-    {}
 #else
-    GuiAdapter() {}
+    GuiAdapter()
 #endif
+    {
+      static int instanceCount = 0;
+      ORTHANC_ASSERT(instanceCount == 0);
+      instanceCount = 1;
+    }
 
     void RegisterWidget(boost::shared_ptr<IGuiAdapterWidget> widget);