DXGL r348 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r347‎ | r348 | r349 >
Date:22:44, 16 March 2013
Author:admin
Status:new
Tags:
Comment:
Trace glClassFactory.cpp
Fix return values for invalid glClassFactory object.
Fix creating clipper objects via COM initialization.
Modified paths:
  • /ddraw/glClassFactory.cpp (modified) (history)
  • /ddraw/trace.cpp (modified) (history)

Diff [purge]

Index: ddraw/glClassFactory.cpp
@@ -24,24 +24,29 @@
2525
2626 ULONG WINAPI glClassFactory::AddRef()
2727 {
28 - if(!this) return DDERR_INVALIDPARAMS;
 28+ TRACE_ENTER(1,14,this);
 29+ if(!this) TRACE_RET(8,0);
2930 refcount++;
 31+ TRACE_EXIT(8,refcount);
3032 return refcount;
3133 }
3234 ULONG WINAPI glClassFactory::Release()
3335 {
34 - if(!this) return DDERR_INVALIDPARAMS;
 36+ TRACE_ENTER(1,14,this);
 37+ if(!this) TRACE_RET(8,0);
3538 ULONG ret;
3639 refcount--;
3740 ret = refcount;
3841 if(refcount == 0) delete this;
 42+ TRACE_EXIT(8,ret);
3943 return ret;
4044 }
4145
4246 HRESULT WINAPI glClassFactory::QueryInterface(REFIID riid, void** ppvObj)
4347 {
44 - if(!this) return DDERR_INVALIDPARAMS;
45 - if(!ppvObj) return DDERR_INVALIDPARAMS;
 48+ TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
 49+ if(!this) TRACE_RET(23,DDERR_INVALIDOBJECT);
 50+ if(!ppvObj) TRACE_RET(23,DDERR_INVALIDPARAMS);
4651 if((riid == IID_IUnknown) || (riid == IID_IClassFactory))
4752 {
4853 *ppvObj = this;
@@ -50,20 +55,25 @@
5156 else
5257 {
5358 *ppvObj = NULL;
54 - return E_NOINTERFACE;
 59+ TRACE_RET(23,E_NOINTERFACE);
5560 }
 61+ TRACE_VAR("*ppvObj",14,*ppvObj);
 62+ TRACE_EXIT(23,S_OK);
5663 return S_OK;
5764 }
5865 HRESULT WINAPI glClassFactory::CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppvObject)
5966 {
60 - if(!this) return DDERR_INVALIDPARAMS;
 67+ TRACE_ENTER(4,14,this,14,pUnkOuter,24,&riid,14,ppvObject);
 68+ if(!this) TRACE_RET(23,DDERR_INVALIDOBJECT);
6169 glDirectDraw7 *glDD7;
62 - if(pUnkOuter != NULL) return CLASS_E_NOAGGREGATION;
 70+ if(pUnkOuter != NULL) TRACE_RET(23,CLASS_E_NOAGGREGATION);
6371 if(riid == IID_IDirectDraw)
6472 {
6573 glDD7 = new glDirectDraw7;
6674 glDD7->QueryInterface(IID_IDirectDraw,ppvObject);
6775 glDD7->Release();
 76+ TRACE_VAR("*ppvObject",14,*ppvObject);
 77+ TRACE_EXIT(23,S_OK);
6878 return S_OK;
6979 }
7080 if(riid == IID_IDirectDraw2)
@@ -71,6 +81,8 @@
7282 glDD7 = new glDirectDraw7;
7383 glDD7->QueryInterface(IID_IDirectDraw2,ppvObject);
7484 glDD7->Release();
 85+ TRACE_VAR("*ppvObject",14,*ppvObject);
 86+ TRACE_EXIT(23,S_OK);
7587 return S_OK;
7688 }
7789 if(riid == IID_IDirectDraw4)
@@ -78,25 +90,35 @@
7991 glDD7 = new glDirectDraw7;
8092 glDD7->QueryInterface(IID_IDirectDraw4,ppvObject);
8193 glDD7->Release();
 94+ TRACE_VAR("*ppvObject",14,*ppvObject);
 95+ TRACE_EXIT(23,S_OK);
8296 return S_OK;
8397 }
8498 if(riid == IID_IDirectDraw7)
8599 {
86100 *ppvObject = new glDirectDraw7();
 101+ TRACE_VAR("*ppvObject",14,*ppvObject);
 102+ TRACE_EXIT(23,S_OK);
87103 return S_OK;
88104 }
89105 if(riid == IID_IDirectDrawClipper)
90106 {
91107 *ppvObject = new glDirectDrawClipper();
 108+ TRACE_VAR("*ppvObject",14,*ppvObject);
 109+ TRACE_EXIT(23,S_OK);
 110+ return S_OK;
92111 }
93112 FIXME("glClassFactory::CreateInterface: stub");
 113+ TRACE_EXIT(23,E_NOINTERFACE);
94114 return E_NOINTERFACE;
95115 }
96116 HRESULT WINAPI glClassFactory::LockServer(BOOL fLock)
97117 {
98 - if(!this) return DDERR_INVALIDPARAMS;
 118+ TRACE_ENTER(2,14,this,22,fLock);
 119+ if(!this) TRACE_RET(23,DDERR_INVALIDOBJECT);
99120 if(fLock) InterlockedIncrement(&locks);
100121 else InterlockedDecrement(&locks);
 122+ TRACE_EXIT(23,S_OK);
101123 return S_OK;
102124 }
103125
Index: ddraw/trace.cpp
@@ -240,6 +240,9 @@
241241 case E_NOINTERFACE:
242242 strcpy(str,"E_NOINTERFACE");
243243 break;
 244+ case CLASS_E_NOAGGREGATION:
 245+ strcpy(str,"CLASS_E_NOAGGREGATION");
 246+ break;
244247 default:
245248 sprintf(str,"(HRESULT)0x%08X",hr);
246249 break;