1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-15 07:40:23 +02:00

Bug 2433 - Importing MIDI into an empty project does not change the project name

This commit is contained in:
Leland Lucius 2021-02-12 02:26:51 -06:00
parent e178f63aec
commit 0f58e8828d

View File

@ -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<NoteTrack>();
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