https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5197d36839a1f8bd21885…
commit 5197d36839a1f8bd21885ac9dbdb7c28404a5846
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Tue Dec 19 16:12:12 2023 +0900
Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
CommitDate: Tue Dec 19 16:12:12 2023 +0900
[MSCTFIME] Refactor on IMC/IMCC locking
- Rename _IMCCLock as IMCCLOCK.
- Rename InternalIMCCLock as IMCCLock.
- Rename _IMCLock as IMCLOCK.
- Add get() pointer accessor of IMCCLock and IMCLOCK.
- Protect the pointer of IMCCLOCK and IMCLOCK.
CORE-19360
---
dll/ime/msctfime/msctfime.cpp | 10 ++++-----
sdk/include/reactos/cicero/imclock.h | 42 +++++++++++++++++++++++-------------
2 files changed, 32 insertions(+), 20 deletions(-)
diff --git a/dll/ime/msctfime/msctfime.cpp b/dll/ime/msctfime/msctfime.cpp
index f6830f9dc62..8550caa2209 100644
--- a/dll/ime/msctfime/msctfime.cpp
+++ b/dll/ime/msctfime/msctfime.cpp
@@ -101,7 +101,7 @@ CicInputContext::GetGuidAtom(
_In_ DWORD dwUnknown,
_Out_opt_ LPDWORD pdwGuidAtom)
{
- InternalIMCCLock<CTFIMECONTEXT> imeContext(imcLock.m_pIC->hCompStr);
+ IMCCLock<CTFIMECONTEXT> imeContext(imcLock.get().hCompStr);
HRESULT hr = imeContext.m_hr;
if (!imeContext)
@@ -809,17 +809,17 @@ CtfImeGetGuidAtom(
if (FAILED(hr))
return hr;
- InternalIMCCLock<CTFIMECONTEXT> imccLock(imcLock.m_pIC->hCtfImeContext);
+ IMCCLock<CTFIMECONTEXT> imccLock(imcLock.get().hCtfImeContext);
hr = imccLock.m_hr;
if (!imccLock)
hr = E_FAIL;
if (FAILED(hr))
return hr;
- if (!imccLock.m_pIMCC->m_pCicIC)
+ if (!imccLock.get().m_pCicIC)
return E_OUTOFMEMORY;
- hr = imccLock.m_pIMCC->m_pCicIC->GetGuidAtom(imcLock, dwUnknown, pdwGuidAtom);
+ hr = imccLock.get().m_pCicIC->GetGuidAtom(imcLock, dwUnknown, pdwGuidAtom);
return hr;
}
@@ -842,7 +842,7 @@ CtfImeIsGuidMapEnable(
if (!imcLock)
hr = E_FAIL;
if (SUCCEEDED(hr))
- ret = !!(imcLock.m_pIC->fdwInit & INIT_GUIDMAP);
+ ret = !!(imcLock.get().fdwInit & INIT_GUIDMAP);
return ret;
}
diff --git a/sdk/include/reactos/cicero/imclock.h b/sdk/include/reactos/cicero/imclock.h
index 0a2ff2368a8..3392c9a1107 100644
--- a/sdk/include/reactos/cicero/imclock.h
+++ b/sdk/include/reactos/cicero/imclock.h
@@ -7,20 +7,22 @@
#pragma once
-// class _IMCCLock<T_DATA>;
-// class InternalIMCCLock<T_DATA>;
+// class IMCCLOCK<T_DATA>;
+// class IMCCLock<T_DATA>;
// class _IMCLock;
// class IMCLock;
template <typename T_DATA>
-class _IMCCLock
+class IMCCLOCK
{
-public:
+protected:
T_DATA *m_pIMCC;
+
+public:
HIMCC m_hIMCC;
HRESULT m_hr;
- _IMCCLock(HIMCC hIMCC)
+ IMCCLOCK(HIMCC hIMCC)
{
m_pIMCC = NULL;
m_hr = S_OK;
@@ -29,15 +31,15 @@ public:
};
template <typename T_DATA>
-class InternalIMCCLock : public _IMCCLock<T_DATA>
+class IMCCLock : public IMCCLOCK<T_DATA>
{
public:
- InternalIMCCLock(HIMCC hIMCC) : _IMCCLock<T_DATA>(hIMCC)
+ IMCCLock(HIMCC hIMCC) : IMCCLOCK<T_DATA>(hIMCC)
{
if (hIMCC)
_LockIMCC(this->m_hIMCC, &this->m_pIMCC);
}
- ~InternalIMCCLock()
+ ~IMCCLock()
{
if (this->m_pIMCC)
_UnlockIMCC(this->m_hIMCC);
@@ -46,6 +48,10 @@ public:
{
return this->m_pIMCC;
}
+ T_DATA& get() const
+ {
+ return *this->m_pIMCC;
+ }
protected:
HRESULT _LockIMCC(HIMCC hIMCC, T_DATA **pptr)
@@ -63,15 +69,17 @@ protected:
}
};
-class _IMCLock
+class IMCLOCK
{
-public:
+protected:
LPINPUTCONTEXTDX m_pIC;
+
+public:
HIMC m_hIMC;
HRESULT m_hr;
DWORD m_dw3;
- _IMCLock(HIMC hIMC)
+ IMCLOCK(HIMC hIMC)
{
m_pIC = NULL;
m_hIMC = hIMC;
@@ -85,10 +93,10 @@ public:
}
};
-class IMCLock : public _IMCLock
+class IMCLock : public IMCLOCK
{
public:
- IMCLock(HIMC hIMC) : _IMCLock(hIMC)
+ IMCLock(HIMC hIMC) : IMCLOCK(hIMC)
{
m_hr = _LockIMC(hIMC, &m_pIC);
}
@@ -111,11 +119,11 @@ public:
if (ImmGetIMCCSize(m_pIC->hCompStr) < sizeof(COMPOSITIONSTRING))
return FALSE;
- InternalIMCCLock<COMPOSITIONSTRING> imccLock(m_pIC->hCompStr);
+ IMCCLock<COMPOSITIONSTRING> imccLock(m_pIC->hCompStr);
if (!imccLock)
return FALSE;
- return imccLock.m_pIMCC->dwCompStrLen > 0;
+ return imccLock.get().dwCompStrLen > 0;
}
BOOL UseVerticalCompWindow() const
@@ -127,6 +135,10 @@ public:
{
return m_pIC;
}
+ INPUTCONTEXTDX& get() const
+ {
+ return *m_pIC;
+ }
protected:
HRESULT _LockIMC(HIMC hIMC, LPINPUTCONTEXTDX *ppIC)