Skip to content

Commit

Permalink
No more QScopedPointer
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianFeldmann committed Sep 22, 2023
1 parent f5c03c9 commit 6b0c4d5
Show file tree
Hide file tree
Showing 21 changed files with 93 additions and 86 deletions.
4 changes: 2 additions & 2 deletions YUViewLib/src/filesource/FileSourceFFmpegFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ bool FileSourceFFmpegFile::scanBitstream(QWidget *mainWindow)
// Create the dialog (if the given pointer is not null)
auto maxPTS = this->getMaxTS();
// Updating the dialog (setValue) is quite slow. Only do this if the percent value changes.
int curPercentValue = 0;
QScopedPointer<QProgressDialog> progress;
int curPercentValue = 0;
std::unique_ptr<QProgressDialog> progress;
if (mainWindow != nullptr)
{
progress.reset(
Expand Down
34 changes: 17 additions & 17 deletions YUViewLib/src/parser/AVFormat/ParserAVFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ bool ParserAVFormat::parseExtradata_hevc(ByteVector &extradata)
try
{
avformat::HVCC hvcc;
hvcc.parse(extradata, packetModel->rootItem, hevcParser, this->bitratePlotModel.data());
hvcc.parse(extradata, packetModel->rootItem, hevcParser, this->bitratePlotModel.get());
}
catch (...)
{
Expand Down Expand Up @@ -567,14 +567,14 @@ bool ParserAVFormat::parseAVPacket(unsigned packetID,
bool ParserAVFormat::runParsingOfFile(QString compressedFilePath)
{
// Open the file but don't parse it yet.
QScopedPointer<FileSourceFFmpegFile> ffmpegFile(new FileSourceFFmpegFile());
if (!ffmpegFile->openFile(compressedFilePath, nullptr, nullptr, false))
FileSourceFFmpegFile ffmpegFile;
if (!ffmpegFile.openFile(compressedFilePath, nullptr, nullptr, false))
{
emit backgroundParsingDone("Error opening the ffmpeg file.");
return false;
}

this->codecID = ffmpegFile->getVideoStreamCodecID();
this->codecID = ffmpegFile.getVideoStreamCodecID();
if (this->codecID.isAVC())
this->annexBParser.reset(new ParserAnnexBAVC());
else if (this->codecID.isHEVC())
Expand All @@ -600,7 +600,7 @@ bool ParserAVFormat::runParsingOfFile(QString compressedFilePath)
// First get the extradata and push it to the parser
try
{
auto extradata = SubByteReaderLogging::convertToByteVector(ffmpegFile->getExtradata());
auto extradata = SubByteReaderLogging::convertToByteVector(ffmpegFile.getExtradata());
this->parseExtradata(extradata);
}
catch (...)
Expand All @@ -610,7 +610,7 @@ bool ParserAVFormat::runParsingOfFile(QString compressedFilePath)
}
try
{
auto metadata = ffmpegFile->getMetadata();
auto metadata = ffmpegFile.getMetadata();
this->parseMetadata(metadata);
}
catch (...)
Expand All @@ -619,17 +619,17 @@ bool ParserAVFormat::runParsingOfFile(QString compressedFilePath)
return false;
}

int max_ts = ffmpegFile->getMaxTS();
this->videoStreamIndex = ffmpegFile->getVideoStreamIndex();
this->framerate = ffmpegFile->getFramerate();
this->streamInfoAllStreams = ffmpegFile->getFileInfoForAllStreams();
this->timeBaseAllStreams = ffmpegFile->getTimeBaseAllStreams();
this->shortStreamInfoAllStreams = ffmpegFile->getShortStreamDescriptionAllStreams();
int max_ts = ffmpegFile.getMaxTS();
this->videoStreamIndex = ffmpegFile.getVideoStreamIndex();
this->framerate = ffmpegFile.getFramerate();
this->streamInfoAllStreams = ffmpegFile.getFileInfoForAllStreams();
this->timeBaseAllStreams = ffmpegFile.getTimeBaseAllStreams();
this->shortStreamInfoAllStreams = ffmpegFile.getShortStreamDescriptionAllStreams();

emit streamInfoUpdated();

// Now iterate over all packets and send them to the parser
AVPacketWrapper packet = ffmpegFile->getNextPacket(false, false);
AVPacketWrapper packet = ffmpegFile.getNextPacket(false, false);
int64_t start_ts = packet.getDTS();

unsigned packetID{};
Expand All @@ -639,7 +639,7 @@ bool ParserAVFormat::runParsingOfFile(QString compressedFilePath)
bool abortParsing = false;
QElapsedTimer signalEmitTimer;
signalEmitTimer.start();
while (!ffmpegFile->atEnd() && !abortParsing)
while (!ffmpegFile.atEnd() && !abortParsing)
{
if (packet.getPacketType() == PacketType::VIDEO)
{
Expand All @@ -661,7 +661,7 @@ bool ParserAVFormat::runParsingOfFile(QString compressedFilePath)

packetID++;
packetCounterPerStream[packet.getStreamIndex()]++;
packet = ffmpegFile->getNextPacket(false, false);
packet = ffmpegFile.getNextPacket(false, false);

// For signal slot debugging purposes, sleep
// QThread::msleep(200);
Expand All @@ -686,12 +686,12 @@ bool ParserAVFormat::runParsingOfFile(QString compressedFilePath)
}

// Seek back to the beginning of the stream.
ffmpegFile->seekFileToBeginning();
ffmpegFile.seekFileToBeginning();

if (packetModel)
emit modelDataUpdated();

this->streamInfoAllStreams = ffmpegFile->getFileInfoForAllStreams();
this->streamInfoAllStreams = ffmpegFile.getFileInfoForAllStreams();
emit streamInfoUpdated();
emit backgroundParsingDone("");

Expand Down
6 changes: 3 additions & 3 deletions YUViewLib/src/parser/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Parser::Parser(QObject *parent) : QObject(parent)
this->bitratePlotModel.reset(new BitratePlotModel());
this->hrdPlotModel.reset(new HRDPlotModel());
this->streamIndexFilter.reset(new FilterByStreamIndexProxyModel(parent));
this->streamIndexFilter->setSourceModel(this->packetModel.data());
this->streamIndexFilter->setSourceModel(this->packetModel.get());
}

Parser::~Parser()
Expand All @@ -62,8 +62,8 @@ Parser::~Parser()

HRDPlotModel *Parser::getHRDPlotModel()
{
if (this->redirectPlotModel == nullptr && !this->hrdPlotModel.isNull())
return this->hrdPlotModel.data();
if (this->redirectPlotModel == nullptr && this->hrdPlotModel)
return this->hrdPlotModel.get();
else if (this->redirectPlotModel != nullptr)
return this->redirectPlotModel;
return {};
Expand Down
16 changes: 9 additions & 7 deletions YUViewLib/src/parser/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include <QString>
#include <QTreeWidgetItem>

#include <memory>

#include "common/BitratePlotModel.h"
#include "common/HRDPlotModel.h"
#include "common/PacketItemModel.h"
Expand All @@ -59,8 +61,8 @@ class Parser : public QObject
Parser(QObject *parent);
virtual ~Parser() = 0;

QAbstractItemModel *getPacketItemModel() { return streamIndexFilter.data(); }
BitratePlotModel * getBitratePlotModel() { return bitratePlotModel.data(); }
QAbstractItemModel *getPacketItemModel() { return streamIndexFilter.get(); }
BitratePlotModel * getBitratePlotModel() { return bitratePlotModel.get(); }
HRDPlotModel * getHRDPlotModel();
void setRedirectPlotModel(HRDPlotModel *plotModel);

Expand Down Expand Up @@ -100,9 +102,9 @@ class Parser : public QObject
void streamInfoUpdated();

protected:
QScopedPointer<PacketItemModel> packetModel;
QScopedPointer<FilterByStreamIndexProxyModel> streamIndexFilter;
QScopedPointer<BitratePlotModel> bitratePlotModel;
std::unique_ptr<PacketItemModel> packetModel;
std::unique_ptr<FilterByStreamIndexProxyModel> streamIndexFilter;
std::unique_ptr<BitratePlotModel> bitratePlotModel;

static QString convertSliceTypeMapToString(QMap<QString, unsigned int> &currentAUSliceTypes);

Expand All @@ -113,8 +115,8 @@ class Parser : public QObject
bool parsingLimitEnabled{false};

private:
QScopedPointer<HRDPlotModel> hrdPlotModel;
HRDPlotModel * redirectPlotModel{nullptr};
std::unique_ptr<HRDPlotModel> hrdPlotModel;
HRDPlotModel * redirectPlotModel{nullptr};
};

} // namespace parser
6 changes: 3 additions & 3 deletions YUViewLib/src/parser/ParserAnnexB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ bool ParserAnnexB::parseAnnexBFile(std::unique_ptr<FileSourceAnnexBFile> &file,
{
DEBUG_ANNEXB("ParserAnnexB::parseAnnexBFile");

int64_t maxPos = file->getFileSize();
QScopedPointer<QProgressDialog> progressDialog;
int curPercentValue = 0;
auto maxPos = file->getFileSize();
std::unique_ptr<QProgressDialog> progressDialog;
int curPercentValue = 0;
if (mainWindow)
{
// Show a modal QProgressDialog while this operation is running.
Expand Down
10 changes: 6 additions & 4 deletions YUViewLib/src/playlistitem/playlistItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ playlistItem::playlistItem(const QString &itemNameOrFileName, Type type)
this->prop.id = idCounter++;
}

playlistItem::~playlistItem() {}
playlistItem::~playlistItem()
{
}

void playlistItem::setName(const QString &name)
{
Expand All @@ -62,7 +64,7 @@ void playlistItem::drawItem(QPainter *painter, int, double zoomFactor, bool)
auto displayFont = painter->font();
displayFont.setPointSizeF(painter->font().pointSizeF() * zoomFactor);
painter->setFont(displayFont);
auto textSize = painter->fontMetrics().size(0, infoText);
auto textSize = painter->fontMetrics().size(0, infoText);
QRect textRect;
textRect.setSize(textSize);
textRect.moveCenter(QPoint(0, 0));
Expand All @@ -75,7 +77,7 @@ QSize playlistItem::getSize() const
{
// Return the size of the text that is drawn on screen.
QPainter painter;
auto displayFont = painter.font();
auto displayFont = painter.font();
return painter.fontMetrics().size(0, infoText);
}

Expand Down Expand Up @@ -182,7 +184,7 @@ void playlistItem::createPropertiesWidget()
this->preparePropertiesWidget(QStringLiteral("playlistItem"));

// On the top level everything is layout vertically
auto vAllLaout = new QVBoxLayout(this->propertiesWidget.data());
auto vAllLaout = new QVBoxLayout(this->propertiesWidget.get());

// First add the parents controls (duration) then the text specific controls (font, text...)
vAllLaout->addLayout(createPlaylistItemControls());
Expand Down
6 changes: 3 additions & 3 deletions YUViewLib/src/playlistitem/playlistItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ class playlistItem : public QObject, public QTreeWidgetItem
{
if (!propertiesWidget)
createPropertiesWidget();
return propertiesWidget.data();
return propertiesWidget.get();
}
bool propertiesWidgetCreated() const { return !propertiesWidget.isNull(); }
bool propertiesWidgetCreated() const { return static_cast<bool>(this->propertiesWidget); }

// Does the playlist item currently accept drops of the given item?
virtual bool acceptDrops(playlistItem *) const { return false; }
Expand Down Expand Up @@ -268,7 +268,7 @@ class playlistItem : public QObject, public QTreeWidgetItem

protected:
// The widget which is put into the stack.
QScopedPointer<QWidget> propertiesWidget;
std::unique_ptr<QWidget> propertiesWidget;

// Create the properties widget and set propertiesWidget to point to it.
// Overload this function in a child class to create a custom widget.
Expand Down
14 changes: 7 additions & 7 deletions YUViewLib/src/playlistitem/playlistItemCompressedVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -905,31 +905,31 @@ void playlistItemCompressedVideo::createPropertiesWidget()
{
Q_ASSERT_X(!this->propertiesWidget, "createPropertiesWidget", "Properties widget already exists");

if (!video)
if (!this->video)
{
playlistItem::createPropertiesWidget();
return;
}

// Create a new widget and populate it with controls
this->propertiesWidget.reset(new QWidget);
ui.setupUi(propertiesWidget.data());
this->propertiesWidget = std::make_unique<QWidget>();
ui.setupUi(this->propertiesWidget.get());

auto lineOne = new QFrame;
auto lineOne = std::make_unique<QFrame>();
lineOne->setObjectName(QStringLiteral("line"));
lineOne->setFrameShape(QFrame::HLine);
lineOne->setFrameShadow(QFrame::Sunken);
auto lineTwo = new QFrame;
auto lineTwo = std::make_unique<QFrame>();
lineTwo->setObjectName(QStringLiteral("line"));
lineTwo->setFrameShape(QFrame::HLine);
lineTwo->setFrameShadow(QFrame::Sunken);

// Insert a stretch at the bottom of the vertical global layout so that everything
// gets 'pushed' to the top
ui.verticalLayout->insertLayout(0, createPlaylistItemControls());
ui.verticalLayout->insertWidget(1, lineOne);
ui.verticalLayout->insertWidget(1, lineOne.release());
ui.verticalLayout->insertLayout(2, video->createVideoHandlerControls(true));
ui.verticalLayout->insertWidget(5, lineTwo);
ui.verticalLayout->insertWidget(5, lineTwo.release());
ui.verticalLayout->insertLayout(
6, this->statisticsUIHandler.createStatisticsHandlerControls(), 1);

Expand Down
11 changes: 7 additions & 4 deletions YUViewLib/src/playlistitem/playlistItemDifference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,17 @@ void playlistItemDifference::createPropertiesWidget()
preparePropertiesWidget(QStringLiteral("playlistItemDifference"));

// On the top level everything is layout vertically
QVBoxLayout *vAllLaout = new QVBoxLayout(propertiesWidget.data());
auto vAllLaout = new QVBoxLayout(propertiesWidget.get());

QFrame *line = new QFrame;
auto line = std::make_unique<QFrame>();
line->setObjectName(QStringLiteral("line"));
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);

// First add the parents controls (first video controls (width/height...) then YUV controls
// (format,...)
vAllLaout->addLayout(difference.createFrameHandlerControls(true));
vAllLaout->addWidget(line);
vAllLaout->addWidget(line.release());
vAllLaout->addLayout(difference.createDifferenceHandlerControls());

vAllLaout->insertStretch(-1, 1); // Push controls up
Expand Down Expand Up @@ -257,7 +257,10 @@ void playlistItemDifference::loadFrame(int frameIdx,
}
}

bool playlistItemDifference::isLoading() const { return this->isDifferenceLoading; }
bool playlistItemDifference::isLoading() const
{
return this->isDifferenceLoading;
}

bool playlistItemDifference::isLoadingDoubleBuffer() const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void playlistItemImageFileSequence::createPropertiesWidget()
preparePropertiesWidget(QStringLiteral("playlistItemRawFile"));

// On the top level everything is layout vertically
QVBoxLayout *vAllLaout = new QVBoxLayout(propertiesWidget.data());
QVBoxLayout *vAllLaout = new QVBoxLayout(this->propertiesWidget.get());

// First add the parents controls (first video controls (width/height...)
vAllLaout->addLayout(createPlaylistItemControls());
Expand Down
4 changes: 2 additions & 2 deletions YUViewLib/src/playlistitem/playlistItemOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ void playlistItemOverlay::createPropertiesWidget()
Q_ASSERT_X(!this->propertiesWidget, "createPropertiesWidget", "Properties widget already exists");

// Create a new widget and populate it with controls
this->propertiesWidget.reset(new QWidget);
this->ui.setupUi(this->propertiesWidget.data());
this->propertiesWidget = std::make_unique<QWidget>();
this->ui.setupUi(this->propertiesWidget.get());

this->ui.verticalLayout->insertLayout(0, this->createPlaylistItemControls());

Expand Down
2 changes: 1 addition & 1 deletion YUViewLib/src/playlistitem/playlistItemRawFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ void playlistItemRawFile::createPropertiesWidget()
this->preparePropertiesWidget(QStringLiteral("playlistItemRawFile"));

// On the top level everything is layout vertically
auto vAllLaout = new QVBoxLayout(this->propertiesWidget.data());
auto vAllLaout = new QVBoxLayout(this->propertiesWidget.get());

auto line = new QFrame;
line->setObjectName(QStringLiteral("line"));
Expand Down
6 changes: 3 additions & 3 deletions YUViewLib/src/playlistitem/playlistItemResample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void playlistItemResample::createPropertiesWidget()
this->preparePropertiesWidget(QStringLiteral("playlistItemResample"));

// On the top level everything is layout vertically
auto vAllLaout = new QVBoxLayout(propertiesWidget.data());
auto vAllLaout = new QVBoxLayout(this->propertiesWidget.get());

ui.setupUi();

Expand Down Expand Up @@ -348,8 +348,8 @@ void playlistItemResample::slotInterpolationModeChanged(int)
{
this->interpolationIndex = ui.comboBoxInterpolation->currentIndex();
auto interpolation = (this->interpolationIndex == 0)
? video::videoHandlerResample::Interpolation::Bilinear
: video::videoHandlerResample::Interpolation::Fast;
? video::videoHandlerResample::Interpolation::Bilinear
: video::videoHandlerResample::Interpolation::Fast;
this->video.setInterpolation(interpolation);
}

Expand Down
6 changes: 3 additions & 3 deletions YUViewLib/src/playlistitem/playlistItemStatisticsFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
#include <cassert>
#include <iostream>

#include <common/YUViewDomElement.h>
#include <common/FunctionsGui.h>
#include <common/YUViewDomElement.h>
#include <statistics/StatisticsDataPainting.h>
#include <statistics/StatisticsFileCSV.h>
#include <statistics/StatisticsFileVTMBMS.h>
Expand Down Expand Up @@ -243,12 +243,12 @@ void playlistItemStatisticsFile::onPOCParsed(int poc)

void playlistItemStatisticsFile::createPropertiesWidget()
{
Q_ASSERT_X(!propertiesWidget, "createPropertiesWidget", "Properties widget already exists");
Q_ASSERT_X(!this->propertiesWidget, "createPropertiesWidget", "Properties widget already exists");

this->preparePropertiesWidget(QStringLiteral("playlistItemStatisticsFile"));

// On the top level everything is layout vertically
auto vAllLaout = new QVBoxLayout(propertiesWidget.data());
auto vAllLaout = new QVBoxLayout(this->propertiesWidget.get());

auto line = new QFrame;
line->setObjectName(QStringLiteral("lineOne"));
Expand Down
Loading

0 comments on commit 6b0c4d5

Please sign in to comment.