mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-31 16:09:28 +02:00
Bug 2673 - Win: Mixer Board problem on Windows - causes crash
This commit is contained in:
parent
463058e20c
commit
53f7cacdb2
@ -165,12 +165,15 @@ bool DBConnection::Close()
|
||||
mCheckpointThread.join();
|
||||
|
||||
// We're done with the prepared statements
|
||||
for (auto stmt : mStatements)
|
||||
{
|
||||
// No need to check return code.
|
||||
sqlite3_finalize(stmt.second);
|
||||
std::lock_guard<std::mutex> guard(mStatementMutex);
|
||||
for (auto stmt : mStatements)
|
||||
{
|
||||
// No need to check return code.
|
||||
sqlite3_finalize(stmt.second);
|
||||
}
|
||||
mStatements.clear();
|
||||
}
|
||||
mStatements.clear();
|
||||
|
||||
// Close the DB
|
||||
rc = sqlite3_close(mDB);
|
||||
@ -248,10 +251,13 @@ const wxString DBConnection::GetLastMessage() const
|
||||
|
||||
sqlite3_stmt *DBConnection::Prepare(enum StatementID id, const char *sql)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(mStatementMutex);
|
||||
|
||||
int rc;
|
||||
StatementIndex ndx(id, std::this_thread::get_id());
|
||||
|
||||
// Return an existing statement if it's already been prepared
|
||||
auto iter = mStatements.find(id);
|
||||
auto iter = mStatements.find(ndx);
|
||||
if (iter != mStatements.end())
|
||||
{
|
||||
return iter->second;
|
||||
@ -267,24 +273,11 @@ sqlite3_stmt *DBConnection::Prepare(enum StatementID id, const char *sql)
|
||||
}
|
||||
|
||||
// And remember it
|
||||
mStatements.insert({id, stmt});
|
||||
mStatements.insert({ndx, stmt});
|
||||
|
||||
return stmt;
|
||||
}
|
||||
|
||||
sqlite3_stmt *DBConnection::GetStatement(enum StatementID id)
|
||||
{
|
||||
// Look it up
|
||||
auto iter = mStatements.find(id);
|
||||
|
||||
// It should always be there
|
||||
wxASSERT(iter != mStatements.end());
|
||||
|
||||
// Return it
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
|
||||
void DBConnection::CheckpointThread()
|
||||
{
|
||||
// Open another connection to the DB to prevent blocking the main thread.
|
||||
|
@ -76,7 +76,6 @@ public:
|
||||
GetRootPage,
|
||||
GetDBPage
|
||||
};
|
||||
sqlite3_stmt *GetStatement(enum StatementID id);
|
||||
sqlite3_stmt *Prepare(enum StatementID id, const char *sql);
|
||||
|
||||
void SetBypass( bool bypass );
|
||||
@ -109,7 +108,9 @@ private:
|
||||
std::atomic_bool mCheckpointPending{ false };
|
||||
std::atomic_bool mCheckpointActive{ false };
|
||||
|
||||
std::map<enum StatementID, sqlite3_stmt *> mStatements;
|
||||
std::mutex mStatementMutex;
|
||||
using StatementIndex = std::pair<enum StatementID, std::thread::id>;
|
||||
std::map<StatementIndex, sqlite3_stmt *> mStatements;
|
||||
|
||||
std::shared_ptr<DBConnectionErrors> mpErrors;
|
||||
CheckpointFailureCallback mCallback;
|
||||
|
Loading…
x
Reference in New Issue
Block a user