Skip to content

Commit b03f7f1

Browse files
committed
[Fix] Sample tab: Fix crash when replacing a sample with a shorter one while outside of the sample editor, and then returning to the same sample slot (https://bugs.openmpt.org/view.php?id=1866).
git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@22973 56274372-70c3-4bfc-bfc3-4c3a0b034d27
1 parent c7be25a commit b03f7f1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

mptrack/Globals.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,8 +801,12 @@ void CModScrollView::SetScrollSizes(int nMapMode, SIZE sizeTotal, const SIZE& si
801801
SCROLLINFO info;
802802
if(GetScrollInfo(SB_HORZ, &info, SIF_POS))
803803
m_nScrollPosX = info.nPos;
804+
else
805+
m_nScrollPosX = 0;
804806
if(GetScrollInfo(SB_VERT, &info, SIF_POS))
805807
m_nScrollPosY = info.nPos;
808+
else
809+
m_nScrollPosY = 0;
806810
}
807811

808812

mptrack/View_smp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,10 +1001,10 @@ void CViewSample::OnDraw(CDC *pDC)
10011001

10021002
const CRect rcClient = m_rcClient;
10031003
CRect rect, rc;
1004-
const SmpLength smpScrollPos = ScrollPosToSamplePos();
10051004
const auto &colors = TrackerSettings::Instance().rgbCustomColors;
10061005
const CSoundFile &sndFile = pModDoc->GetSoundFile();
10071006
const ModSample &sample = sndFile.GetSample((m_nSample <= sndFile.GetNumSamples()) ? m_nSample : 0);
1007+
const SmpLength smpScrollPos = std::min(ScrollPosToSamplePos(), sample.nLength);
10081008
if(sample.uFlags[CHN_ADLIB])
10091009
{
10101010
CModScrollView::OnDraw(pDC);

0 commit comments

Comments
 (0)