From: <sag...@us...> - 2010-03-26 19:17:33
|
Revision: 553 http://modplug.svn.sourceforge.net/modplug/?rev=553&view=rev Author: saga-games Date: 2010-03-26 19:17:27 +0000 (Fri, 26 Mar 2010) Log Message: ----------- [Fix] Many dialogs don't check if their SndFile pointer is valid, so using the global "close file" shortcut can crash them. As a lazy fix, this shortcut is now only allowed if the main window has the focus. Modified Paths: -------------- trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2010-03-26 17:14:18 UTC (rev 552) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2010-03-26 19:17:27 UTC (rev 553) @@ -3300,7 +3300,7 @@ case kcApproxRealBPM: OnApproximateBPM(); break; case kcFileSave: DoSave(m_strPathName, 0); break; case kcFileSaveAs: DoSave(NULL, 1); break; - case kcFileClose: OnFileClose(); break; + case kcFileClose: SafeFileClose(); break; case kcPlayPatternFromCursor: OnPatternPlay(); break; case kcPlayPatternFromStart: OnPatternRestart(); break; @@ -3543,4 +3543,12 @@ displayName.Format(TEXT("%s (%s)"), (LPCTSTR)instrumentName, (LPCTSTR)pluginName); } return displayName; +} + +void CModDoc::SafeFileClose() +//-------------------------- +{ + // Verify that the main window has the focus. This saves us a lot of trouble because active dialogs normally don't check if their pSndFile pointers are still valid. + if(GetActiveWindow() == CMainFrame::GetMainFrame()->m_hWnd) + OnFileClose(); } \ No newline at end of file Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2010-03-26 17:14:18 UTC (rev 552) +++ trunk/OpenMPT/mptrack/Moddoc.h 2010-03-26 19:17:27 UTC (rev 553) @@ -292,6 +292,8 @@ bool MergeSequences(); bool ConvertSubsongsToMultipleSequences(); + bool HasMPTHacks(bool autofix = false); + bool m_bHasValidPath; //becomes true if document is loaded or saved. // Fix: save pattern scrollbar position when switching to other tab CSize GetOldPatternScrollbarsPos() const { return m_szOldPatternScrollbarsPos; }; @@ -322,6 +324,7 @@ virtual BOOL OnOpenDocument(LPCTSTR lpszPathName); virtual BOOL OnSaveDocument(LPCTSTR lpszPathName); virtual void OnCloseDocument(); + void SafeFileClose(); // -> CODE#0023 // -> DESC="IT project files (.itp)" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |