1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-23 17:30:17 +01:00

Bug2531 mitigation: Reduce the pause without progress dialog...

... Do so by lowering the usage of TransactionScope into UndoManager, so that
deletion of blocks is more often grouped into a transaction, as when invoking
Compact via the menu item.
This commit is contained in:
Paul Licameli
2020-09-05 15:16:57 -04:00
parent e4319144c8
commit 49fc197e42
2 changed files with 9 additions and 5 deletions

View File

@@ -15,7 +15,6 @@ Paul Licameli split from AudacityProject.cpp
#include "AdornedRulerPanel.h" #include "AdornedRulerPanel.h"
#include "AudioIO.h" #include "AudioIO.h"
#include "Clipboard.h" #include "Clipboard.h"
#include "DBConnection.h"
#include "FileNames.h" #include "FileNames.h"
#include "Menus.h" #include "Menus.h"
#include "ModuleManager.h" #include "ModuleManager.h"
@@ -741,16 +740,12 @@ void ProjectManager::OnCloseWindow(wxCloseEvent & event)
projectFileIO.SetBypass(); projectFileIO.SetBypass();
{ {
TransactionScope trans(projectFileIO.GetConnection(), "Shutdown");
// This can reduce reference counts of sample blocks in the project's // This can reduce reference counts of sample blocks in the project's
// tracks. // tracks.
UndoManager::Get( project ).ClearStates(); UndoManager::Get( project ).ClearStates();
// Delete all the tracks to free up memory // Delete all the tracks to free up memory
tracks.Clear(); tracks.Clear();
trans.Commit();
} }
// We're all done with the project file, so close it now // We're all done with the project file, so close it now

View File

@@ -26,6 +26,7 @@ UndoManager
#include <wx/hashset.h> #include <wx/hashset.h>
#include "Clipboard.h" #include "Clipboard.h"
#include "DBConnection.h"
#include "Diags.h" #include "Diags.h"
#include "Project.h" #include "Project.h"
#include "SampleBlock.h" #include "SampleBlock.h"
@@ -181,12 +182,20 @@ void UndoManager::RemoveStateAt(int n)
void UndoManager::RemoveStates(int num) void UndoManager::RemoveStates(int num)
{ {
Optional<TransactionScope> pTrans;
auto pConnection = ConnectionPtr::Get(mProject).mpConnection.get();
if (pConnection)
pTrans.emplace(*pConnection, "DiscardingUndoStates");
for (int i = 0; i < num; i++) { for (int i = 0; i < num; i++) {
RemoveStateAt(0); RemoveStateAt(0);
current -= 1; current -= 1;
saved -= 1; saved -= 1;
} }
if (pTrans)
pTrans->Commit();
} }
void UndoManager::ClearStates() void UndoManager::ClearStates()