mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-23 17:30:17 +01:00
Fix dangling pointer in lambda capture for checkpoint thread
This commit is contained in:
@@ -134,7 +134,7 @@ int DBConnection::Open(const FilePath fileName)
|
|||||||
wxASSERT(mDB == nullptr);
|
wxASSERT(mDB == nullptr);
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
// Initalize checkpoint controls
|
// Initialize checkpoint controls
|
||||||
mCheckpointStop = false;
|
mCheckpointStop = false;
|
||||||
mCheckpointPending = false;
|
mCheckpointPending = false;
|
||||||
mCheckpointActive = false;
|
mCheckpointActive = false;
|
||||||
@@ -157,7 +157,8 @@ int DBConnection::Open(const FilePath fileName)
|
|||||||
if (SafeMode())
|
if (SafeMode())
|
||||||
{
|
{
|
||||||
auto db = mCheckpointDB;
|
auto db = mCheckpointDB;
|
||||||
mCheckpointThread = std::thread([this, db, name]{ CheckpointThread(db, name); });
|
mCheckpointThread = std::thread(
|
||||||
|
[this, db, fileName]{ CheckpointThread(db, fileName); });
|
||||||
|
|
||||||
// Install our checkpoint hook
|
// Install our checkpoint hook
|
||||||
sqlite3_wal_hook(mDB, CheckpointHook, this);
|
sqlite3_wal_hook(mDB, CheckpointHook, this);
|
||||||
@@ -426,7 +427,7 @@ sqlite3_stmt *DBConnection::Prepare(enum StatementID id, const char *sql)
|
|||||||
return stmt;
|
return stmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBConnection::CheckpointThread(sqlite3 *db, const char *name)
|
void DBConnection::CheckpointThread(sqlite3 *db, const FilePath &fileName)
|
||||||
{
|
{
|
||||||
int rc = SQLITE_OK;
|
int rc = SQLITE_OK;
|
||||||
bool giveUp = false;
|
bool giveUp = false;
|
||||||
@@ -474,12 +475,12 @@ void DBConnection::CheckpointThread(sqlite3 *db, const char *name)
|
|||||||
wxLogMessage("Failed to perform checkpoint on %s\n"
|
wxLogMessage("Failed to perform checkpoint on %s\n"
|
||||||
"\tErrCode: %d\n"
|
"\tErrCode: %d\n"
|
||||||
"\tErrMsg: %s",
|
"\tErrMsg: %s",
|
||||||
name,
|
fileName,
|
||||||
sqlite3_errcode(db),
|
sqlite3_errcode(db),
|
||||||
sqlite3_errmsg(db));
|
sqlite3_errmsg(db));
|
||||||
|
|
||||||
// Can't checkpoint -- maybe the device has too little space
|
// Can't checkpoint -- maybe the device has too little space
|
||||||
wxFileNameWrapper fName{ name };
|
wxFileNameWrapper fName{ fileName };
|
||||||
auto path = FileNames::AbbreviatePath(fName);
|
auto path = FileNames::AbbreviatePath(fName);
|
||||||
auto name = fName.GetFullName();
|
auto name = fName.GetFullName();
|
||||||
auto longname = name + "-wal";
|
auto longname = name + "-wal";
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool ModeConfig(sqlite3 *db, const char *schema, const char *config);
|
bool ModeConfig(sqlite3 *db, const char *schema, const char *config);
|
||||||
|
|
||||||
void CheckpointThread(sqlite3 *db, const char *name);
|
void CheckpointThread(sqlite3 *db, const FilePath &fileName);
|
||||||
static int CheckpointHook(void *data, sqlite3 *db, const char *schema, int pages);
|
static int CheckpointHook(void *data, sqlite3 *db, const char *schema, int pages);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user