Use wxWinAPI::Event wrapper class instead of raw Windows event handles.
This makes the code slightly shorter and, more importantly, more readable and safer. Closes #16233. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76655 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
|
||||
#include "wx/msw/private.h"
|
||||
#include "wx/msw/private/hiddenwin.h"
|
||||
#include "wx/msw/private/event.h"
|
||||
#include "wx/dynlib.h"
|
||||
|
||||
wxDEFINE_EVENT( wxEVT_DIALUP_CONNECTED, wxDialUpEvent );
|
||||
@@ -137,8 +138,6 @@ struct WXDLLEXPORT wxRasThreadData
|
||||
wxRasThreadData()
|
||||
{
|
||||
hWnd = 0;
|
||||
hEventRas =
|
||||
hEventQuit = 0;
|
||||
dialUpManager = NULL;
|
||||
}
|
||||
|
||||
@@ -146,17 +145,11 @@ struct WXDLLEXPORT wxRasThreadData
|
||||
{
|
||||
if ( hWnd )
|
||||
DestroyWindow(hWnd);
|
||||
|
||||
if ( hEventQuit )
|
||||
CloseHandle(hEventQuit);
|
||||
|
||||
if ( hEventRas )
|
||||
CloseHandle(hEventRas);
|
||||
}
|
||||
|
||||
HWND hWnd; // window to send notifications to
|
||||
HANDLE hEventRas, // automatic event which RAS signals when status changes
|
||||
hEventQuit; // manual event which we signal when we terminate
|
||||
wxWinAPI::Event hEventRas, // automatic event which RAS signals when status changes
|
||||
hEventQuit; // manual event which we signal when we terminate
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxDialUpManagerMSW *dialUpManager; // the owner
|
||||
};
|
||||
@@ -575,12 +568,10 @@ void wxDialUpManagerMSW::CleanUpThreadData()
|
||||
{
|
||||
if ( m_hThread )
|
||||
{
|
||||
if ( !SetEvent(m_data->hEventQuit) )
|
||||
{
|
||||
wxLogLastError(wxT("SetEvent(RasThreadQuit)"));
|
||||
}
|
||||
else // sent quit request to the background thread
|
||||
if ( m_data->hEventQuit.Set() )
|
||||
{
|
||||
// sent quit request to the background thread
|
||||
|
||||
// the thread still needs m_data so we can't free it here, rather
|
||||
// let the thread do it itself
|
||||
m_data = NULL;
|
||||
@@ -1066,14 +1057,11 @@ bool wxDialUpManagerMSW::EnableAutoCheckOnlineStatus(size_t nSeconds)
|
||||
if ( ok )
|
||||
{
|
||||
// first create an event to wait on
|
||||
m_data->hEventRas = ::CreateEvent
|
||||
if ( !m_data->hEventRas.Create
|
||||
(
|
||||
NULL, // security attribute (default)
|
||||
FALSE, // manual reset (no, it is automatic)
|
||||
FALSE, // initial state (not signaled)
|
||||
NULL // name (no)
|
||||
);
|
||||
if ( !m_data->hEventRas )
|
||||
wxWinAPI::Event::AutomaticReset,
|
||||
wxWinAPI::Event::Nonsignaled
|
||||
) )
|
||||
{
|
||||
wxLogLastError(wxT("CreateEvent(RasStatus)"));
|
||||
|
||||
@@ -1087,14 +1075,11 @@ bool wxDialUpManagerMSW::EnableAutoCheckOnlineStatus(size_t nSeconds)
|
||||
// here avoids problems with missing the event if wxDialUpManagerMSW
|
||||
// is created and destroyed immediately, before wxRasStatusWindowProc
|
||||
// starts waiting on the event
|
||||
m_data->hEventQuit = ::CreateEvent
|
||||
if ( !m_data->hEventQuit.Create
|
||||
(
|
||||
NULL, // default security
|
||||
TRUE, // manual event
|
||||
FALSE, // initially non signalled
|
||||
NULL // nameless
|
||||
);
|
||||
if ( !m_data->hEventQuit )
|
||||
wxWinAPI::Event::ManualReset,
|
||||
wxWinAPI::Event::Nonsignaled
|
||||
) )
|
||||
{
|
||||
wxLogLastError(wxT("CreateEvent(RasThreadQuit)"));
|
||||
|
||||
|
Reference in New Issue
Block a user