[commit] r1437 - trunk/GME/Gme

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Tue Jul 26 11:01:35 CDT 2011


Author: ksmyth
Date: Tue Jul 26 11:01:35 2011
New Revision: 1437

Log:
Fix memory leak

Modified:
   trunk/GME/Gme/GUIObject.cpp
   trunk/GME/Gme/GUIObject.h

Modified: trunk/GME/Gme/GUIObject.cpp
==============================================================================
--- trunk/GME/Gme/GUIObject.cpp	Tue Jul 26 11:00:47 2011	(r1436)
+++ trunk/GME/Gme/GUIObject.cpp	Tue Jul 26 11:01:35 2011	(r1437)
@@ -1914,8 +1914,16 @@
 		else
 			COMTHROW(GetCurrentAspect()->GetDecorator()->Draw((ULONG)pDC));
 	}
-	catch (hresult_exception &) {
-		AfxMessageBox(_T("Error in decorator [method Draw()]"));
+	catch (hresult_exception &e) {
+		CComQIPtr<ISupportErrorInfo> errorInfo = GetCurrentAspect()->GetDecorator();
+		_bstr_t error;
+		if (errorInfo) {
+			GetErrorInfo(error.GetAddress());
+		} else {
+			GetErrorInfo(e.hr, error.GetAddress());
+		}
+		// FIXME: KMS: won't Draw() be called after the MessageBox is dismissed?
+		AfxMessageBox(CString(_T("Error in decorator [method Draw()]: ")) + static_cast<const TCHAR*>(error));
 	}
 
 // #define _ARDEBUG
@@ -2423,7 +2431,6 @@
 
 CGuiConnection::CGuiConnection(CComPtr<IMgaFCO>& pt, CComPtr<IMgaMetaRole>& role, CGMEView* vw, int numAsp, bool resolve):
 	CGuiFco(pt, role, vw, numAsp),
-	visible					(NULL),
 	src						(NULL),
 	srcPort					(NULL),
 	dst						(NULL),
@@ -2559,8 +2566,8 @@
 		VERIFY(conn);
 
 		// Compute visibility
-		visible = new bool[numParentAspects];
-		memset(visible, 0, numParentAspects * sizeof(bool));
+		visible = std::unique_ptr<bool[]>(new bool[numParentAspects]);
+		memset(visible.get(), 0, numParentAspects * sizeof(bool));
 		CComPtr<IMgaMetaParts> mmParts;
 		COMTHROW(metaRole->get_Parts(&mmParts));
 		MGACOLL_ITERATE(IMgaMetaPart,mmParts) {

Modified: trunk/GME/Gme/GUIObject.h
==============================================================================
--- trunk/GME/Gme/GUIObject.h	Tue Jul 26 11:00:47 2011	(r1436)
+++ trunk/GME/Gme/GUIObject.h	Tue Jul 26 11:01:35 2011	(r1437)
@@ -4,6 +4,7 @@
 #include "Autoroute/AutoRouter.h"
 #include "GMEStd.h"
 #include <vector>
+#include <memory>
 
 class CGMEView;
 class CModelGrid;
@@ -430,7 +431,7 @@
 {
 public:
 	CGuiConnection(CComPtr<IMgaFCO>& pt, CComPtr<IMgaMetaRole>& role, CGMEView* vw, int numAsp, bool resolve = true);
-	virtual ~CGuiConnection() { delete visible; }
+	virtual ~CGuiConnection() { }
 
 	// This is a trick to speed up dynamic_cast
 	virtual CGuiConnection*			dynamic_cast_CGuiConnection(void)			{ return this; }
@@ -502,7 +503,7 @@
 private:
 	CAutoRouterPath* routerPath;
 	CGuiConnectionLabelSet labelset;
-	bool* visible;
+	std::unique_ptr<bool[]> visible;
 	GMEConnLineType lineType;
 	int srcStyle;
 	int dstStyle;


More information about the gme-commit mailing list