Defend against divide by 0.
authorCarl Hetherington <cth@carlh.net>
Fri, 16 Jun 2023 19:14:42 +0000 (21:14 +0200)
committerCarl Hetherington <cth@carlh.net>
Fri, 16 Jun 2023 19:14:42 +0000 (21:14 +0200)
src/wx/timeline.cc

index 5cf84dfd51196b9435f6c98711c8631d5fea3c3e..c6ce1527b0aaa549fc9690f781ddc40e24ba1f3e 100644 (file)
@@ -950,8 +950,8 @@ Timeline::zoom_all ()
 {
        auto film = _film.lock ();
        DCPOMATIC_ASSERT (film);
-       set_pixels_per_second ((_main_canvas->GetSize().GetWidth() - 32) / film->length().seconds());
-       set_pixels_per_track ((_main_canvas->GetSize().GetHeight() - tracks_y_offset() - _time_axis_view->bbox().height - 32) / _tracks);
+       set_pixels_per_second((_main_canvas->GetSize().GetWidth() - 32) / std::max(1.0, film->length().seconds()));
+       set_pixels_per_track((_main_canvas->GetSize().GetHeight() - tracks_y_offset() - _time_axis_view->bbox().height - 32) / std::max(1, _tracks));
        setup_scrollbars ();
        _main_canvas->Scroll (0, 0);
        _labels_canvas->Scroll (0, 0);