Dn-Programming-Core-Management / Dn-FamiTracker

modifications and improvements for 0CC-FamiTracker (based on j0CC-FamiTracker 0.6.3)
Other
386 stars 23 forks source link

Opening existing document when non-initial song is active crashes #147

Closed nyanpasu64 closed 2 years ago

nyanpasu64 commented 2 years ago
    Dn-FamiTracker.exe!AfxAssertFailedLine(const char * lpszFileName, int nLine) Line 317   C++
    Dn-FamiTracker.exe!CFamiTrackerDoc::GetTrack(unsigned int Track) Line 3959  C++
    Dn-FamiTracker.exe!CFamiTrackerDoc::GetFrameCount(unsigned int Track) Line 3336 C++
    Dn-FamiTracker.exe!CPatternEditor::GetFrameCount() Line 2418    C++
    Dn-FamiTracker.exe!CPatternEditor::CursorUpdated() Line 739 C++
    Dn-FamiTracker.exe!CFamiTrackerView::RedrawPatternEditor() Line 578 C++
    Dn-FamiTracker.exe!CFamiTrackerView::InvalidateCursor() Line 537    C++
    Dn-FamiTracker.exe!CFamiTrackerView::OnKillFocus(CWnd * pNewWnd) Line 860   C++
    [External Code] 
    Dn-FamiTracker.exe!CFamiTrackerDoc::GetTrack(unsigned int Track) Line 3959  C++
    Dn-FamiTracker.exe!CFamiTrackerDoc::GetFrameCount(unsigned int Track) Line 3336 C++
    Dn-FamiTracker.exe!CPatternEditor::GetFrameCount() Line 2418    C++
    Dn-FamiTracker.exe!CPatternEditor::CursorUpdated() Line 739 C++
    Dn-FamiTracker.exe!CFamiTrackerView::RedrawPatternEditor() Line 578 C++
>   Dn-FamiTracker.exe!CFamiTrackerView::OnUpdate(CView * __formal, __int64 lHint, CObject * __formal) Line 1445    C++
    [External Code] 
    Dn-FamiTracker.exe!CFamiTrackerDoc::SetMachine(machine_t Machine) Line 3391 C++
    Dn-FamiTracker.exe!CFamiTrackerDoc::SetupChannels(unsigned char Chip) Line 4019 C++
    Dn-FamiTracker.exe!CFamiTrackerDoc::ReadBlock_Parameters(CDocumentFile * pDocFile, const int Version) Line 1767 C++
    Dn-FamiTracker.exe!CFamiTrackerDoc::OpenDocumentNew(CDocumentFile & DocumentFile) Line 1621 C++
    Dn-FamiTracker.exe!CFamiTrackerDoc::OpenDocument(const char * lpszPathName) Line 1343   C++
    Dn-FamiTracker.exe!CFamiTrackerDoc::OnOpenDocument(const char * lpszPathName) Line 287  C++
    [External Code] 
    Dn-FamiTracker.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 26    C++
    [External Code] 

I have no clue why this stack is so funny and includes two CFamiTrackerDoc::GetTrack() calls.

This will more reliably reproduce on debug builds.

nyanpasu64 commented 2 years ago

CFamiTrackerDoc::SetupChannels() calling SetMachine(NTSC); should not redraw the view mid-update.

Ideally we'd rewrite with something akin to StateTransaction, holding either pointers or indexes into a SlotMap<AnyWidget>, or (if we only have 1 of every window) relying on the main window for receiving updates.

Until then, we can make the redraw not crash.