Skip to content

Commit 8903ff0

Browse files
authored
fix Plot.show() (#131)
* fix Plot.show() Closes #128 * Update plot.rs * Update plot.rs * Update plot.rs
1 parent bec81a3 commit 8903ff0

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

plotly/src/plot.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,13 @@ impl Plot {
262262

263263
// Save the rendered plot to the temp file.
264264
let temp_path = temp.to_str().unwrap();
265-
let mut file = File::create(temp_path).unwrap();
266-
file.write_all(rendered.as_bytes())
267-
.expect("failed to write html output");
268-
file.flush().unwrap();
265+
266+
{
267+
let mut file = File::create(temp_path).unwrap();
268+
file.write_all(rendered.as_bytes())
269+
.expect("failed to write html output");
270+
file.flush().unwrap();
271+
}
269272

270273
// Hand off the job of opening the browser to an OS-specific implementation.
271274
Plot::show_with_default_app(temp_path);
@@ -288,10 +291,13 @@ impl Plot {
288291

289292
// Save the rendered plot to the temp file.
290293
let temp_path = temp.to_str().unwrap();
291-
let mut file = File::create(temp_path).unwrap();
292-
file.write_all(rendered.as_bytes())
293-
.expect("failed to write html output");
294-
file.flush().unwrap();
294+
295+
{
296+
let mut file = File::create(temp_path).unwrap();
297+
file.write_all(rendered.as_bytes())
298+
.expect("failed to write html output");
299+
file.flush().unwrap();
300+
}
295301

296302
// Hand off the job of opening the browser to an OS-specific implementation.
297303
Plot::show_with_default_app(temp_path);
@@ -467,7 +473,7 @@ impl Plot {
467473
Command::new("cmd")
468474
.arg("/C")
469475
.arg(format!("start {}", temp_path))
470-
.spawn()
476+
.output()
471477
.expect(DEFAULT_HTML_APP_NOT_FOUND);
472478
}
473479
}

0 commit comments

Comments
 (0)