44
55void WeaselTSF::_ClearCompositionDisplayAttributes (TfEditCookie ec,
66 _In_ ITfContext* pContext) {
7- ITfRange* pRangeComposition = nullptr ;
8- ITfProperty* pDisplayAttributeProperty = nullptr ;
7+ com_ptr< ITfRange> pRangeComposition = nullptr ;
8+ com_ptr< ITfProperty> pDisplayAttributeProperty = nullptr ;
99
1010 if (FAILED (_pComposition->GetRange (&pRangeComposition))) {
1111 return ;
@@ -14,17 +14,13 @@ void WeaselTSF::_ClearCompositionDisplayAttributes(TfEditCookie ec,
1414 if (SUCCEEDED (pContext->GetProperty (GUID_PROP_ATTRIBUTE,
1515 &pDisplayAttributeProperty))) {
1616 pDisplayAttributeProperty->Clear (ec, pRangeComposition);
17-
18- pDisplayAttributeProperty->Release ();
1917 }
20-
21- pRangeComposition->Release ();
2218}
2319
2420BOOL WeaselTSF::_SetCompositionDisplayAttributes (TfEditCookie ec,
2521 _In_ ITfContext* pContext,
2622 ITfRange* pRangeComposition) {
27- ITfProperty* pDisplayAttributeProperty = nullptr ;
23+ com_ptr< ITfProperty> pDisplayAttributeProperty = nullptr ;
2824 HRESULT hr = S_OK;
2925
3026 if (pRangeComposition == nullptr )
@@ -40,10 +36,7 @@ BOOL WeaselTSF::_SetCompositionDisplayAttributes(TfEditCookie ec,
4036 VARIANT var;
4137 var.vt = VT_I4; // we're going to set a TfGuidAtom
4238 var.lVal = _gaDisplayAttributeInput;
43-
4439 hr = pDisplayAttributeProperty->SetValue (ec, pRangeComposition, &var);
45-
46- pDisplayAttributeProperty->Release ();
4740 }
4841
4942 // DO NOT release range composition here
@@ -53,7 +46,7 @@ BOOL WeaselTSF::_SetCompositionDisplayAttributes(TfEditCookie ec,
5346}
5447
5548BOOL WeaselTSF::_InitDisplayAttributeGuidAtom () {
56- ITfCategoryMgr* pCategoryMgr = nullptr ;
49+ com_ptr< ITfCategoryMgr> pCategoryMgr = nullptr ;
5750 HRESULT hr =
5851 CoCreateInstance (CLSID_TF_CategoryMgr, nullptr , CLSCTX_INPROC_SERVER,
5952 IID_ITfCategoryMgr, (void **)&pCategoryMgr);
@@ -69,7 +62,5 @@ BOOL WeaselTSF::_InitDisplayAttributeGuidAtom() {
6962 }
7063
7164Exit:
72- pCategoryMgr->Release ();
73-
7465 return (hr == S_OK);
7566}
0 commit comments