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.

This commit is contained in:
Simon Rozman 2016-08-31 17:13:59 +02:00
parent d9bfcc3e49
commit 0d221d4401
2 changed files with 12 additions and 0 deletions

View File

@ -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();
}

View File

@ -28,3 +28,4 @@
#include "../../PAP_UI/include/PAP_UI.h"
#include <wx/app.h>
#include <wx/thread.h>