--- nono/wx/wxapp.cpp 2026/04/29 17:05:35 1.1.1.17 +++ nono/wx/wxapp.cpp 2026/04/29 17:05:53 1.1.1.21 @@ -41,6 +41,8 @@ class WXApp : public wxApp std::unique_ptr pHostInfo {}; }; +static std::string utf8_to_sjis(const std::string&); + // IMPLEMENT_APP() は闇マクロすぎて clang のちからには耐えられない PRAGMA_PUSH_WARNINGS IMPLEMENT_APP(WXApp) @@ -63,7 +65,7 @@ WXApp::OnRun() { int rv; - rv = gMainApp.Init1(false, argc, argv); + rv = gMainApp.Init1(argc, argv, utf8_to_sjis); if (rv != MainApp::PASS) { return rv; } @@ -100,12 +102,24 @@ WXApp::OnRun() item_fontsize.Err("Must be either 12, 16 or 24"); return EXIT_FAILURE; } - pFontManager.reset(new FontManager()); + try { + pFontManager.reset(new FontManager()); + } catch (...) { } + if ((bool)pFontManager == false) { + warnx("Failed to initialize FontManager"); + return EXIT_FAILURE; + } gFontManager = pFontManager.get(); gFontManager->SetFont(fontid); // ホスト情報用のモニタ (どこでやるのがいいか) - pHostInfo.reset(new HostInfoMonitor()); + try { + pHostInfo.reset(new HostInfoMonitor()); + } catch (...) { } + if ((bool)pHostInfo == false) { + warnx("Failed to initialize HostInfoMonitor"); + return EXIT_FAILURE; + } gHostInfo = pHostInfo.get(); // 手順 6. (vm/device.h) @@ -310,8 +324,8 @@ WXApp::ShowMonitorsName() } // 一覧を表示 - std::string msg = MonitorManager::MakeListString(list); - printf("%s", msg.c_str()); + std::vector names = gMonitorManager->MakeListString(list); + MainApp::ShowHelpList(stdout, names); } // モニタ名 name を検索し、一つに確定すればその id を返す。 @@ -329,8 +343,13 @@ WXApp::SearchMonitorName(const char *nam for (uint id = ID_MONITOR_START; id <= ID_SUBWIN_END; id++) { if (id < ID_SUBWIN_START) { - // モニターは登録されていなければ除外する - if (gMonitorManager->Find(id) == NULL) { + // モニターは登録されていなければ除外する。 + Monitor *mon = gMonitorManager->Find(id); + if (mon == NULL) { + continue; + } + // SLIRP モニタだけ、登録はされてて obj が NULL という状態がある。 + if (mon->obj == NULL) { continue; } } else { @@ -432,3 +451,21 @@ WXApp::FindAvailable(const std::vector wxString + wxString wstr(utf8str.c_str(), wxConvUTF8); + + // wxString -> Shift_JIS + wxCharBuffer sjisbuf = wstr.mb_str(conv); + + return std::string(sjisbuf.data()); +}