Add database mutex locker and resolve "Error in my_thread_global_end()"

executeNodeQuery() and its caller are refactored since adding a QMutex pointer
to executeNodeQuery()'s arguments confuses the compiler (don't know why).

To avoid the "Error in my_thread_global_end(): X threads didn't exit" runtime
error, database connections need to be closed **on the same thread that opens
them** (#1), so we really need to open/close them on the fly instead of leaving
them open. The refactoring mentioned previously actually made this easy,
fortunately. =)

(#1) http://www.archivum.info/qt-interest@trolltech.com/2008-03/00348/Re-(Linux)-Possible-Qt-MySQL-threading-bug.html