Add a checkbox to quit on disconnect
This commit is contained in:
+16
-5
@@ -12,7 +12,8 @@ use super::AppWindow;
|
||||
pub struct GdbServerWindow {
|
||||
sim_id: SimId,
|
||||
port_str: String,
|
||||
launched: bool,
|
||||
connected: bool,
|
||||
quit_on_disconnect: bool,
|
||||
server: GdbServer,
|
||||
proxy: EventLoopProxy<UserEvent>,
|
||||
}
|
||||
@@ -22,7 +23,8 @@ impl GdbServerWindow {
|
||||
Self {
|
||||
sim_id,
|
||||
port_str: (8080 + sim_id.to_index()).to_string(),
|
||||
launched: false,
|
||||
connected: false,
|
||||
quit_on_disconnect: false,
|
||||
server: GdbServer::new(sim_id, client),
|
||||
proxy,
|
||||
}
|
||||
@@ -31,8 +33,9 @@ impl GdbServerWindow {
|
||||
pub fn launch(&mut self, port: u16) {
|
||||
self.server.stop();
|
||||
self.port_str = port.to_string();
|
||||
self.launched = true;
|
||||
self.quit_on_disconnect = true;
|
||||
self.server.start(port);
|
||||
self.connected = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +44,10 @@ impl AppWindow for GdbServerWindow {
|
||||
ViewportId::from_hash_of(format!("Debugger-{}", self.sim_id))
|
||||
}
|
||||
|
||||
fn sim_id(&self) -> SimId {
|
||||
self.sim_id
|
||||
}
|
||||
|
||||
fn initial_viewport(&self) -> ViewportBuilder {
|
||||
ViewportBuilder::default()
|
||||
.with_title(format!("GDB Server ({})", self.sim_id))
|
||||
@@ -61,16 +68,20 @@ impl AppWindow for GdbServerWindow {
|
||||
ui.label("Port");
|
||||
let port_editor = TextEdit::singleline(&mut self.port_str).desired_width(100.0);
|
||||
ui.add_enabled(!status.running(), port_editor);
|
||||
ui.checkbox(&mut self.quit_on_disconnect, "Quit on disconnect");
|
||||
});
|
||||
|
||||
if !status.running() {
|
||||
if self.launched {
|
||||
self.proxy.send_event(UserEvent::Quit).unwrap();
|
||||
if self.connected && self.quit_on_disconnect {
|
||||
self.proxy.send_event(UserEvent::Quit(self.sim_id)).unwrap();
|
||||
} else {
|
||||
self.connected = false;
|
||||
}
|
||||
let start_button = Button::new("Start");
|
||||
if ui.add_enabled(port_num.is_some(), start_button).clicked() {
|
||||
let port = port_num.unwrap();
|
||||
self.server.start(port);
|
||||
self.connected = true;
|
||||
}
|
||||
} else {
|
||||
let stop_button = Button::new("Stop");
|
||||
|
||||
Reference in New Issue
Block a user