summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-02-01 18:17:19 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-02-01 18:17:19 +0300
commit133b067e695bee81189df980c9043fe843d7887e (patch)
tree76a36435e3d210490a08c59a3c2abe236a16d115
parent22308a6db6d03337d854810c3245260a19972deb (diff)
let's make a couple of things simpler
-rw-r--r--include/m_gui.h3
-rw-r--r--libs/win32/mir_core.libbin463074 -> 463576 bytes
-rw-r--r--libs/win64/mir_core.libbin467908 -> 468422 bytes
-rw-r--r--protocols/Discord/src/connection.cpp2
-rw-r--r--protocols/Discord/src/dispatch.cpp2
-rw-r--r--src/mir_core/src/CTimer.cpp16
-rw-r--r--src/mir_core/src/locks.cpp3
-rw-r--r--src/mir_core/src/mir_core.def2
-rw-r--r--src/mir_core/src/mir_core64.def2
9 files changed, 24 insertions, 6 deletions
diff --git a/include/m_gui.h b/include/m_gui.h
index 45ce0cf778..a3eddb96ee 100644
--- a/include/m_gui.h
+++ b/include/m_gui.h
@@ -497,6 +497,9 @@ public:
void Start(int elapse);
void Stop();
+ void StartSafe(int elapse);
+ void StopSafe();
+
CCallback<CTimer> OnEvent;
protected:
diff --git a/libs/win32/mir_core.lib b/libs/win32/mir_core.lib
index 7ec5e8210a..2130e6587f 100644
--- a/libs/win32/mir_core.lib
+++ b/libs/win32/mir_core.lib
Binary files differ
diff --git a/libs/win64/mir_core.lib b/libs/win64/mir_core.lib
index 586e45e019..6423be6390 100644
--- a/libs/win64/mir_core.lib
+++ b/libs/win64/mir_core.lib
Binary files differ
diff --git a/protocols/Discord/src/connection.cpp b/protocols/Discord/src/connection.cpp
index 758d2a05a9..aa11ff9af2 100644
--- a/protocols/Discord/src/connection.cpp
+++ b/protocols/Discord/src/connection.cpp
@@ -80,7 +80,7 @@ void CDiscordProto::OnLoggedOut()
m_bTerminated = true;
m_iGatewaySeq = 0;
- m_impl.m_heartBeat.Stop();
+ m_impl.m_heartBeat.StopSafe();
ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)m_iStatus, ID_STATUS_OFFLINE);
m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp
index 90d0c6af40..2841b481a4 100644
--- a/protocols/Discord/src/dispatch.cpp
+++ b/protocols/Discord/src/dispatch.cpp
@@ -550,7 +550,7 @@ void CDiscordProto::OnCommandPresence(const JSONNode &pRoot)
void CDiscordProto::OnCommandReady(const JSONNode &pRoot)
{
GatewaySendHeartbeat();
- m_impl.m_heartBeat.Start(m_iHartbeatInterval);
+ m_impl.m_heartBeat.StartSafe(m_iHartbeatInterval);
m_szGatewaySessionId = pRoot["session_id"].as_mstring();
diff --git a/src/mir_core/src/CTimer.cpp b/src/mir_core/src/CTimer.cpp
index 2525031dff..e03a44666c 100644
--- a/src/mir_core/src/CTimer.cpp
+++ b/src/mir_core/src/CTimer.cpp
@@ -46,6 +46,18 @@ BOOL CTimer::OnTimer()
/////////////////////////////////////////////////////////////////////////////////////////
+void CTimer::Start(int elapse)
+{
+ ::SetTimer(m_wnd->GetHwnd(), m_idEvent, elapse, nullptr);
+}
+
+void CTimer::Stop()
+{
+ ::KillTimer(m_wnd->GetHwnd(), m_idEvent);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
struct TStartParam
{
CTimer *pTimer;
@@ -58,7 +70,7 @@ static INT_PTR CALLBACK stubStart(void *param)
return ::SetTimer(p->pTimer->GetHwnd(), p->pTimer->GetEventId(), p->period, nullptr);
}
-void CTimer::Start(int elapse)
+void CTimer::StartSafe(int elapse)
{
TStartParam param = { this, elapse };
CallFunctionSync(stubStart, &param);
@@ -72,7 +84,7 @@ static INT_PTR CALLBACK stubStop(void *param)
return ::KillTimer(p->GetHwnd(), p->GetEventId());
}
-void CTimer::Stop()
+void CTimer::StopSafe()
{
CallFunctionSync(stubStop, this);
}
diff --git a/src/mir_core/src/locks.cpp b/src/mir_core/src/locks.cpp
index 38146b2858..d4ea621b91 100644
--- a/src/mir_core/src/locks.cpp
+++ b/src/mir_core/src/locks.cpp
@@ -36,8 +36,7 @@ mir_cs::~mir_cs()
void mir_cs::Lock()
{
- while (!::TryEnterCriticalSection(&m_cs))
- ::SleepEx(0, TRUE);
+ ::EnterCriticalSection(&m_cs);
}
void mir_cs::Unlock()
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def
index d233b605ec..b9a61b6e00 100644
--- a/src/mir_core/src/mir_core.def
+++ b/src/mir_core/src/mir_core.def
@@ -1457,3 +1457,5 @@ XmlGetChildText @1645
??1mir_cs@@QAE@XZ @1672 NONAME
?Lock@mir_cs@@QAEXXZ @1673 NONAME
?Unlock@mir_cs@@QAEXXZ @1674 NONAME
+?StartSafe@CTimer@@QAEXH@Z @1675 NONAME
+?StopSafe@CTimer@@QAEXXZ @1676 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def
index b589947f72..4c3168f789 100644
--- a/src/mir_core/src/mir_core64.def
+++ b/src/mir_core/src/mir_core64.def
@@ -1457,3 +1457,5 @@ XmlGetChildText @1645
??1mir_cs@@QEAA@XZ @1672 NONAME
?Lock@mir_cs@@QEAAXXZ @1673 NONAME
?Unlock@mir_cs@@QEAAXXZ @1674 NONAME
+?StartSafe@CTimer@@QEAAXH@Z @1675 NONAME
+?StopSafe@CTimer@@QEAAXXZ @1676 NONAME