Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix verso crashes when launched without panel #267

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 36 additions & 32 deletions src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,20 +238,22 @@ impl Window {
let mut webview = WebView::new(webview_id, rect);
webview.set_size(content_size);

let (tx, rx) = ipc::channel::<WebDriverJSResult>().unwrap();
let cmd: String = format!(
"window.navbar.addTab('{}', {})",
serde_json::to_string(&webview.webview_id).unwrap(),
true,
);
send_to_constellation(
constellation_sender,
ConstellationMsg::WebDriverCommand(WebDriverCommandMsg::ScriptCommand(
self.panel.as_ref().unwrap().webview.webview_id.into(),
WebDriverScriptCommand::ExecuteScript(cmd, tx),
)),
);
let _ = rx.recv();
if let Some(panel) = &self.panel {
let (tx, rx) = ipc::channel::<WebDriverJSResult>().unwrap();
let cmd: String = format!(
"window.navbar.addTab('{}', {})",
serde_json::to_string(&webview.webview_id).unwrap(),
true,
);
send_to_constellation(
constellation_sender,
ConstellationMsg::WebDriverCommand(WebDriverCommandMsg::ScriptCommand(
panel.webview.webview_id.into(),
WebDriverScriptCommand::ExecuteScript(cmd, tx),
)),
);
let _ = rx.recv();
}

self.tab_manager.append_tab(webview, true);

Expand All @@ -267,26 +269,28 @@ impl Window {
let sender = compositor.constellation_chan.clone();
// if there are more than 2 tabs, we need to ask for the new active tab after tab is closed
if self.tab_manager.count() > 1 {
let (tx, rx) = ipc::channel::<WebDriverJSResult>().unwrap();
let cmd: String = format!(
"window.navbar.closeTab('{}')",
serde_json::to_string(&tab_id).unwrap()
);
send_to_constellation(
&sender,
ConstellationMsg::WebDriverCommand(WebDriverCommandMsg::ScriptCommand(
self.panel.as_ref().unwrap().webview.webview_id.into(),
WebDriverScriptCommand::ExecuteScript(cmd, tx),
)),
);
if let Some(panel) = &self.panel {
let (tx, rx) = ipc::channel::<WebDriverJSResult>().unwrap();
let cmd: String = format!(
"window.navbar.closeTab('{}')",
serde_json::to_string(&tab_id).unwrap()
);
send_to_constellation(
&sender,
ConstellationMsg::WebDriverCommand(WebDriverCommandMsg::ScriptCommand(
panel.webview.webview_id.into(),
WebDriverScriptCommand::ExecuteScript(cmd, tx),
)),
);

let active_tab_id = rx.recv().unwrap().unwrap();
match active_tab_id {
WebDriverJSValue::String(resp) => {
let active_id: WebViewId = serde_json::from_str(&resp).unwrap();
self.activate_tab(compositor, active_id, self.tab_manager.count() > 2);
let active_tab_id = rx.recv().unwrap().unwrap();
match active_tab_id {
WebDriverJSValue::String(resp) => {
let active_id: WebViewId = serde_json::from_str(&resp).unwrap();
self.activate_tab(compositor, active_id, self.tab_manager.count() > 2);
}
_ => {}
}
_ => {}
}
}
send_to_constellation(&sender, ConstellationMsg::CloseWebView(tab_id));
Expand Down
Loading