[commit] r2728 - in trunk: GME/Console GME/MgaUtil SDK/DecoratorLib

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Thu Dec 14 15:03:42 CST 2017


Author: ksmyth
Date: Thu Dec 14 15:03:42 2017
New Revision: 2728

Log:
Fix memory and GDI errors

Modified:
   trunk/GME/Console/ScriptHost.cpp
   trunk/GME/MgaUtil/MgaRegistrar.cpp
   trunk/SDK/DecoratorLib/ModelComplexPart.cpp
   trunk/SDK/DecoratorLib/TextPart.cpp

Modified: trunk/GME/Console/ScriptHost.cpp
==============================================================================
--- trunk/GME/Console/ScriptHost.cpp	Wed Dec  6 13:57:32 2017	(r2727)
+++ trunk/GME/Console/ScriptHost.cpp	Thu Dec 14 15:03:42 2017	(r2728)
@@ -84,6 +84,7 @@
 
 STDMETHODIMP CScriptHost::GetLCID(/*[out]*/ LCID *plcid)
 {
+	*plcid = LANG_ENGLISH;
 	return S_OK;
 }
 
@@ -95,37 +96,40 @@
 {
 	if (!m_gmeptr)
 		return E_FAIL;
-	if (dwReturnMask&SCRIPTINFO_IUNKNOWN)
+	if (dwReturnMask & SCRIPTINFO_IUNKNOWN)
 	{
-		if (m_gmeptr && (_bstr_t)pstrName == _bstr_t(L"gme"))
+		if (m_gmeptr && wcscmp(pstrName, L"gme") == 0)
 		{
 			CComPtr<IUnknown> punk(m_gmeptr);
-			((IUnknown*)punk)->AddRef(); 
-			*ppiunkItem = punk;
+			*ppiunkItem = punk.Detach();
 		}
-		else if (m_mgaproj && (_bstr_t)pstrName == _bstr_t(L"project"))
+		else if (m_mgaproj && wcscmp(pstrName, L"project") == 0)
 		{
 			CComPtr<IUnknown> punk(m_mgaproj);
-			((IUnknown*)punk)->AddRef(); 
-			*ppiunkItem = punk;
+			*ppiunkItem = punk.Detach();
 		}
-		else if (m_actMod && (_bstr_t)pstrName == _bstr_t(L"it"))
+		else if (m_actMod && wcscmp(pstrName, L"it") == 0)
 		{
 			CComPtr<IUnknown> punk(m_actMod);
-			((IUnknown*)punk)->AddRef(); 
-			*ppiunkItem = punk;
+			*ppiunkItem = punk.Detach();
 		}
+		else
+		{
+			return TYPE_E_ELEMENTNOTFOUND;
+		}
+
+		return S_OK;
 	}
-	if (dwReturnMask&SCRIPTINFO_ITYPEINFO)
+	if (dwReturnMask & SCRIPTINFO_ITYPEINFO)
 	{
 	}
-
+	*ppti = NULL;
 	return S_OK;
 }
 
 STDMETHODIMP CScriptHost::GetDocVersionString(/*[out]*/ BSTR      *pbstrVersion)
 {
-	return S_OK;
+	return E_NOTIMPL;
 }
 
 STDMETHODIMP CScriptHost::OnScriptTerminate(

Modified: trunk/GME/MgaUtil/MgaRegistrar.cpp
==============================================================================
--- trunk/GME/MgaUtil/MgaRegistrar.cpp	Wed Dec  6 13:57:32 2017	(r2727)
+++ trunk/GME/MgaUtil/MgaRegistrar.cpp	Thu Dec 14 15:03:42 2017	(r2728)
@@ -1928,8 +1928,10 @@
 				res = comp.QueryStringValue(_T("Description"), NULL, &count);
 				if (strDesc == _T("") && res == ERROR_SUCCESS) {
 					CString ret;
-					if (comp.QueryStringValue(_T("Description"), ret.GetBufferSetLength(count), &count) == ERROR_SUCCESS)
+					if (comp.QueryStringValue(_T("Description"), ret.GetBufferSetLength(count), &count) == ERROR_SUCCESS) {
+						ret.ReleaseBuffer();
 						strDesc = ret;
+					}
 				}
 			}
 		}
@@ -2044,6 +2046,7 @@
 				if (res == ERROR_SUCCESS) {
 					CString ret;
 					if (comp.QueryStringValue(PutInCString(name), ret.GetBufferSetLength(count), &count) == ERROR_SUCCESS) {
+						ret.ReleaseBuffer();
 						CopyTo(ret, pVal);
 						return S_OK;
 					}
@@ -2086,12 +2089,14 @@
 				CString data;
 				ULONG count = 1024;
 				if (comp.QueryStringValue(_T("CodeBase"), data.GetBufferSetLength(count), &count) == ERROR_SUCCESS) {
+					data.ReleaseBuffer();
 					m_strPath = data;
 					m_strPath = m_strPath.Right(m_strPath.GetLength() - 8);
 					m_strPath.Replace('/', '\\');
 				} else {
 					count = 1024;
 					if (comp.QueryStringValue(_T("Assembly"), data.GetBufferSetLength(count), &count) == ERROR_SUCCESS) {
+						data.ReleaseBuffer();
 						m_strPath = _T("GAC: ");
 						m_strPath += data;
 					}

Modified: trunk/SDK/DecoratorLib/ModelComplexPart.cpp
==============================================================================
--- trunk/SDK/DecoratorLib/ModelComplexPart.cpp	Wed Dec  6 13:57:32 2017	(r2727)
+++ trunk/SDK/DecoratorLib/ModelComplexPart.cpp	Thu Dec 14 15:03:42 2017	(r2728)
@@ -182,8 +182,7 @@
 	LOGFONTA logFont;
 	getFacilities().GetFont(FONT_PORT)->gdipFont->GetLogFontA(getFacilities().getGraphics(), &logFont);
 	{
-		CDC dc;
-		dc.Attach(GetDC(NULL));
+		HDC dc = GetDC(NULL);
 		Gdiplus::Graphics g(dc);
 		Gdiplus::Font f(dc, &logFont);
 		Gdiplus::PointF zero(0.0, 0.0);
@@ -213,6 +212,7 @@
 			const_cast<ModelComplexPart*>(this)->m_prominentAttrsNamesCX = max(m_prominentAttrsNamesCX, prominentNameSize.Width);
 			const_cast<ModelComplexPart*>(this)->m_prominentAttrsValuesCX = max(m_prominentAttrsValuesCX, prominentValueSize.Width);
 		}
+		::ReleaseDC(NULL, dc);
 	}
 
 	long lWidth = 0;

Modified: trunk/SDK/DecoratorLib/TextPart.cpp
==============================================================================
--- trunk/SDK/DecoratorLib/TextPart.cpp	Wed Dec  6 13:57:32 2017	(r2727)
+++ trunk/SDK/DecoratorLib/TextPart.cpp	Thu Dec 14 15:03:42 2017	(r2728)
@@ -42,6 +42,7 @@
 
 void TextPart::Initialize(CComPtr<IMgaProject>& pProject, CComPtr<IMgaMetaPart>& pPart, CComPtr<IMgaFCO>& pFCO)
 {
+	resizeLogic.Initialize(pProject, pPart, pFCO);
 	if (m_spFCO)
 		resizeLogic.SetResizeFeatures(ResizeLogic::Resizeable | /* TODO: temp ResizeLogic::Movable |*/ ResizeLogic::DrawSelectionRectangle);
 


More information about the gme-commit mailing list