@@ -72,6 +72,33 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
7272 themeManager->ApplyTheme (NekoGui::dataStore->theme );
7373 ui->setupUi (this );
7474
75+ // Prepare core
76+ NekoGui::dataStore->core_port = MkPort ();
77+ if (NekoGui::dataStore->core_port <= 0 ) NekoGui::dataStore->core_port = 19810 ;
78+
79+ auto core_path = QApplication::applicationDirPath () + " /" ;
80+ core_path += " nekobox_core" ;
81+
82+ QStringList args;
83+ args.push_back (" nekobox" );
84+ args.push_back (" -port" );
85+ args.push_back (Int2String (NekoGui::dataStore->core_port ));
86+ if (NekoGui::dataStore->flag_debug ) args.push_back (" -debug" );
87+
88+ // Start core
89+ runOnUiThread (
90+ [=] {
91+ core_process = new NekoGui_sys::CoreProcess (core_path, args);
92+ // Remember last started
93+ if (NekoGui::dataStore->remember_enable && NekoGui::dataStore->remember_id >= 0 ) {
94+ core_process->start_profile_when_core_is_up = NekoGui::dataStore->remember_id ;
95+ }
96+ // Setup
97+ core_process->Start ();
98+ setup_grpc ();
99+ },
100+ DS_cores);
101+
75102 if (!NekoGui::dataStore->font .isEmpty ()) {
76103 qApp->setFont (NekoGui::dataStore->font );
77104 }
@@ -432,34 +459,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
432459 });
433460 refresh_status ();
434461
435- // Prepare core
436- NekoGui::dataStore->core_token = GetRandomString (32 );
437- NekoGui::dataStore->core_port = MkPort ();
438- if (NekoGui::dataStore->core_port <= 0 ) NekoGui::dataStore->core_port = 19810 ;
439-
440- auto core_path = QApplication::applicationDirPath () + " /" ;
441- core_path += " nekobox_core" ;
442-
443- QStringList args;
444- args.push_back (" nekobox" );
445- args.push_back (" -port" );
446- args.push_back (Int2String (NekoGui::dataStore->core_port ));
447- if (NekoGui::dataStore->flag_debug ) args.push_back (" -debug" );
448-
449- // Start core
450- runOnUiThread (
451- [=] {
452- core_process = new NekoGui_sys::CoreProcess (core_path, args);
453- // Remember last started
454- if (NekoGui::dataStore->remember_enable && NekoGui::dataStore->remember_id >= 0 ) {
455- core_process->start_profile_when_core_is_up = NekoGui::dataStore->remember_id ;
456- }
457- // Setup
458- core_process->Start ();
459- setup_grpc ();
460- },
461- DS_cores);
462-
463462 connect (qApp, &QGuiApplication::commitDataRequest, this , &MainWindow::on_commitDataRequest);
464463
465464 auto t = new QTimer;
0 commit comments