diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index a74fbba6c9..a74f2daf73 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -2987,3 +2987,8 @@ u64 thread_ctrl::get_tid() return reinterpret_cast(pthread_self()); #endif } + +bool thread_ctrl::is_main() +{ + return get_tid() == utils::main_tid; +} diff --git a/Utilities/Thread.h b/Utilities/Thread.h index abcc0bc8ff..b10351d76b 100644 --- a/Utilities/Thread.h +++ b/Utilities/Thread.h @@ -342,6 +342,9 @@ public: // Get thread ID (works for all threads) static u64 get_tid(); + // Check whether current thread is main thread (usually Qt GUI) + static bool is_main(); + private: // Miscellaneous static const u64 process_affinity_mask; diff --git a/rpcs3/main.cpp b/rpcs3/main.cpp index 12b89347f5..b1e487074c 100644 --- a/rpcs3/main.cpp +++ b/rpcs3/main.cpp @@ -377,6 +377,8 @@ int main(int argc, char** argv) } #endif + ensure(thread_ctrl::is_main()); + // Initialize TSC freq (in case it isn't) static_cast(utils::get_tsc_freq());