From: <sag...@us...> - 2011-08-17 00:24:35
|
Revision: 979 http://modplug.svn.sourceforge.net/modplug/?rev=979&view=rev Author: saga-games Date: 2011-08-16 23:32:11 +0000 (Tue, 16 Aug 2011) Log Message: ----------- [Fix] Treeview works in VS2010 as well now (fix by xaimus). [Imp] Improved template file handling (not added to MRU anymore, so they don't need to be removed anymore as well, so the MRU list stays intact) Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/test/test.cpp Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2011-08-16 18:40:56 UTC (rev 978) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2011-08-16 23:32:11 UTC (rev 979) @@ -2182,7 +2182,7 @@ const bool bAvailable = Util::sdOs::IsPathFileAvailable(sPath, Util::sdOs::FileModeRead); if (bAvailable) { - CDocument* pDoc = theApp.OpenDocumentFile(sPath); + CDocument* pDoc = theApp.OpenDocumentFile(sPath, bTemplateFile ? FALSE : TRUE); if (pDoc != nullptr) { ASSERT(pDoc->IsKindOf(RUNTIME_CLASS(CModDoc)) == TRUE); @@ -2201,7 +2201,6 @@ pModDoc->GetFileHistory()->clear(); // Reset edit history for template files pModDoc->GetSoundFile()->m_dwCreatedWithVersion = MptVersion::num; pModDoc->GetSoundFile()->m_dwLastSavedWithVersion = 0; - theApp.RemoveMruItem(0); } } } Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2011-08-16 18:40:56 UTC (rev 978) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2011-08-16 23:32:11 UTC (rev 979) @@ -50,42 +50,45 @@ public: CModDocTemplate(UINT nIDResource, CRuntimeClass* pDocClass, CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass): CMultiDocTemplate(nIDResource, pDocClass, pFrameClass, pViewClass) {} - virtual CDocument* OpenDocumentFile(LPCTSTR lpszPathName, BOOL bMakeVisible = TRUE); + virtual CDocument* OpenDocumentFile(LPCTSTR path, BOOL addToMru = TRUE, BOOL makeVisible = TRUE); + +private: + bool DocumentIsOpen(const char*, CDocument**); }; -CDocument *CModDocTemplate::OpenDocumentFile(LPCTSTR lpszPathName, BOOL bMakeVisible) -//----------------------------------------------------------------------------------- +CDocument *CModDocTemplate::OpenDocumentFile(LPCTSTR path, BOOL addToMru, BOOL makeVisible) +//----------------------------------------------------------------------------------------- { - if (lpszPathName) + if (path) { TCHAR s[_MAX_EXT]; - _tsplitpath(lpszPathName, NULL, NULL, NULL, s); + _tsplitpath(path, NULL, NULL, NULL, s); if (!_tcsicmp(s, _TEXT(".dll"))) { CVstPluginManager *pPluginManager = theApp.GetPluginManager(); if (pPluginManager) { - pPluginManager->AddPlugin(lpszPathName); + pPluginManager->AddPlugin(path); return NULL; } } } - CDocument *pDoc = CMultiDocTemplate::OpenDocumentFile(lpszPathName, bMakeVisible); + CDocument *pDoc = CMultiDocTemplate::OpenDocumentFile(path, addToMru, makeVisible); if (pDoc) { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - if (pMainFrm) pMainFrm->OnDocumentCreated((CModDoc *)pDoc); + if (pMainFrm) pMainFrm->OnDocumentCreated(static_cast<CModDoc *>(pDoc)); } else //Case: pDoc == 0, opening document failed. { - if(lpszPathName != 0) + if(path != NULL) { - if(PathFileExists(lpszPathName) == FALSE) + if(PathFileExists(path) == FALSE) { CString str; - str.Format(GetStrI18N(_TEXT("Unable to open \"%s\": file does not exist.")), lpszPathName); + str.Format(GetStrI18N(_TEXT("Unable to open \"%s\": file does not exist.")), path); AfxMessageBox(str); } else //Case: Valid path but opening fails. @@ -97,7 +100,7 @@ "recognised. If the former is true, it's " "recommended to close some documents as otherwise crash is likely" "(currently there %s %d document%s open).")), - lpszPathName, (nOdc == 1) ? "is" : "are", nOdc, (nOdc == 1) ? "" : "s"); + path, (nOdc == 1) ? "is" : "are", nOdc, (nOdc == 1) ? "" : "s"); AfxMessageBox(str); } } Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2011-08-16 18:40:56 UTC (rev 978) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2011-08-16 23:32:11 UTC (rev 979) @@ -157,8 +157,7 @@ <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> - <DataExecutionPrevention> - </DataExecutionPrevention> + <DataExecutionPrevention>true</DataExecutionPrevention> </Link> <Manifest> <AdditionalManifestFiles>$(ProjectDir)res/rt_manif.bin;%(AdditionalManifestFiles)</AdditionalManifestFiles> Modified: trunk/OpenMPT/mptrack/test/test.cpp =================================================================== --- trunk/OpenMPT/mptrack/test/test.cpp 2011-08-16 18:40:56 UTC (rev 978) +++ trunk/OpenMPT/mptrack/test/test.cpp 2011-08-16 23:32:11 UTC (rev 979) @@ -469,21 +469,20 @@ theFile.Append("test/test."); // Test file loading - CModDoc *pModDoc = (CModDoc *)theApp.OpenDocumentFile(theFile + "mptm"); + CModDoc *pModDoc = (CModDoc *)theApp.OpenDocumentFile(theFile + "mptm", FALSE); TestLoadFile(pModDoc); // Test file saving pModDoc->DoSave(theFile + "saved.mptm"); pModDoc->OnCloseDocument(); + // Saving the file puts it in the MRU list... + theApp.RemoveMruItem(0); + // Reload the saved file and test if everything is still working correctly. - pModDoc = (CModDoc *)theApp.OpenDocumentFile(theFile + "saved.mptm"); + pModDoc = (CModDoc *)theApp.OpenDocumentFile(theFile + "saved.mptm", FALSE); TestLoadFile(pModDoc); pModDoc->OnCloseDocument(); - - // Forget about the files we just loaded - theApp.RemoveMruItem(0); - theApp.RemoveMruItem(0); } double Rand01() {return rand() / double(RAND_MAX);} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |