From cb72bf226049f00b17e6e4254108be54fe272055 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Fri, 10 Jul 2009 17:47:37 +0200 Subject: [PATCH] MidiTime/Pattern: fixed divisions by zero with time sigs 1/16+ Setting time signatures 1/16+ lead to divisions by zero in two places. Fixed this by adding according qMax() call (closes #2818125). Signed-off-by: Tobias Doerffel --- include/midi_time.h | 2 +- src/tracks/pattern.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/midi_time.h b/include/midi_time.h index dfb8a1c90..620738177 100644 --- a/include/midi_time.h +++ b/include/midi_time.h @@ -135,7 +135,7 @@ public: static int stepsPerTact( void ) { - return ticksPerTact() / DefaultBeatsPerTact; + return qMax( 1, ticksPerTact() / DefaultBeatsPerTact ); } static void setTicksPerTact( tick_t _tpt ) diff --git a/src/tracks/pattern.cpp b/src/tracks/pattern.cpp index 8e7aa0704..561910257 100644 --- a/src/tracks/pattern.cpp +++ b/src/tracks/pattern.cpp @@ -1244,7 +1244,8 @@ void patternView::paintEvent( QPaintEvent * ) QPixmap stepoverlay; QPixmap stepoff; QPixmap stepoffl; - const int steps = m_pat->length() / DefaultBeatsPerTact; + const int steps = qMax( 1, + m_pat->length() / DefaultBeatsPerTact ); const int w = width() - 2 * TCO_BORDER_WIDTH; stepon = s_stepBtnOn->scaled( w / steps, s_stepBtnOn->height(),