mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-23 17:30:17 +01:00
Unitary thread review (#623)
* Fix uninitialized members of ProjectFileIO... ... which fixes this problem I observed: Opening a previously saved project, saving-as to another path, then exiting Audacity, gives a progress dialog waiting for checkpoints to end, which doesn't go away * Remove two mutexes... ... One wasn't used at all, and another was only ever used by one thread, and then not correctly unlocked for each locking on all possible paths. * Values that the worker thread writes and main reads should be atomic * Remember to close db connections even after failure to open
This commit is contained in:
@@ -311,11 +311,8 @@ void ProjectFileIO::CheckpointThread()
|
||||
}
|
||||
|
||||
// Capture the number of pages that need checkpointing and reset
|
||||
mCheckpointCurrentPages = mCheckpointWaitingPages;
|
||||
mCheckpointCurrentPages.store( mCheckpointWaitingPages );
|
||||
mCheckpointWaitingPages = 0;
|
||||
|
||||
// Lock out others while the checkpoint is running
|
||||
mCheckpointActive.lock();
|
||||
}
|
||||
|
||||
// Open another connection to the DB to prevent blocking the main thread.
|
||||
@@ -334,10 +331,10 @@ void ProjectFileIO::CheckpointThread()
|
||||
|
||||
// Reset
|
||||
mCheckpointCurrentPages = 0;
|
||||
|
||||
// Checkpoint is complete
|
||||
mCheckpointActive.unlock();
|
||||
}
|
||||
else
|
||||
// Gotta close it anyway!
|
||||
sqlite3_close( db );
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -348,7 +345,7 @@ int ProjectFileIO::CheckpointHook(void *data, sqlite3 *db, const char *schema, i
|
||||
// Get access to our object
|
||||
ProjectFileIO *that = static_cast<ProjectFileIO *>(data);
|
||||
|
||||
// Qeuue the database pointer for our checkpoint thread to process
|
||||
// Queue the database pointer for our checkpoint thread to process
|
||||
std::lock_guard<std::mutex> guard(that->mCheckpointMutex);
|
||||
that->mCheckpointWaitingPages = pages;
|
||||
that->mCheckpointCondition.notify_one();
|
||||
|
||||
Reference in New Issue
Block a user