[Cppunit-cvs] cppunit2/src/opentest sharedmemorytransport.cpp,1.4,1.5
Brought to you by:
blep
From: Baptiste L. <bl...@us...> - 2006-01-31 08:08:46
|
Update of /cvsroot/cppunit/cppunit2/src/opentest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21157/src/opentest Modified Files: sharedmemorytransport.cpp Log Message: * fixed compilation error on VC 8.0 (AutoHandle was being copied). Index: sharedmemorytransport.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/opentest/sharedmemorytransport.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** sharedmemorytransport.cpp 6 Sep 2005 07:31:42 -0000 1.4 --- sharedmemorytransport.cpp 31 Jan 2006 08:08:38 -0000 1.5 *************** *** 43,54 **** // ////////////////////////////////////////////////////////////////// ! class AutoHandle : public CppTL::NonCopyable { public: ! AutoHandle( HANDLE handle = 0 ) : handle_( handle ) { } ~AutoHandle() { --- 43,74 ---- // ////////////////////////////////////////////////////////////////// ! class AutoHandle { public: ! AutoHandle() ! : handle_( 0 ) ! { ! } ! ! explicit AutoHandle( HANDLE handle ) : handle_( handle ) { } + AutoHandle( const AutoHandle &other ) + : handle_( 0 ) + { + if ( other.handle_ ) + { + ::DuplicateHandle( GetCurrentProcess(), + other.handle_, + GetCurrentProcess(), + &handle_, + 0, + TRUE, // handle may be inherited by child process + DUPLICATE_SAME_ACCESS ); + } + } + ~AutoHandle() { *************** *** 64,73 **** AutoHandle &operator =( HANDLE handle ) { ! if ( handle_ ) ! ::CloseHandle( handle_ ); ! handle_ = handle; return *this; } private: HANDLE handle_; --- 84,101 ---- AutoHandle &operator =( HANDLE handle ) { ! if ( handle != handle_ ) ! { ! if ( handle_ ) ! ::CloseHandle( handle_ ); ! handle_ = handle; ! } return *this; } + AutoHandle &operator =( const AutoHandle &other ) + { + return *this = other.handle_; + } + private: HANDLE handle_; *************** *** 437,441 **** SharedMemoryTransportImpl::autoManage( HANDLE handle ) { ! handles_.push_back( handle ); return handle; } --- 465,470 ---- SharedMemoryTransportImpl::autoManage( HANDLE handle ) { ! AutoHandle autoHandle( handle ); ! handles_.push_back( autoHandle ); return handle; } |