Originally Posted by
jpn
Presumably you use it in myUnit::run() too, which means you're using the same database object in multiple threads (which is a no no). The constructor of myUnit is executed in that thread which creates the myUnit object (eg. main thread). However, myUnit::run() gets executed in the "new" thread. For more details, read the detailed description of
QThread docs.
Hi jpn
This is my myUnit::run
void myUnit::run()
{
this->peerAddress = tcpSocket.peerAddress().toString();
textcolor ( DIM, CYAN, BLACK );
printf ("%s: Incoming connection from [%s] - Active clients: %d - DB conn: %s\r\n", qPrintable(dt), qPrintable(peerAddress), server->nbrClients, dbUnique);
textcolor ( BRIGHT, WHITE, BLACK );
exec();
return;
}
void myUnit::run()
{
QString dt = getDateTime();
this->peerAddress = tcpSocket.peerAddress().toString();
textcolor ( DIM, CYAN, BLACK );
printf ("%s: Incoming connection from [%s] - Active clients: %d - DB conn: %s\r\n", qPrintable(dt), qPrintable(peerAddress), server->nbrClients, dbUnique);
textcolor ( BRIGHT, WHITE, BLACK );
exec();
return;
}
To copy to clipboard, switch view to plain text mode
As you can see, no access to the DB here...
Are you saying that I should initialize the DB in myUnit::run ?
Thanks,
Pedro.
Bookmarks