diff --git a/src/import/ImportMIDI.cpp b/src/import/ImportMIDI.cpp index b8422b4d4..2ee40c479 100644 --- a/src/import/ImportMIDI.cpp +++ b/src/import/ImportMIDI.cpp @@ -26,6 +26,7 @@ #include "../NoteTrack.h" #include "../Project.h" +#include "../ProjectFileIO.h" #include "../ProjectHistory.h" #include "../ProjectWindow.h" #include "../SelectUtilities.h" @@ -35,8 +36,10 @@ // Given an existing project, try to import into it, return true on success bool DoImportMIDI( AudacityProject &project, const FilePath &fileName ) { + auto &projectFileIO = ProjectFileIO::Get( project ); auto &tracks = TrackList::Get( project ); auto newTrack = std::make_shared(); + bool initiallyEmpty = tracks.empty(); if (::ImportMIDI(fileName, newTrack.get())) { @@ -60,6 +63,15 @@ bool DoImportMIDI( AudacityProject &project, const FilePath &fileName ) ProjectWindow::Get( project ).ZoomAfterImport(pTrack); FileHistory::Global().Append(fileName); + + // If the project was clean and temporary (not permanently saved), then set + // the filename to the just imported path. + if (initiallyEmpty && projectFileIO.IsTemporary()) { + wxFileName fn(fileName); + project.SetProjectName(fn.GetName()); + project.SetInitialImportPath(fn.GetPath()); + projectFileIO.SetProjectTitle(); + } return true; } else