Commit 0e14d3dc authored by Tobias Koenig's avatar Tobias Koenig
Browse files

Fix dead-lock by replacing QThread::terminate() with a boolean

condition in the main loop.

svn path=/trunk/KDE/kdepim/kaddressbook/; revision=1022332
parent 61b5a90e
......@@ -180,7 +180,7 @@ void QCsvModel::setTextQuote( const QChar &textQuote )
const bool isRunning = d->mParser->isRunning();
if ( isRunning ) {
d->mParser->terminate();
d->mParser->reader()->terminate();
d->mParser->wait();
}
......@@ -200,7 +200,7 @@ void QCsvModel::setDelimiter( const QChar &delimiter )
const bool isRunning = d->mParser->isRunning();
if ( isRunning ) {
d->mParser->terminate();
d->mParser->reader()->terminate();
d->mParser->wait();
}
......@@ -220,7 +220,7 @@ void QCsvModel::setStartRow( uint startRow )
const bool isRunning = d->mParser->isRunning();
if ( isRunning ) {
d->mParser->terminate();
d->mParser->reader()->terminate();
d->mParser->wait();
}
......@@ -240,7 +240,7 @@ void QCsvModel::setTextCodec( QTextCodec *textCodec )
const bool isRunning = d->mParser->isRunning();
if ( isRunning ) {
d->mParser->terminate();
d->mParser->reader()->terminate();
d->mParser->wait();
}
......
......@@ -31,7 +31,7 @@ class QCsvReader::Private
{
public:
Private( QCsvBuilderInterface *builder )
: mBuilder( builder )
: mBuilder( builder ), mNotTerminated( true )
{
mTextQuote = QChar( '"' );
mDelimiter = QChar( ' ' );
......@@ -52,6 +52,7 @@ class QCsvReader::Private
uint mStartRow;
bool mIgnoreDuplicates;
bool mNotTerminated;
};
void QCsvReader::Private::emitBeginLine( uint row )
......@@ -110,7 +111,7 @@ bool QCsvReader::read( QIODevice *device )
inputStream.setCodec( d->mCodec );
int maxColumn = 0;
while ( !inputStream.atEnd() ) {
while ( !inputStream.atEnd() && d->mNotTerminated ) {
inputStream >> x; // read one char
if ( x == '\r' ) inputStream >> x; // eat '\r', to handle DOS/LOSEDOWS files correctly
......@@ -280,6 +281,10 @@ QTextCodec *QCsvReader::textCodec() const
return d->mCodec;
}
void QCsvReader::terminate()
{
d->mNotTerminated = false;
}
class QCsvStandardBuilder::Private
{
......
......@@ -165,6 +165,11 @@ class QCsvReader : public QObject
*/
QTextCodec *textCodec() const;
/**
* Terminates the parsing of the csv data.
*/
void terminate();
private:
class Private;
Private* const d;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment