GUI: Don't freeze when calling BridgeResult::Wait() on the main ThreadClear
closes #1716
This commit is contained in:
parent
ec66220dd5
commit
51c1b5f690
|
|
@ -14,19 +14,16 @@ static Bridge* mBridge;
|
|||
************************************************************************************/
|
||||
Bridge::Bridge(QObject* parent) : QObject(parent)
|
||||
{
|
||||
mBridgeMutex = new QMutex();
|
||||
winId = 0;
|
||||
scriptView = 0;
|
||||
referenceManager = 0;
|
||||
bridgeResult = 0;
|
||||
hResultEvent = CreateEventW(nullptr, true, true, nullptr);
|
||||
dbgStopped = false;
|
||||
InitializeCriticalSection(&csBridge);
|
||||
hResultEvent = CreateEventW(nullptr, true, true, nullptr);;
|
||||
dwMainThreadId = GetCurrentThreadId();
|
||||
}
|
||||
|
||||
Bridge::~Bridge()
|
||||
{
|
||||
CloseHandle(hResultEvent);
|
||||
delete mBridgeMutex;
|
||||
EnterCriticalSection(&csBridge);
|
||||
DeleteCriticalSection(&csBridge);
|
||||
}
|
||||
|
||||
void Bridge::CopyToClipboard(const QString & text)
|
||||
|
|
|
|||
|
|
@ -37,10 +37,9 @@ public:
|
|||
void setDbgStopped();
|
||||
|
||||
//Public variables
|
||||
void* winId;
|
||||
QWidget* scriptView;
|
||||
ReferenceManager* referenceManager;
|
||||
QWidget* snowmanView;
|
||||
void* winId = nullptr;
|
||||
ReferenceManager* referenceManager = nullptr;
|
||||
QWidget* snowmanView = nullptr;
|
||||
bool mIsRunning = false;
|
||||
|
||||
signals:
|
||||
|
|
@ -157,10 +156,11 @@ signals:
|
|||
void getDumpAttention();
|
||||
|
||||
private:
|
||||
QMutex* mBridgeMutex;
|
||||
dsint bridgeResult;
|
||||
CRITICAL_SECTION csBridge;
|
||||
HANDLE hResultEvent;
|
||||
volatile bool dbgStopped;
|
||||
DWORD dwMainThreadId = 0;
|
||||
dsint bridgeResult = 0;
|
||||
volatile bool dbgStopped = false;
|
||||
};
|
||||
|
||||
void DbgCmdExec(const QString & cmd);
|
||||
|
|
|
|||
|
|
@ -3,17 +3,22 @@
|
|||
|
||||
BridgeResult::BridgeResult()
|
||||
{
|
||||
Bridge::getBridge()->mBridgeMutex->lock();
|
||||
EnterCriticalSection(&Bridge::getBridge()->csBridge);
|
||||
ResetEvent(Bridge::getBridge()->hResultEvent);
|
||||
}
|
||||
|
||||
BridgeResult::~BridgeResult()
|
||||
{
|
||||
Bridge::getBridge()->mBridgeMutex->unlock();
|
||||
LeaveCriticalSection(&Bridge::getBridge()->csBridge);
|
||||
}
|
||||
|
||||
dsint BridgeResult::Wait()
|
||||
{
|
||||
WaitForSingleObject(Bridge::getBridge()->hResultEvent, INFINITE);
|
||||
//Don't freeze when waiting on the main thread (https://github.com/x64dbg/x64dbg/issues/1716)
|
||||
if(GetCurrentThreadId() == Bridge::getBridge()->dwMainThreadId)
|
||||
while(WaitForSingleObject(Bridge::getBridge()->hResultEvent, 10) == WAIT_TIMEOUT)
|
||||
QCoreApplication::processEvents();
|
||||
else
|
||||
WaitForSingleObject(Bridge::getBridge()->hResultEvent, INFINITE);
|
||||
return Bridge::getBridge()->bridgeResult;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue