Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix #3411: Threaded access to Database #3422
Qt5 documents that QSqlDatabase must not be called from varying threads.
In Mumble the Database class handles database access.
To resolve this issue, we promote Database to an instantiable class,
This replaces PR #3419.
@davidebeatrici Please not the elaborate and complete commit message.
Compared to the other PR, this PR suggests to use two explicit Database instances [and connections]. They are named, which is useful if we ever were to debug issues or errors. Identifying db connections by an arbitrary number (thread address) is not really feasible/immediately useful.
Being explicit is in most cases better than being generic. We now know who uses the database, and in which [thread] context.
This change brings us closer to the desired state of no global state. Previously we had unspecific unnamed global state (default database as per Qt). Now we use an explicit global state/instance with our Global class. If we ever manage to drop Global, this diff is at least a move in that direction.
Please note that this does not compile locally for me, but due to an unrelated non-change (somehow dirty compile workspace?). I just want to bring this out here now. CI can prove/disprove if it builds, or I'll check in the coming days.