File tree Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Expand file tree Collapse file tree 3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ namespace PokemonAutomation{
2626const  std::set<std::string> SANITIZER_FILTER = {
2727//     "MultiSwitchProgramSession",
2828//     "MultiSwitchProgramWidget2",
29+ //     "VideoSource",
2930};
3031
3132SpinLock sanitizer_lock;
Original file line number Diff line number Diff line change @@ -22,15 +22,19 @@ void queue_on_main_thread(std::function<void()> lambda){
2222
2323
2424void  run_on_main_thread_and_wait (std::function<void ()> lambda){
25-     if  (QCoreApplication::instance ()->thread () == QThread::currentThread ()){
25+     run_on_object_thread_and_wait (QCoreApplication::instance (), std::move (lambda));
26+ }
27+ 
28+ void  run_on_object_thread_and_wait (QObject* object, std::function<void ()> lambda){
29+     if  (object->thread () == QThread::currentThread ()){
2630        lambda ();
2731        return ;
2832    }
2933
3034    std::mutex lock;
3135    std::condition_variable cv;
3236    bool  done = false ;
33-     QMetaObject::invokeMethod (QCoreApplication::instance () , [&]{
37+     QMetaObject::invokeMethod (object , [&]{
3438        lambda ();
3539        std::lock_guard<std::mutex> lg (lock);
3640        done = true ;
@@ -42,4 +46,5 @@ void run_on_main_thread_and_wait(std::function<void()> lambda){
4246
4347
4448
49+ 
4550}
Original file line number Diff line number Diff line change 99
1010#include  < functional> 
1111
12+ class  QObject ;
13+ 
1214namespace  PokemonAutomation {
1315
1416
@@ -18,6 +20,7 @@ void queue_on_main_thread(std::function<void()> lambda);
1820
1921
2022void  run_on_main_thread_and_wait (std::function<void ()> lambda);
23+ void  run_on_object_thread_and_wait (QObject* object, std::function<void ()> lambda);
2124
2225
2326
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments