Changeset 78756 in vbox for trunk/include/VBox
- Timestamp:
- May 26, 2019 2:59:24 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 130843
- Location:
- trunk/include/VBox/com
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/microatl.h
r76585 r78756 1050 1050 1051 1051 HRESULT hrc = E_OUTOFMEMORY; 1052 CComObject<Base> *p = new(std::nothrow) CComObject<Base>(); 1052 CComObject<Base> *p = NULL; 1053 try 1054 { 1055 p = new CComObject<Base>(); 1056 } 1057 catch (std::bad_alloc &) 1058 { 1059 p = NULL; 1060 } 1053 1061 if (p) 1054 1062 { 1055 1063 p->InternalFinalConstructAddRef(); 1056 hrc = p->_AtlInitialConstruct(); 1057 if (SUCCEEDED(hrc)) 1058 hrc = p->FinalConstruct(); 1064 try 1065 { 1066 hrc = p->_AtlInitialConstruct(); 1067 if (SUCCEEDED(hrc)) 1068 hrc = p->FinalConstruct(); 1069 } 1070 catch (std::bad_alloc &) 1071 { 1072 hrc = E_OUTOFMEMORY; 1073 } 1059 1074 p->InternalFinalConstructRelease(); 1060 1075 if (FAILED(hrc)) -
trunk/include/VBox/com/ptr.h
r76585 r78756 469 469 * object doesn't increase the lock count of the server module, as it 470 470 * does otherwise. 471 * 472 * @note In order to make it easier to use, this method does _not_ throw 473 * bad_alloc, but instead returns E_OUTOFMEMORY. 471 474 */ 472 475 HRESULT createObject() 473 476 { 474 HRESULT rc;477 HRESULT hrc; 475 478 #ifndef VBOX_WITH_XPCOM 476 479 # ifdef VBOX_COM_OUTOFPROC_MODULE 477 ATL::CComObjectNoLock<T> *obj = new ATL::CComObjectNoLock<T>(); 480 ATL::CComObjectNoLock<T> *obj = NULL; 481 try 482 { 483 obj = new ATL::CComObjectNoLock<T>(); 484 } 485 catch (std::bad_alloc &) 486 { 487 obj = NULL; 488 } 478 489 if (obj) 479 490 { 480 491 obj->InternalFinalConstructAddRef(); 481 rc = obj->FinalConstruct(); 492 try 493 { 494 hrc = obj->FinalConstruct(); 495 } 496 catch (std::bad_alloc &) 497 { 498 hrc = E_OUTOFMEMORY; 499 } 482 500 obj->InternalFinalConstructRelease(); 501 if (FAILED(hrc)) 502 { 503 delete obj; 504 obj = NULL; 505 } 483 506 } 484 507 else 485 rc = E_OUTOFMEMORY;508 hrc = E_OUTOFMEMORY; 486 509 # else 487 510 ATL::CComObject<T> *obj = NULL; 488 rc = ATL::CComObject<T>::CreateInstance(&obj);511 hrc = ATL::CComObject<T>::CreateInstance(&obj); 489 512 # endif 490 513 #else /* VBOX_WITH_XPCOM */ 491 ATL::CComObject<T> *obj = new ATL::CComObject<T>(); 514 ATL::CComObject<T> *obj; 515 try 516 { 517 obj = new ATL::CComObject<T>(); 518 } 519 catch (std::bad_alloc &) 520 { 521 obj = NULL; 522 } 492 523 if (obj) 493 rc = obj->FinalConstruct(); 524 { 525 try 526 { 527 hrc = obj->FinalConstruct(); 528 } 529 catch (std::bad_alloc &) 530 { 531 delete obj; 532 obj = NULL; 533 hrc = E_OUTOFMEMORY; 534 } 535 } 494 536 else 495 rc = E_OUTOFMEMORY;537 hrc = E_OUTOFMEMORY; 496 538 #endif /* VBOX_WITH_XPCOM */ 497 539 *this = obj; 498 return rc;540 return hrc; 499 541 } 500 542 };
Note:
See TracChangeset
for help on using the changeset viewer.