Skip to content

Commit

Permalink
Merge some of nickbnf#220 by gin-ahirsch
Browse files Browse the repository at this point in the history
  • Loading branch information
variar committed Jun 16, 2018
1 parent 4ba221b commit 53be04c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
6 changes: 1 addition & 5 deletions src/logdata/include/data/logdataworkerthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class IndexOperation : public QObject
protected:
// Returns the total size indexed
// Modify the passed linePosition and maxLength
void doIndex(IndexingData* linePosition, LineOffset initialPosition );
void doIndex(LineOffset initialPosition );

QString fileName_;
AtomicFlag* interruptRequest_;
Expand Down Expand Up @@ -158,10 +158,6 @@ class LogDataWorkerThread : public QThread
// Interrupts the indexing if one is in progress
void interrupt();

// Returns a copy of the current indexing data
void getIndexingData( qint64* indexedSize,
LineLength* maxLength, LinePositionArray* linePosition );

signals:
// Sent during the indexing process to signal progress
// percent being the percentage of completion.
Expand Down
15 changes: 8 additions & 7 deletions src/logdata/src/logdataworkerthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ LogDataWorkerThread::LogDataWorkerThread( IndexingData* indexing_data )

LogDataWorkerThread::~LogDataWorkerThread()
{
interruptRequested_.set();
{
QMutexLocker locker( &mutex_ );
terminate_.set();
Expand Down Expand Up @@ -221,7 +222,7 @@ PartialIndexOperation::PartialIndexOperation( const QString& fileName,
{
}

void IndexOperation::doIndex(IndexingData* indexing_data, LineOffset initialPosition )
void IndexOperation::doIndex(LineOffset initialPosition )
{
static std::shared_ptr<Configuration> config =
Persistent<Configuration>( "settings" );
Expand Down Expand Up @@ -255,7 +256,7 @@ void IndexOperation::doIndex(IndexingData* indexing_data, LineOffset initialPosi
const auto block = file.read( sizeChunk );

if ( !fileTextCodec ) {
fileTextCodec = indexing_data->getForcedEncoding();
fileTextCodec = indexing_data_->getForcedEncoding();
if ( !fileTextCodec ) {
fileTextCodec = EncodingDetector::getInstance().detectEncoding(block);
}
Expand Down Expand Up @@ -306,7 +307,7 @@ void IndexOperation::doIndex(IndexingData* indexing_data, LineOffset initialPosi
}

// Update the shared data
indexing_data->addAll( block.length(),
indexing_data_->addAll( block.length(),
LineLength( max_length ),
line_positions,
encodingGuess );
Expand All @@ -326,15 +327,15 @@ void IndexOperation::doIndex(IndexingData* indexing_data, LineOffset initialPosi
line_position.append( LineOffset( file_size + 1 ) );
line_position.setFakeFinalLF();

indexing_data->addAll( 0, 0_length, line_position, encodingGuess );
indexing_data_->addAll( 0, 0_length, line_position, encodingGuess );
}
}
else {
// TODO: Check that the file is seekable?
// If the file cannot be open, we do as if it was empty
LOG(logWARNING) << "Cannot open file " << fileName_.toStdString();

indexing_data->clear();
indexing_data_->clear();

emit indexingProgressed( 100 );
}
Expand All @@ -354,7 +355,7 @@ bool FullIndexOperation::start()
indexing_data_->clear();
indexing_data_->forceEncoding(forcedEncoding_);

doIndex( indexing_data_, 0_offset );
doIndex( 0_offset );

LOG(logDEBUG) << "FullIndexOperation: ... finished counting."
"interrupt = " << static_cast<bool>(*interruptRequest_);
Expand All @@ -374,7 +375,7 @@ bool PartialIndexOperation::start()

emit indexingProgressed( 0 );

doIndex( indexing_data_, initial_position );
doIndex( initial_position );

LOG(logDEBUG) << "PartialIndexOperation: ... finished counting.";

Expand Down

0 comments on commit 53be04c

Please sign in to comment.