From: <sv...@op...> - 2024-10-23 20:50:18
|
Author: sagamusix Date: Wed Oct 23 22:50:05 2024 New Revision: 21912 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21912 Log: [Fix] Avoid crash with modules that have no time signature set (https://bugs.openmpt.org/view.php?id=1833). Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp trunk/OpenMPT/soundlib/PlayState.cpp Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp ============================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp Mon Oct 21 23:15:24 2024 (r21911) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp Wed Oct 23 22:50:05 2024 (r21912) @@ -411,6 +411,7 @@ sndFile.m_nDefaultRowsPerBeat = std::min(static_cast<ROWINDEX>(GetDlgItemInt(IDC_ROWSPERBEAT)), MAX_ROWS_PER_BEAT); sndFile.m_nDefaultRowsPerMeasure = std::min(static_cast<ROWINDEX>(GetDlgItemInt(IDC_ROWSPERMEASURE)), MAX_ROWS_PER_BEAT); + sndFile.m_PlayState.UpdateTimeSignature(sndFile); sel = m_TempoModeBox.GetCurSel(); if(sel >= 0) Modified: trunk/OpenMPT/soundlib/PlayState.cpp ============================================================================== --- trunk/OpenMPT/soundlib/PlayState.cpp Mon Oct 21 23:15:24 2024 (r21911) +++ trunk/OpenMPT/soundlib/PlayState.cpp Wed Oct 23 22:50:05 2024 (r21912) @@ -50,10 +50,12 @@ void PlayState::UpdatePPQ(bool patternTransition) noexcept { - if(m_lTotalSampleCount > 0 && (patternTransition || !(m_nRow % m_nCurrentRowsPerMeasure))) + ROWINDEX rpm = m_nCurrentRowsPerMeasure ? m_nCurrentRowsPerMeasure : 4; + ROWINDEX rpb = m_nCurrentRowsPerBeat ? m_nCurrentRowsPerBeat : 1; + if(m_lTotalSampleCount > 0 && (patternTransition || !(m_nRow % rpm))) { // Pattern end = end of measure, so round up PPQ to the next full measure - m_ppqPosBeat += (m_nCurrentRowsPerMeasure + (m_nCurrentRowsPerBeat - 1)) / m_nCurrentRowsPerBeat; + m_ppqPosBeat += (rpm + (rpb - 1)) / rpb; m_ppqPosFract = 0; } } |