Hi guys,

(Disclaimer: This is mostly me thinking out loud...)

Apparently I didn't read the fine print that says SQLite doesn't
support concurrent multiple writer connections, and so the new library
code is semi-broken at the moment. To the best of my understanding, we
have two options for solving this:

1) Try to write some sort of wrapper around part of QtSql that queues
all SQL interactions into a single thread. I thought for a while that
we might be able to make this work, but after staring at Qt's SQL
drivers for a few hours, I just don't see how anyone could make this
work. You'd basically have to make it so that only one QSqlQuery
object exists at any given time for the whole program by using some
crazy static blocking, but you'd also have to take into account
transactions and a maybe some other stuff. As far as I can tell,
nobody's successfully done this before.

2) Reorganize the code that uses the database so that the queries all
get executed in the GUI thread. The nasty thing about QtSql and the
QSqlTableModel class that we're using with Qt's Model/View pattern is
that there's already tons of queries going on in the GUI thread, and
it looks like it would be very difficult to get them out of there.
Fortunately, aside from searches, our SQL queries execute fairly fast
and I've never seen them noticeably block the GUI. Right now, the
database can get written to via:
- Track table view (QSqlTableModel, GUI thread)
- Library scanner (Scanner thread... so this isn't working anymore b/c
the DB is locked by the GUI thread)
- Analyser queue (Analyser thread, updates track info in DB when
analysis complete)
- Player (Reader thread? I don't even know actually... but the track
info in the DB gets updated when a track is unloaded from a player)

So the question is, can we refactor the DB access in the above code to
emit a signal that runs these queries in the GUI thread?

Thanks,
Albert

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Mixxx-devel mailing list
Mixxx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mixxx-devel

Reply via email to