[commit] r1368 - trunk/GME/PartBrowser
GMESRC Repository Notifications
gme-commit at list.isis.vanderbilt.edu
Fri Jun 17 17:16:20 CDT 2011
Author: ksmyth
Date: Fri Jun 17 17:16:20 2011
New Revision: 1368
Log:
Fix CrashRpt ca28b809-0c03-4fe5-a3bf-08c0af3ff279 (hopefully). Convert from MIDL headers to #import compiler intrinsic
Modified:
trunk/GME/PartBrowser/PartBrowser.vcxproj
trunk/GME/PartBrowser/PartBrowserCtrl.cpp
trunk/GME/PartBrowser/PartBrowserPane.cpp
trunk/GME/PartBrowser/PartBrowserPane.h
trunk/GME/PartBrowser/stdafx.cpp
trunk/GME/PartBrowser/stdafx.h
Modified: trunk/GME/PartBrowser/PartBrowser.vcxproj
==============================================================================
--- trunk/GME/PartBrowser/PartBrowser.vcxproj Fri Jun 17 17:02:44 2011 (r1367)
+++ trunk/GME/PartBrowser/PartBrowser.vcxproj Fri Jun 17 17:16:20 2011 (r1368)
@@ -62,7 +62,7 @@
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>../Common;../Interfaces;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>../Common;../Interfaces;$(OutDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
@@ -97,7 +97,7 @@
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
- <AdditionalIncludeDirectories>../Common;../Interfaces;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>../Common;../Interfaces;$(OutDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>Use</PrecompiledHeader>
@@ -128,10 +128,42 @@
<Project>{bef31e1e-bb02-4687-a543-a6ad5d522869}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
+ <ProjectReference Include="..\Gme\GME.vcxproj">
+ <Project>{10471163-556b-4be1-a12e-c917f90f8346}</Project>
+ <Private>false</Private>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
+ <LinkLibraryDependencies>false</LinkLibraryDependencies>
+ <UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
+ </ProjectReference>
<ProjectReference Include="..\Interfaces\Interfaces.vcxproj">
<Project>{a9ba4850-c3d5-45dc-98b3-c29ec9fd54eb}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
+ <ProjectReference Include="..\Meta\Meta.vcxproj">
+ <Project>{3ed3216e-b64c-4d0b-881f-68bff2cb3e83}</Project>
+ <Private>false</Private>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
+ <LinkLibraryDependencies>false</LinkLibraryDependencies>
+ <UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
+ </ProjectReference>
+ <ProjectReference Include="..\MgaUtil\MgaUtil.vcxproj">
+ <Project>{ca09ab5c-bfac-4152-ae0b-d5afc400a5e7}</Project>
+ <Private>false</Private>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
+ <LinkLibraryDependencies>false</LinkLibraryDependencies>
+ <UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
+ </ProjectReference>
+ <ProjectReference Include="..\Mga\Mga.vcxproj">
+ <Project>{86daef74-2527-41e5-82ce-52c31c5bbe8e}</Project>
+ <Private>false</Private>
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
+ <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
+ <LinkLibraryDependencies>false</LinkLibraryDependencies>
+ <UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\Common\CommonError.cpp" />
Modified: trunk/GME/PartBrowser/PartBrowserCtrl.cpp
==============================================================================
--- trunk/GME/PartBrowser/PartBrowserCtrl.cpp Fri Jun 17 17:02:44 2011 (r1367)
+++ trunk/GME/PartBrowser/PartBrowserCtrl.cpp Fri Jun 17 17:16:20 2011 (r1368)
@@ -4,7 +4,6 @@
#include "PartBrowser.h"
#include "PartBrowserCtrl.h"
#include "PartBrowserPropPage.h"
-#include "..\Interfaces\Mga_i.c"
#ifdef _DEBUG
#define new DEBUG_NEW
@@ -59,7 +58,7 @@
/////////////////////////////////////////////////////////////////////////////
// Native COM interface map - peter
BEGIN_INTERFACE_MAP(CPartBrowserCtrl, COleControl)
- INTERFACE_PART(CPartBrowserCtrl, IID_IMgaEventSink, EventSink)
+ INTERFACE_PART(CPartBrowserCtrl, __uuidof(IMgaEventSink), EventSink)
END_INTERFACE_MAP()
Modified: trunk/GME/PartBrowser/PartBrowserPane.cpp
==============================================================================
--- trunk/GME/PartBrowser/PartBrowserPane.cpp Fri Jun 17 17:02:44 2011 (r1367)
+++ trunk/GME/PartBrowser/PartBrowserPane.cpp Fri Jun 17 17:16:20 2011 (r1368)
@@ -6,7 +6,7 @@
#include "PartBrowserPaneFrame.h"
#include "..\Annotator\AnnotationDefs.h"
#include "..\GME\GMEOLEData.h"
-#include "Gme_i.c"
+#include <algorithm>
#ifdef _DEBUG
@@ -45,7 +45,7 @@
txtMetricFont.DeleteObject();
}
-CComBSTR CPartBrowserPane::GetDecoratorProgId(CComPtr<IMgaMetaFCO> metaFCO)
+CComBSTR CPartBrowserPane::GetDecoratorProgId(IMgaMetaFCO* metaFCO)
{
CComBSTR pathBstr(DECORATOR_PREF);
CComBSTR bstrVal;
@@ -119,73 +119,63 @@
PartWithDecorator tuple;
tuple.part = metaPart;
- CComPtr<IMgaMetaRole> mmRole;
- COMTHROW(metaPart->get_Role(&mmRole));
- CComPtr<IMgaMetaFCO> mFco;
- COMTHROW(mmRole->get_Kind(&mFco));
- CComPtr<IMgaDecorator> decorator;
- CComPtr<IMgaElementDecorator> newDecorator;
+ IMgaMetaRolePtr mmRole = metaPart->Role;
+ IMgaMetaFCOPtr mFco = mmRole->Kind;
+ IMgaDecoratorPtr decorator;
+ IMgaElementDecoratorPtr newDecorator;
CComBSTR decoratorProgId = GetDecoratorProgId(mFco);
CString nameString;
- CComBSTR bstrKindName;
- COMTHROW(mFco->get_Name(&bstrKindName));
- CComBSTR bstrRoleName;
- COMTHROW(mmRole->get_Name(&bstrRoleName));
+ _bstr_t bstrKindName = mFco->Name;
+ _bstr_t bstrRoleName = mmRole->Name;
if (bstrKindName == bstrRoleName) {
- CComBSTR bstrDisplayedName;
- COMTHROW(mFco->get_DisplayedName(&bstrDisplayedName));
- CopyTo(bstrDisplayedName,nameString);
+ _bstr_t bstrDisplayedName = mFco->DisplayedName;
+ nameString = (const wchar_t*)bstrDisplayedName;
}
else {
- CopyTo(bstrRoleName,nameString);
+ nameString = (const wchar_t*)bstrRoleName;
}
tuple.name = nameString;
- try {
- HRESULT hres = newDecorator.CoCreateInstance(PutInBstr(decoratorProgId));
- if (FAILED(hres) && hres != CO_E_CLASSSTRING) { // might be an old decorator
- hres = decorator.CoCreateInstance(PutInBstr(decoratorProgId));
- }
- if (FAILED(hres)) { // fall back to default decorator
- decoratorProgId = GME_DEFAULT_DECORATOR;
- COMTHROW(newDecorator.CoCreateInstance(PutInBstr(decoratorProgId)));
- }
-
- if (newDecorator) {
- tuple.newDecorator = newDecorator;
- decorator = CComQIPtr<IMgaDecorator>(newDecorator);
- COMTHROW(newDecorator->InitializeEx(mgaProject, metaPart, NULL, NULL /*decorEventSinkIface*/, (ULONGLONG)m_hWnd));
- } else {
- COMTHROW(decorator->Initialize(mgaProject, metaPart, NULL));
- }
+ HRESULT hres = newDecorator.CreateInstance((LPCWSTR)decoratorProgId);
+ if (FAILED(hres) && hres != CO_E_CLASSSTRING) { // might be an old decorator
+ hres = decorator.CreateInstance(PutInBstr(decoratorProgId));
}
- catch (hresult_exception&) {
+ if (FAILED(hres)) { // fall back to default decorator
+ COMTHROW(newDecorator.CreateInstance(GME_DEFAULT_DECORATOR));
+ }
+
+ if (newDecorator) {
+ tuple.newDecorator = newDecorator;
+ // KMS: this is a workaround for a bug in many decorators: QI(IID_IMgaDecorator) returns E_NOINTERFACE
+ // (Fixed in MetaGME and UML in r1367)
+ decorator = (IMgaDecorator*)(IMgaElementDecorator*)newDecorator;
+ newDecorator->__InitializeEx(mgaProject, metaPart, NULL, NULL /*decorEventSinkIface*/, (ULONGLONG)m_hWnd);
+ } else {
+ decorator->__Initialize(mgaProject, metaPart, NULL);
}
long sx, sy;
- COMTHROW(decorator->GetPreferredSize(&sx, &sy));
- COMTHROW(decorator->SetLocation(0, 0, sx, sy));
+ decorator->__GetPreferredSize(&sx, &sy);
+ decorator->__SetLocation(0, 0, sx, sy);
tuple.decorator = decorator;
- // Insert/append in alphabetical order
- std::vector<PartWithDecorator>::iterator ii = pdt.begin();
- while (ii != pdt.end()) {
- if ((*ii).name >= tuple.name)
- break;
- ++ii;
- }
- if (ii == pdt.end())
- pdt.push_back(tuple);
- else
- pdt.insert(ii, tuple);
+ pdt.push_back(tuple);
}
}
MGACOLL_ITERATE_END;
}
- catch (hresult_exception&) {
+ catch (hresult_exception& e) {
+ _bstr_t error;
+ GetErrorInfo(e.hr, error.GetAddress());
+ CGMEDataSource::get_GME(CComObjPtr<IMgaProject>(mgaProject))->ConsoleMessage(error, MSG_ERROR);
+ return;
+ }
+ catch (_com_error& e) {
+ CGMEDataSource::get_GME(CComObjPtr<IMgaProject>(mgaProject))->ConsoleMessage(_bstr_t(L"Couldn't initialize decorator: " + e.Description()), MSG_ERROR);
return;
}
+ std::sort(pdt.begin(), pdt.end(), [](const PartWithDecorator& a, const PartWithDecorator& b){ return a.name < b.name; });
pdts.push_back(pdt);
}
Modified: trunk/GME/PartBrowser/PartBrowserPane.h
==============================================================================
--- trunk/GME/PartBrowser/PartBrowserPane.h Fri Jun 17 17:02:44 2011 (r1367)
+++ trunk/GME/PartBrowser/PartBrowserPane.h Fri Jun 17 17:16:20 2011 (r1368)
@@ -37,7 +37,7 @@
private:
// Operations
- CComBSTR GetDecoratorProgId(CComPtr<IMgaMetaFCO> metaFCO);
+ CComBSTR GetDecoratorProgId(IMgaMetaFCO* metaFCO);
bool IsPartDisplayable(CComPtr<IMgaMetaPart> metaPart);
bool FindObject(CPoint &pt, PartWithDecorator& pdt);
void CreateDecorators(CComPtr<IMgaMetaParts> metaParts);
Modified: trunk/GME/PartBrowser/stdafx.cpp
==============================================================================
--- trunk/GME/PartBrowser/stdafx.cpp Fri Jun 17 17:02:44 2011 (r1367)
+++ trunk/GME/PartBrowser/stdafx.cpp Fri Jun 17 17:16:20 2011 (r1368)
@@ -3,3 +3,9 @@
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
+
+#import "Meta.dll" implementation_only auto_search no_namespace no_search_namespace raw_method_prefix("") high_method_prefix("__")
+#import "Mga.dll" implementation_only auto_search no_namespace no_search_namespace raw_method_prefix("") high_method_prefix("__")
+#import "GME.exe" implementation_only auto_search no_namespace no_search_namespace raw_method_prefix("") high_method_prefix("__")
+#import "MgaUtil.dll" implementation_only auto_search no_namespace no_search_namespace raw_method_prefix("") high_method_prefix("__")
+
Modified: trunk/GME/PartBrowser/stdafx.h
==============================================================================
--- trunk/GME/PartBrowser/stdafx.h Fri Jun 17 17:02:44 2011 (r1367)
+++ trunk/GME/PartBrowser/stdafx.h Fri Jun 17 17:16:20 2011 (r1368)
@@ -1,6 +1,3 @@
-#if !defined(AFX_STDAFX_H__A72BCE1F_468F_4b23_A08F_E29356EF3659__INCLUDED_)
-#define AFX_STDAFX_H__A72BCE1F_468F_4b23_A08F_E29356EF3659__INCLUDED_
-
#pragma once
#ifndef _SECURE_ATL
@@ -33,20 +30,26 @@
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
-// Delete the two includes below if you do not wish to use the MFC
-// database classes
-#include <afxdb.h> // MFC database classes
-#include <afxdao.h> // MFC DAO database classes
-
#include <atlbase.h>
//You may derive a class from CComModule and use it if you want to override
//something, but do not change the name of _Module
extern CComModule _Module;
#include <atlcom.h>
-#include "Meta.h"
-#include "MgaUtil.h"
-#include "GME.h"
+#import "Meta.dll" no_implementation auto_search no_namespace no_search_namespace raw_method_prefix("") high_method_prefix("__")
+#import "Mga.dll" no_implementation auto_search no_namespace no_search_namespace raw_method_prefix("") high_method_prefix("__")
+#import "GME.exe" no_implementation auto_search no_namespace no_search_namespace raw_method_prefix("") high_method_prefix("__")
+#import "MgaUtil.dll" no_implementation auto_search no_namespace no_search_namespace raw_method_prefix("") high_method_prefix("__")
+
+// Don't load the MIDL-generated headers
+#define __Core_h__
+#define __Meta_h__
+#define __Mga_h__
+#define __MgaUtil_h__
+#define __Gme_h__
+
+#define IID_IMgaDataSource __uuidof(IMgaDataSource)
+
#include "CommonError.h"
#include "CommonSmart.h"
#include "CommonMfc.h"
@@ -65,5 +68,3 @@
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_STDAFX_H__A72BCE1F_468F_4b23_A08F_E29356EF3659__INCLUDED_)
More information about the gme-commit
mailing list