I'm building some QT application to convert DBF files to SQL database.
I have a class derived from QThread to convert one DBF file containing information from one month. This class is defined as :
Qt Code:
  1. class KonwertJedenMiesiac :
  2. public QThread
  3. {
  4. Q_OBJECT
  5. public:
  6. KonwertJedenMiesiac(QString katDBF,QString bazaDBF);
  7. ~KonwertJedenMiesiac(void);
  8. void KonwertJedenMiesiac::stopKonwerter( void );
  9. void zrobIncProgressBarOperacja( void );
  10. signals:
  11. void incProgressBarOperacja( void );
  12. protected:
  13. inline long nowyKod( char litera, long kod )
  14. { if(litera == ' ' )
  15. return 0;
  16. return(litera*1000000L + kod);
  17. }
  18. protected:
  19. bool run_konwerter;
  20. mutable QMutex mutex;
  21. Code4 cb;
  22. QDate d88;
  23. QString katDBF, bazaDBF;
  24. };
To copy to clipboard, switch view to plain text mode 
The constructor look s like :
Qt Code:
  1. KonwertJedenMiesiac::KonwertJedenMiesiac(QString katDBF, QString bazaDBF )
  2. {
  3. run_konwerter = true;
  4. d88 = QDate(1988,01,01);
  5. this->bazaDBF = bazaDBF;
  6. this->katDBF = katDBF;
  7.  
  8. // wczytujemy parametry bazy danych
  9. QSettings settings( "dworzec.ini", QSettings::IniFormat);
  10. settings.beginGroup("DbSetup");
  11.  
  12. db = QSqlDatabase::addDatabase(settings.value("DbType").toString(),bazaDBF);
  13.  
  14. db.setHostName(settings.value("HostName").toString());
  15. db.setDatabaseName(settings.value("DatabaseName").toString());
  16. db.setUserName(settings.value("UserName").toString());
  17. db.setPassword(settings.value("Password").toString());
  18. }
To copy to clipboard, switch view to plain text mode 

SQL database is opened in method run().
All monthly DBF files must be merged to one SQL table.
When I create only one thread KonwerterJedenMiesiac all is working correctly. But when I create more than one thread from time to time INSERT rows generated in program are broken like this :
Qt Code:
  1. QSqlError(-1, "", "")
  2. "INSERT INTO pozycje_paragonow (litera,kod,pozycja,id_towaru,nazwa_towaru,jm,ilosc,cena,kod_vat,stawka_vat,rabat1,rabat2,bonifikata,kwota_ulgi,sww) VALUES ('F',7429,1,65000031,'A
To copy to clipboard, switch view to plain text mode 

I don't observe this behavior when SQL database is Firebird.

Is something special to do with PostgreSQL driver ?

Qt 4.3.3 OpenSource on Windows XP compiled with Visual C++ 2005 Express Edition. PostgreSQL developer library v.8.2.