--- nono/wx/wxmainframe.cpp 2026/04/29 17:05:35 1.1.1.20 +++ nono/wx/wxmainframe.cpp 2026/04/29 17:05:40 1.1.1.21 @@ -34,6 +34,7 @@ #include "nmi.h" #include "power.h" #include "scsidev.h" +#include "scsidomain.h" #include "syncer.h" #include @@ -90,6 +91,8 @@ enum { ID_FONTSIZE_24, ID_FONTSIZE_END, + ID_DEVICE_EMPTY, + ID_MONRATE_START, ID_MONRATE_END = ID_MONRATE_START + 4, @@ -295,7 +298,7 @@ WXMainFrame::WXMainFrame(wxWindow *paren menuFontSize->AppendRadioItem(ID_FONTSIZE_24, "2&4"); menuDisplay->AppendSubMenu(menuFontSize, _("&Font Size")); wxMenu *menuMonRate = new wxMenu(); - user_idx = CreateMonRateTable(); + CreateMonRateTable(); for (int i = 0, end = monrates.size(); i < end; i++) { std::string text; switch (monrates[i]) { @@ -331,6 +334,13 @@ WXMainFrame::WXMainFrame(wxWindow *paren menuOper->AppendCheckItem(ID_KEYBOARD_CONNECT, _("Connect &Keyboard")); menuDevice->AppendSubMenu(menuOper, _("&Operation")); } + // アイテムが何もなければ本当はメニューバーのアイテムを無効にしたいが、 + // それは出来ないっぽい。何かアイテムを置かないと変なパネルが出たりする。 + if (menuDevice->GetMenuItems().IsEmpty()) { + // TRANSLATORS: This is "Device > Nothing" in the menubar. + menuDevice->Append(ID_DEVICE_EMPTY, _("Nothing")); + menuDevice->Enable(ID_DEVICE_EMPTY, false); + } menubar->Append(menuDevice, _("&Device")); #define AppendIfSeparator(menu, vmcap_) do { \ @@ -430,6 +440,7 @@ WXMainFrame::WXMainFrame(wxWindow *paren AppendIf(menuDev, id, name); } AppendIf(menuDev, ID_MONITOR_VIRTIO_NET, _("VirtIO Network")); + AppendIf(menuDev, ID_MONITOR_VIRTIO_SCSI, "VirtIO SCSI"); AppendIf(menuDev, ID_MONITOR_VIRTIO_ENTROPY,_("VirtIO Entropy")); AppendIf(menuDev, ID_MONITOR_CRTC, "CRTC"); AppendIf(menuDev, ID_MONITOR_LUNAVC, _("Video Control")); @@ -609,7 +620,7 @@ WXMainFrame::CreateRemovableMenu(wxMenu } // CD, MO - auto scsi = gMainApp.FindObject(OBJ_SCSI); + auto scsi = gMainApp.FindObject(OBJ_SCSI); if (scsi) { for (int id = 0; id < 8; id++) { scsidev[id] = scsi->GetTarget(id); @@ -1005,10 +1016,8 @@ WXMainFrame::monrates { 1, }; -// 「表示 > モニタ更新頻度」のメニュー項目作成に必要な monrates を作成し、 -// ユーザ指定値があれば monrates[] 内のインデックスを返す。 -// ユーザ指定値がなければ -1 を返す。 -int +// 「表示 > モニタ更新頻度」のメニュー項目作成に必要な monrates を作成する。 +void WXMainFrame::CreateMonRateTable() { // 設定ファイル monitor-rate で指定された値を追加。 @@ -1022,16 +1031,7 @@ WXMainFrame::CreateMonRateTable() std::sort(monrates.begin(), monrates.end(), [](int a, int b) { return a > b; } ); - - // ユーザ指定の値が何番目かを返す。指定されてなければ -1。 - for (int i = 0, end = monrates.size(); i < end; i++) { - if (monrates[i] == user_rate) { - return i; - } - } - // 見付からないことはないはずだが } - return -1; } // メニューの「表示 > モニタ更新頻度 > *」の共通イベント @@ -1323,6 +1323,13 @@ WXMainFrame::OnWindow(wxCommandEvent& ev DoWindow(id, event.IsChecked()); } +#define SetMonitor(id, name) do { \ + try { \ + windows[id].reset(new WXMonitorWindow(this, (name), \ + gMonitorManager->Get(id))); \ + } catch (...) { } \ +} while (0) + void WXMainFrame::DoWindow(int id, bool enable) { @@ -1330,17 +1337,16 @@ WXMainFrame::DoWindow(int id, bool enabl // id はモニター ID であると同時に、windows[] 配列の添字、さらにこの // モニタウィンドウの wxWindowID としても使っている // (WXSubWindow::OnClose() 参照)。 -#define SetMonitor(id, name) \ - windows[id].reset(new WXMonitorWindow(this, (name), \ - gMonitorManager->Get(id))) if (enable) { // チェックが入ったのでウィンドウを作成 switch (id) { case ID_MONITOR_ACCSTAT: // こいつだけモニタ ID を持ちつつ上位互換のサブウィンドウがある。 - windows[id].reset(new - WXAccStatWindow(this, gMonitorManager->Get(id))); + try { + windows[id].reset(new + WXAccStatWindow(this, gMonitorManager->Get(id))); + } catch (...) { } break; case ID_MONITOR_AREASET: @@ -1445,7 +1451,9 @@ WXMainFrame::DoWindow(int id, bool enabl break; case ID_MONITOR_LCD: - windows[id].reset(new WXLCDMonitor(this)); + try { + windows[id].reset(new WXLCDMonitor(this)); + } catch (...) { } break; case ID_MONITOR_LUNAVC: @@ -1469,7 +1477,9 @@ WXMainFrame::DoWindow(int id, bool enabl case ID_MONITOR_XPMEMDUMP0 ... ID_MONITOR_XPMEMDUMP(MAX_XPMEMDUMP_MONITOR - 1): { - windows[id].reset(new WXMemdumpWindow(this, id)); + try { + windows[id].reset(new WXMemdumpWindow(this, id)); + } catch (...) { } break; } @@ -1583,6 +1593,10 @@ WXMainFrame::DoWindow(int id, bool enabl SetMonitor(id, _("VirtIO Network")); break; + case ID_MONITOR_VIRTIO_SCSI: + SetMonitor(id, "VirtIO SCSI"); + break; + case ID_MONITOR_VIRTIO_ENTROPY: SetMonitor(id, _("VirtIO Entropy")); break; @@ -1606,16 +1620,20 @@ WXMainFrame::DoWindow(int id, bool enabl case ID_SUBWIN_BRHIST: { wxString name = MPUName() + " " + _("Branch History"); - windows[id].reset(new WXScrollMonitorWindow(this, name, - gMonitorManager->Get(id))); + try { + windows[id].reset(new WXScrollMonitorWindow(this, name, + gMonitorManager->Get(id))); + } catch (...) { } break; } case ID_SUBWIN_EXHIST: { wxString name = MPUName() + " " + _("Exception History"); - windows[id].reset(new WXScrollMonitorWindow(this, name, - gMonitorManager->Get(id))); + try { + windows[id].reset(new WXScrollMonitorWindow(this, name, + gMonitorManager->Get(id))); + } catch (...) { } break; } @@ -1636,23 +1654,35 @@ WXMainFrame::DoWindow(int id, bool enabl } else { name += _("(Inst)"); } - windows[id].reset(new WXCacheWindow(this, name, - gMonitorManager->Get(id))); + try { + windows[id].reset(new WXCacheWindow(this, name, + gMonitorManager->Get(id))); + } catch (...) { } break; } case ID_SUBWIN_DIPSW: - windows[id].reset(new WXDipswWindow(this)); + try { + windows[id].reset(new WXDipswWindow(this)); + } catch (...) { } break; case ID_SUBWIN_LCDPANEL: - windows[id].reset(new WXLCDWindow(this)); + try { + windows[id].reset(new WXLCDWindow(this)); + } catch (...) { } break; + case ID_SUBWIN_LOG: - windows[id].reset(new WXLogMonitor(this)); + try { + windows[id].reset(new WXLogMonitor(this)); + } catch (...) { } break; + case ID_SUBWIN_LOGSETTING: - windows[id].reset(new WXLogSettingWindow(this)); + try { + windows[id].reset(new WXLogSettingWindow(this)); + } catch (...) { } break; case ID_SUBWIN_LUNAFB: @@ -1665,17 +1695,19 @@ WXMainFrame::DoWindow(int id, bool enabl } else { name = _("Text VRAM"); } - windows[id].reset(new WXPlaneVRAMWindow(this, name)); + try { + windows[id].reset(new WXPlaneVRAMWindow(this, name)); + } catch (...) { } break; } case ID_SUBWIN_NEWSIO: - { - windows[id].reset(new WXScrollMonitorWindow(this, - _("Device Map (NEWS)"), - gMonitorManager->Get(id))); + try { + windows[id].reset(new WXScrollMonitorWindow(this, + _("Device Map (NEWS)"), + gMonitorManager->Get(id))); + } catch (...) { } break; - } case ID_SUBWIN_PALETTE: case ID_SUBWIN_TEXTPAL: @@ -1687,47 +1719,60 @@ WXMainFrame::DoWindow(int id, bool enabl } else { name = _("Palette Colormap"); } - windows[id].reset(new WXPaletteWindow(this, name)); + try { + windows[id].reset(new WXPaletteWindow(this, name)); + } catch (...) { } break; } case ID_SUBWIN_ROM: - windows[id].reset(new WXROMWindow(this)); + try { + windows[id].reset(new WXROMWindow(this)); + } catch (...) { } break; case ID_SUBWIN_SOFTKEY: - windows[id].reset(new WXSoftKeyWindow(this, gMainApp.GetVMType())); + try { + windows[id].reset(new WXSoftKeyWindow(this, + gMainApp.GetVMType())); + } catch (...) { } break; case ID_SUBWIN_VECTOR: { wxString name = MPUName() + " " + _("Vector Table"); - windows[id].reset(new WXScrollMonitorWindow(this, name, - gMonitorManager->Get(id))); + try { + windows[id].reset(new WXScrollMonitorWindow(this, name, + gMonitorManager->Get(id))); + } catch (...) { } break; } case ID_SUBWIN_X68KIO: - { - windows[id].reset(new WXScrollMonitorWindow(this, - _("Device Map (24bit space)"), - gMonitorManager->Get(id))); + try { + windows[id].reset(new WXScrollMonitorWindow(this, + _("Device Map (24bit space)"), + gMonitorManager->Get(id))); + } catch (...) { } break; - } case ID_SUBWIN_XPBRHIST: { wxString name = "HD647180 " + _("Branch History"); - windows[id].reset(new WXScrollMonitorWindow(this, name, - gMonitorManager->Get(id))); + try { + windows[id].reset(new WXScrollMonitorWindow(this, name, + gMonitorManager->Get(id))); + } catch (...) { } break; } case ID_SUBWIN_XPEXHIST: { wxString name = "HD647180 " + _("Exception History"); - windows[id].reset(new WXScrollMonitorWindow(this, name, - gMonitorManager->Get(id))); + try { + windows[id].reset(new WXScrollMonitorWindow(this, name, + gMonitorManager->Get(id))); + } catch (...) { } break; }