DEV9: fix crash when closing game window with ethernet disabled

This commit is contained in:
GovanifY 2020-10-03 21:55:40 +02:00 committed by refractionpcsx2
parent 6186676add
commit cf58a32583
2 changed files with 5 additions and 0 deletions

View File

@ -280,6 +280,7 @@ TAPAdapter::TAPAdapter()
write.Offset = 0; write.Offset = 0;
write.OffsetHigh = 0; write.OffsetHigh = 0;
write.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); write.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
isActive = true;
} }
@ -379,10 +380,13 @@ bool TAPAdapter::send(NetPacket* pkt)
} }
TAPAdapter::~TAPAdapter() TAPAdapter::~TAPAdapter()
{ {
if (!isActive)
return;
CloseHandle(read.hEvent); CloseHandle(read.hEvent);
CloseHandle(write.hEvent); CloseHandle(write.hEvent);
TAPSetStatus(htap, FALSE); TAPSetStatus(htap, FALSE);
CloseHandle(htap); CloseHandle(htap);
isActive = false;
} }
//i leave these for reference, in case we need msth :p //i leave these for reference, in case we need msth :p

View File

@ -29,6 +29,7 @@ class TAPAdapter : public NetAdapter
{ {
HANDLE htap; HANDLE htap;
OVERLAPPED read,write; OVERLAPPED read,write;
bool isActive = false;
public: public:
TAPAdapter(); TAPAdapter();
virtual bool blocks(); virtual bool blocks();