OSDN Git Service

[VM][Qt] EmuThread/DrawThread: Wait (not start) until complete to prepare GUI.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Thu, 22 Oct 2020 23:33:53 +0000 (08:33 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Thu, 22 Oct 2020 23:33:53 +0000 (08:33 +0900)
source/src/qt/common/qt_utils.cpp
source/src/qt/gui/draw_thread.cpp
source/src/qt/gui/draw_thread.h
source/src/qt/gui/mainwidget_base.h
source/src/qt/gui/mainwindow_utils.cpp

index 0140fa0..2c18498 100644 (file)
@@ -264,6 +264,7 @@ void Ui_MainWindow::LaunchEmuThread(void)
        connect(hRunEmu, SIGNAL(window_title_changed(QString)), this, SLOT(do_set_window_title(QString)));
        connect(hDrawEmu, SIGNAL(message_changed(QString)), this, SLOT(message_status_bar(QString)));
        connect(actionCapture_Screen, SIGNAL(triggered()), glv, SLOT(do_save_frame_screen()));
+       connect(this, SIGNAL(sig_emu_launched()), glv, SLOT(set_emu_launched()));
 
        /*if(config.use_separate_thread_draw) {
                connect(hRunEmu, SIGNAL(sig_draw_thread(bool)), hDrawEmu, SLOT(doDraw(bool)), Qt::QueuedConnection);
@@ -305,8 +306,6 @@ void Ui_MainWindow::LaunchEmuThread(void)
        objNameStr = QString("EmuDrawThread");
        hDrawEmu->setObjectName(objNameStr);
 
-       if(config.use_separate_thread_draw) hDrawEmu->start();
-
        csp_logger->debug_log(CSP_LOG_INFO, CSP_LOG_TYPE_GENERAL, "DrawThread : Launch done.");
 
        hSaveMovieThread = new MOVIE_SAVER(640, 400,  30, (OSD*)(emu->get_osd()), &config);
@@ -357,7 +356,9 @@ void Ui_MainWindow::LaunchEmuThread(void)
        connect(this, SIGNAL(sig_unblock_task()), hRunEmu, SLOT(do_unblock()));
        connect(this, SIGNAL(sig_block_task()), hRunEmu, SLOT(do_block()));
        connect(this, SIGNAL(sig_start_emu_thread()), hRunEmu, SLOT(do_start_emu_thread()));
-       
+       connect(this, SIGNAL(sig_start_draw_thread()), hDrawEmu, SLOT(do_start_draw_thread()));
+
+
 //     hRunEmu->start(QThread::HighestPriority);
        this->set_screen_aspect(config.window_stretch_type);
        emit sig_movie_set_width(SCREEN_WIDTH);
@@ -1316,7 +1317,6 @@ int MainLoop(int argc, char *argv[])
        emu->get_osd()->update_keyname_table();
        
        GLDrawClass *pgl = rMainWindow->getGraphicsView();
-       pgl->set_emu_launched();
        pgl->do_set_texture_size(NULL, -1, -1);  // It's very ugly workaround (;_;) 20191028 K.Ohta
 //     pgl->setFixedSize(pgl->width(), pgl->height());
        // main loop
@@ -1325,6 +1325,7 @@ int MainLoop(int argc, char *argv[])
 #endif
        rMainWindow->do_start_emu_thread();
        rMainWindow->do_unblock_task();
+       rMainWindow->do_start_draw_thread();
        GuiMain->exec();
        return 0;
 }
index 1af3662..1d82b1d 100644 (file)
@@ -87,6 +87,17 @@ DrawThreadClass::~DrawThreadClass()
 
 }
 
+void DrawThreadClass::do_start_draw_thread(void)
+{
+       bool _separate = false;
+       if(using_flags->get_config_ptr() != NULL) {
+               if(using_flags->get_config_ptr()->use_separate_thread_draw) {
+                       _separate = true;
+               }
+       }
+       if(_separate) start(QThread::HighPriority);
+}
+
 void DrawThreadClass::SetEmu(EMU_TEMPLATE *p)
 {
        //p_emu = p;
index 018ca7d..d1664f2 100644 (file)
@@ -73,6 +73,7 @@ class DLL_PREFIX DrawThreadClass : public QThread {
        void run() { doWork("");}
        void SetEmu(EMU_TEMPLATE *p);
 public slots:
+       void do_start_draw_thread(void);
        void doWork(const QString &);
        void doExit(void);
        void doDraw(bool flag);
index 95d9ee5..a852d83 100644 (file)
@@ -754,7 +754,9 @@ public slots:
        void do_show_ram_size_dialog(void);
        void do_block_task();
        void do_unblock_task();
+       
        void do_start_emu_thread();
+       void do_start_draw_thread();
 signals:
        int message_changed(QString);
        int quit_emu_thread();
@@ -837,6 +839,8 @@ signals:
        int sig_block_task();
        int sig_unblock_task();
        int sig_start_emu_thread(void);
+       int sig_start_draw_thread(void);
+       int sig_emu_launched(void);
 };
 
 QT_END_NAMESPACE
index d55b8ea..f48d7de 100644 (file)
@@ -32,6 +32,12 @@ void Ui_MainWindowBase::do_unblock_task(void)
 void Ui_MainWindowBase::do_start_emu_thread(void)
 {
        emit sig_start_emu_thread();
+       emit sig_emu_launched();
+}
+
+void Ui_MainWindowBase::do_start_draw_thread(void)
+{
+       emit sig_start_draw_thread();
 }
 
 void Ui_MainWindowBase::set_latency(int num)