From 0d221d440143a548455bec8f8ec59a69017d6d21 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Wed, 31 Aug 2016 17:13:59 +0200 Subject: [PATCH] wxWidgets initialization reference counter introduced to prevent second initialization, as we recorded a case where EapHost called our GUI twice in the same DllHost.exe process. --- lib/TTLS_UI/src/Module.cpp | 11 +++++++++++ lib/TTLS_UI/src/StdAfx.h | 1 + 2 files changed, 12 insertions(+) diff --git a/lib/TTLS_UI/src/Module.cpp b/lib/TTLS_UI/src/Module.cpp index a8e5c32..4d14d58 100644 --- a/lib/TTLS_UI/src/Module.cpp +++ b/lib/TTLS_UI/src/Module.cpp @@ -23,6 +23,9 @@ using namespace std; using namespace winstd; +static wxCriticalSection s_lock; +static unsigned long s_init_ref_count = 0; + ////////////////////////////////////////////////////////////////////// // wxInitializerPeer @@ -328,6 +331,10 @@ void eap::peer_ttls_ui::invoke_interactive_ui( wxInitializerPeer::wxInitializerPeer(_In_ HINSTANCE instance) { + wxCriticalSectionLocker locker(s_lock); + if (s_init_ref_count++) + return; + // Initialize application. new wxApp(); wxEntryStart(instance); @@ -343,5 +350,9 @@ wxInitializerPeer::wxInitializerPeer(_In_ HINSTANCE instance) wxInitializerPeer::~wxInitializerPeer() { + wxCriticalSectionLocker locker(s_lock); + if (--s_init_ref_count) + return; + wxEntryCleanup(); } diff --git a/lib/TTLS_UI/src/StdAfx.h b/lib/TTLS_UI/src/StdAfx.h index 6eb96e1..595d5e8 100644 --- a/lib/TTLS_UI/src/StdAfx.h +++ b/lib/TTLS_UI/src/StdAfx.h @@ -28,3 +28,4 @@ #include "../../PAP_UI/include/PAP_UI.h" #include +#include