From f3e78b826754b79639bb38d6c50c5831f6f9ca01 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Mon, 3 Sep 2018 09:46:13 +0100 Subject: [PATCH] utilities: Split thread internal callback function __try is used in pthread_cleanup_push when CLEANUP_SEH is used as the pthread cleanup model. That can't be used in functions with objects that have destructors, so move it into a separate function. Fixes a non-release build compile error on Windows. Regression was introduced in 93d5b52df34c03a2ed859bba6e06fead3b875e70. --- common/include/Utilities/PersistentThread.h | 1 + common/src/Utilities/ThreadTools.cpp | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/common/include/Utilities/PersistentThread.h b/common/include/Utilities/PersistentThread.h index b0f0f660cf..0f4468a210 100644 --- a/common/include/Utilities/PersistentThread.h +++ b/common/include/Utilities/PersistentThread.h @@ -200,6 +200,7 @@ protected: void _ThreadCleanup(); static void *_internal_callback(void *func); + static void internal_callback_helper(void *func); static void _pt_callback_cleanup(void *handle); }; diff --git a/common/src/Utilities/ThreadTools.cpp b/common/src/Utilities/ThreadTools.cpp index 53cbb93ae2..aa18bfa6a9 100644 --- a/common/src/Utilities/ThreadTools.cpp +++ b/common/src/Utilities/ThreadTools.cpp @@ -685,12 +685,21 @@ void *Threading::pxThread::_internal_callback(void *itsme) { if (!pxAssertDev(itsme != NULL, wxNullChar)) return NULL; - pxThread &owner = *((pxThread *)itsme); + + internal_callback_helper(itsme); + return NULL; +} + +// __try is used in pthread_cleanup_push when CLEANUP_SEH is used as the cleanup model. +// That can't be used in a function that has objects that require unwinding (compile +// error C2712), so move it into a separate function. +void Threading::pxThread::internal_callback_helper(void *itsme) +{ + pxThread &owner = *static_cast(itsme); pthread_cleanup_push(_pt_callback_cleanup, itsme); owner._internal_execute(); pthread_cleanup_pop(true); - return NULL; } void Threading::pxThread::_DoSetThreadName(const wxString &name)