Added a safeguard against empty vector plotting, this would segfault
This commit is contained in:
parent
411086483e
commit
42ae2779bb
1 changed files with 4 additions and 0 deletions
|
@ -226,6 +226,10 @@ impl PlotLine {
|
||||||
|
|
||||||
/// Plot a line. Use this in closures passed to [`Plot::build()`](struct.Plot.html#method.build)
|
/// Plot a line. Use this in closures passed to [`Plot::build()`](struct.Plot.html#method.build)
|
||||||
pub fn plot(&self, x: &Vec<f64>, y: &Vec<f64>) {
|
pub fn plot(&self, x: &Vec<f64>, y: &Vec<f64>) {
|
||||||
|
// If there is no data to plot, we stop here
|
||||||
|
if x.len().min(y.len()) == 0 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
unsafe {
|
unsafe {
|
||||||
implot_sys::ImPlot_PlotLinedoublePtrdoublePtr(
|
implot_sys::ImPlot_PlotLinedoublePtrdoublePtr(
|
||||||
im_str!("{}", self.label).as_ptr() as *const i8,
|
im_str!("{}", self.label).as_ptr() as *const i8,
|
||||||
|
|
Loading…
Reference in a new issue