diff --git a/src/syncevo/GLibSupport.h b/src/syncevo/GLibSupport.h index a36da39d..08e1b8ef 100644 --- a/src/syncevo/GLibSupport.h +++ b/src/syncevo/GLibSupport.h @@ -43,6 +43,7 @@ typedef void *GMainLoop; #include #include +#include #include SE_BEGIN_CXX @@ -581,7 +582,7 @@ template class GAsyncReadyCXX { GErrorCXX gerror; T t = finish(reinterpret_cast(sourceObject), result, gerror); - CXXFunctionCB_t *cb = static_cast(userData); + std::auto_ptr cb(static_cast(userData)); (*cb)(gerror, t); } catch (...) { // called from C, must not let exception escape @@ -602,7 +603,7 @@ template class GAsyncReadyCXX(sourceObject), result); - CXXFunctionCB_t *cb = static_cast(userData); + std::auto_ptr cb(static_cast(userData)); (*cb)(t); } catch (...) { // called from C, must not let exception escape @@ -623,7 +624,7 @@ template class GAsyncReadyCXX(userData); + std::auto_ptr cb(static_cast(userData)); (*cb)(gerror, t); } catch (...) { // called from C, must not let exception escape @@ -644,14 +645,8 @@ template class GAsyncReadyCXX(sourceObject), result, gerror); - CXXFunctionCB_t *cb = static_cast(userData); - try { - (*cb)(gerror); - } catch (...) { - delete cb; - throw; - } - delete cb; + std::auto_ptr cb(static_cast(userData)); + (*cb)(gerror); } catch (...) { // called from C, must not let exception escape Exception::handle(HANDLE_EXCEPTION_FATAL); @@ -671,14 +666,8 @@ template class GAsyncReadyCXX(sourceObject), result); - CXXFunctionCB_t *cb = static_cast(userData); - try { - (*cb)(); - } catch (...) { - delete cb; - throw; - } - delete cb; + std::auto_ptr cb(static_cast(userData)); + (*cb)(); } catch (...) { // called from C, must not let exception escape Exception::handle(HANDLE_EXCEPTION_FATAL); @@ -698,14 +687,8 @@ template class GAsyncReadyCXX(userData); - try { - (*cb)(gerror); - } catch (...) { - delete cb; - throw; - } - delete cb; + std::auto_ptr cb(static_cast(userData)); + (*cb)(gerror); } catch (...) { // called from C, must not let exception escape Exception::handle(HANDLE_EXCEPTION_FATAL);