| 264 | } |
| 265 | |
| 266 | void playlistItemStatisticsFile::openStatisticsFile() |
| 267 | { |
| 268 | // Is the background parser still running? If yes, abort it. |
| 269 | if (this->backgroundParserFuture.isRunning()) |
| 270 | { |
| 271 | // signal to background thread that we want to cancel the processing |
| 272 | this->breakBackgroundAtomic.store(true); |
| 273 | this->backgroundParserFuture.waitForFinished(); |
| 274 | } |
| 275 | |
| 276 | auto suffix = QFileInfo(this->prop.name).suffix(); |
| 277 | if (this->openMode == OpenMode::CSVFile || |
| 278 | (this->openMode == OpenMode::Extension && suffix == "csv")) |
| 279 | this->file.reset(new stats::StatisticsFileCSV(this->prop.name, this->statisticsData)); |
| 280 | else if (this->openMode == OpenMode::VTMBMSFile || |
| 281 | (this->openMode == OpenMode::Extension && suffix == "vtmbmsstats")) |
| 282 | this->file.reset(new stats::StatisticsFileVTMBMS(this->prop.name, this->statisticsData)); |
| 283 | else |
| 284 | assert(false); |
| 285 | |
| 286 | connect(this->file.get(), |
| 287 | &stats::StatisticsFileBase::readPOC, |
| 288 | this, |
| 289 | &playlistItemStatisticsFile::onPOCParsed); |
| 290 | connect(this->file.get(), |
| 291 | &stats::StatisticsFileBase::readPOCType, |
| 292 | this, |
| 293 | &playlistItemStatisticsFile::onPOCTypeParsed); |
| 294 | |
| 295 | // Run the parsing of the file in the background |
| 296 | this->timer.start(1000, this); |
| 297 | this->breakBackgroundAtomic.store(false); |
| 298 | this->backgroundParserFuture = QtConcurrent::run( |
| 299 | [=](stats::StatisticsFileBase *file) { |
| 300 | file->readFrameAndTypePositionsFromFile(std::ref(this->breakBackgroundAtomic)); |
| 301 | }, |
| 302 | this->file.get()); |
| 303 | |
| 304 | DEBUG_STAT( |
| 305 | "playlistItemStatisticsFile::openStatisticsFile File opened. Background parsing started."); |
| 306 | } |
| 307 | |
| 308 | // This timer event is called regularly when the background loading process is running. |
| 309 | void playlistItemStatisticsFile::timerEvent(QTimerEvent *event) |
no test coverage detected