@@ -394,7 +394,12 @@ void EditorService::redo()
394394
395395quint64 EditorService::columnCount (quint64 trackIndex) const
396396{
397- return m_song->columnCount (trackIndex);
397+ try {
398+ return m_song->columnCount (trackIndex);
399+ } catch (...) {
400+ juzzlin::L (TAG).warning () << " Cannot get column count for track, index=" << trackIndex;
401+ return 0 ;
402+ }
398403}
399404
400405quint64 EditorService::lineCount (quint64 patternId) const
@@ -878,7 +883,7 @@ bool EditorService::isColumnVisible(quint64 track, quint64 column) const
878883
879884bool EditorService::isTrackVisible (quint64 track) const
880885{
881- for (quint64 column = 0 ; column < m_song-> columnCount (track); column++) {
886+ for (quint64 column = 0 ; column < columnCount (track); column++) {
882887 if (isColumnVisible (track, column)) {
883888 return true ;
884889 }
@@ -2253,16 +2258,21 @@ void EditorService::requestColumnRight(bool isSelecting)
22532258
22542259quint64 EditorService::totalUnitCount () const
22552260{
2256- quint64 columnCount = 0 ;
2261+ quint64 totalColumnCount = 0 ;
22572262 for (auto && trackIndex : m_song->trackIndices ()) {
2258- columnCount += m_song-> columnCount (trackIndex);
2263+ totalColumnCount += columnCount (trackIndex);
22592264 }
2260- return columnCount ;
2265+ return totalColumnCount ;
22612266}
22622267
22632268quint64 EditorService::trackWidthInUnits (quint64 trackIndex) const
22642269{
2265- return m_song->columnCount (trackIndex);
2270+ try {
2271+ return m_song->columnCount (trackIndex);
2272+ } catch (...) {
2273+ juzzlin::L (TAG).warning () << " Cannot get width for track, index=" << trackIndex;
2274+ return 0 ;
2275+ }
22662276}
22672277
22682278quint64 EditorService::columnPositionInUnits (quint64 trackIndex, quint64 columnIndex) const
@@ -2275,7 +2285,7 @@ quint64 EditorService::trackPositionInUnits(quint64 trackIndex) const
22752285 quint64 unitPosition = 0 ;
22762286 const auto trackPosition = m_song->trackPositionByIndex (trackIndex);
22772287 for (quint64 track = 0 ; track < trackPosition; track++) {
2278- unitPosition += m_song-> columnCount (m_song->trackIndexByPosition (track).value_or (0 ));
2288+ unitPosition += columnCount (m_song->trackIndexByPosition (track).value_or (0 ));
22792289 }
22802290 return unitPosition;
22812291}
@@ -2290,7 +2300,7 @@ int EditorService::onScreenTrackPositionInUnits(quint64 trackIndex) const
22902300 int unitPosition = -static_cast <int >(m_state.horizontalScrollPosition );
22912301 const auto trackPosition = m_song->trackPositionByIndex (trackIndex);
22922302 for (quint64 track = 0 ; track < trackPosition; track++) {
2293- unitPosition += m_song-> columnCount (m_song->trackIndexByPosition (track).value_or (0 ));
2303+ unitPosition += columnCount (m_song->trackIndexByPosition (track).value_or (0 ));
22942304 }
22952305 return unitPosition;
22962306}
0 commit comments