Skip to content

Commit

Permalink
Tidy: Use the auto type specifier instead of duplicating types. (plug…
Browse files Browse the repository at this point in the history
…ins)

The clang-tidy "use auto" modernization checker pointed out a ton of
places where a type specifier was duplicated, e.g. "Foo *var = new
Foo();", where the code can be simplified by using the new "auto"
keyword.  The previous example will be updated to read "auto *var =
new Foo();".  This example looks trivial, but when "Foo" is a 25
character QMap or something even longer, it makes the code easier to
read.  All replacements made by clang-tidy with some manual
reformatting.  There are also two tweaks for places where a pointer
was malloced with "sizeof(*ptr)" as the number of bytes of data.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-auto.html
  • Loading branch information
linuxdude42 committed Dec 2, 2019
1 parent 754a2f4 commit 0c79cdb
Show file tree
Hide file tree
Showing 33 changed files with 232 additions and 265 deletions.
56 changes: 28 additions & 28 deletions mythplugins/mytharchive/mytharchive/archivesettings.cpp
Expand Up @@ -15,7 +15,7 @@

static HostFileBrowserSetting *MythArchiveTempDir()
{
HostFileBrowserSetting *gc = new HostFileBrowserSetting("MythArchiveTempDir");
auto *gc = new HostFileBrowserSetting("MythArchiveTempDir");

gc->setLabel(ArchiveSettings::tr("MythArchive Temp Directory"));
gc->setValue("");
Expand All @@ -30,7 +30,7 @@ static HostFileBrowserSetting *MythArchiveTempDir()

static HostFileBrowserSetting *MythArchiveShareDir()
{
HostFileBrowserSetting *gc = new HostFileBrowserSetting("MythArchiveShareDir");
auto *gc = new HostFileBrowserSetting("MythArchiveShareDir");

gc->setLabel(ArchiveSettings::tr("MythArchive Share Directory"));
gc->setValue(GetShareDir() + "mytharchive/");
Expand All @@ -45,7 +45,7 @@ static HostFileBrowserSetting *MythArchiveShareDir()

static HostComboBoxSetting *PALNTSC()
{
HostComboBoxSetting *gc = new HostComboBoxSetting("MythArchiveVideoFormat");
auto *gc = new HostComboBoxSetting("MythArchiveVideoFormat");

gc->setLabel(ArchiveSettings::tr("Video format"));

Expand All @@ -59,7 +59,7 @@ static HostComboBoxSetting *PALNTSC()

static HostTextEditSetting *MythArchiveFileFilter()
{
HostTextEditSetting *gc = new HostTextEditSetting("MythArchiveFileFilter");
auto *gc = new HostTextEditSetting("MythArchiveFileFilter");

gc->setLabel(ArchiveSettings::tr("File Selector Filter"));
gc->setValue("*.mpg *.mov *.avi *.mpeg *.nuv");
Expand All @@ -71,7 +71,7 @@ static HostTextEditSetting *MythArchiveFileFilter()

static HostFileBrowserSetting *MythArchiveDVDLocation()
{
HostFileBrowserSetting *gc = new HostFileBrowserSetting("MythArchiveDVDLocation");
auto *gc = new HostFileBrowserSetting("MythArchiveDVDLocation");

gc->setLabel(ArchiveSettings::tr("Location of DVD"));
gc->setValue("/dev/dvd");
Expand All @@ -84,7 +84,7 @@ static HostFileBrowserSetting *MythArchiveDVDLocation()

static HostSpinBoxSetting *MythArchiveDriveSpeed()
{
HostSpinBoxSetting *gc = new HostSpinBoxSetting("MythArchiveDriveSpeed", 0, 48, 1);
auto *gc = new HostSpinBoxSetting("MythArchiveDriveSpeed", 0, 48, 1);

gc->setLabel(ArchiveSettings::tr("DVD Drive Write Speed"));
gc->setValue(0);
Expand All @@ -98,7 +98,7 @@ static HostSpinBoxSetting *MythArchiveDriveSpeed()

static HostTextEditSetting *MythArchiveDVDPlayerCmd()
{
HostTextEditSetting *gc = new HostTextEditSetting("MythArchiveDVDPlayerCmd");
auto *gc = new HostTextEditSetting("MythArchiveDVDPlayerCmd");

gc->setLabel(ArchiveSettings::tr("Command to play DVD"));
gc->setValue("Internal");
Expand All @@ -114,7 +114,7 @@ static HostTextEditSetting *MythArchiveDVDPlayerCmd()

static HostCheckBoxSetting *MythArchiveCopyRemoteFiles()
{
HostCheckBoxSetting *gc = new HostCheckBoxSetting("MythArchiveCopyRemoteFiles");
auto *gc = new HostCheckBoxSetting("MythArchiveCopyRemoteFiles");

gc->setLabel(ArchiveSettings::tr("Copy remote files"));
gc->setValue(false);
Expand All @@ -129,7 +129,7 @@ static HostCheckBoxSetting *MythArchiveCopyRemoteFiles()

static HostCheckBoxSetting *MythArchiveAlwaysUseMythTranscode()
{
HostCheckBoxSetting *gc = new HostCheckBoxSetting("MythArchiveAlwaysUseMythTranscode");
auto *gc = new HostCheckBoxSetting("MythArchiveAlwaysUseMythTranscode");

gc->setLabel(ArchiveSettings::tr("Always Use Mythtranscode"));
gc->setValue(true);
Expand All @@ -144,7 +144,7 @@ static HostCheckBoxSetting *MythArchiveAlwaysUseMythTranscode()

static HostCheckBoxSetting *MythArchiveUseProjectX()
{
HostCheckBoxSetting *gc = new HostCheckBoxSetting("MythArchiveUseProjectX");
auto *gc = new HostCheckBoxSetting("MythArchiveUseProjectX");

gc->setLabel(ArchiveSettings::tr("Use ProjectX"));
gc->setValue(false);
Expand All @@ -158,7 +158,7 @@ static HostCheckBoxSetting *MythArchiveUseProjectX()

static HostCheckBoxSetting *MythArchiveUseFIFO()
{
HostCheckBoxSetting *gc = new HostCheckBoxSetting("MythArchiveUseFIFO");
auto *gc = new HostCheckBoxSetting("MythArchiveUseFIFO");

gc->setLabel(ArchiveSettings::tr("Use FIFOs"));
gc->setValue(true);
Expand All @@ -174,7 +174,7 @@ static HostCheckBoxSetting *MythArchiveUseFIFO()

static HostCheckBoxSetting *MythArchiveAddSubtitles()
{
HostCheckBoxSetting *gc = new HostCheckBoxSetting("MythArchiveAddSubtitles");
auto *gc = new HostCheckBoxSetting("MythArchiveAddSubtitles");

gc->setLabel(ArchiveSettings::tr("Add Subtitles"));
gc->setValue(false);
Expand All @@ -187,7 +187,7 @@ static HostCheckBoxSetting *MythArchiveAddSubtitles()

static HostComboBoxSetting *MainMenuAspectRatio()
{
HostComboBoxSetting *gc = new HostComboBoxSetting("MythArchiveMainMenuAR");
auto *gc = new HostComboBoxSetting("MythArchiveMainMenuAR");

gc->setLabel(ArchiveSettings::tr("Main Menu Aspect Ratio"));

Expand All @@ -203,7 +203,7 @@ static HostComboBoxSetting *MainMenuAspectRatio()

static HostComboBoxSetting *ChapterMenuAspectRatio()
{
HostComboBoxSetting *gc = new HostComboBoxSetting("MythArchiveChapterMenuAR");
auto *gc = new HostComboBoxSetting("MythArchiveChapterMenuAR");

gc->setLabel(ArchiveSettings::tr("Chapter Menu Aspect Ratio"));

Expand All @@ -224,7 +224,7 @@ static HostComboBoxSetting *ChapterMenuAspectRatio()

static HostComboBoxSetting *MythArchiveDateFormat()
{
HostComboBoxSetting *gc = new HostComboBoxSetting("MythArchiveDateFormat");
auto *gc = new HostComboBoxSetting("MythArchiveDateFormat");
gc->setLabel(ArchiveSettings::tr("Date format"));

QDate sampdate = MythDate::current().toLocalTime().date();
Expand Down Expand Up @@ -260,7 +260,7 @@ static HostComboBoxSetting *MythArchiveDateFormat()

static HostComboBoxSetting *MythArchiveTimeFormat()
{
HostComboBoxSetting *gc = new HostComboBoxSetting("MythArchiveTimeFormat");
auto *gc = new HostComboBoxSetting("MythArchiveTimeFormat");
gc->setLabel(ArchiveSettings::tr("Time format"));

QTime samptime = QTime::currentTime();
Expand All @@ -278,7 +278,7 @@ static HostComboBoxSetting *MythArchiveTimeFormat()

static HostComboBoxSetting *MythArchiveDefaultEncProfile()
{
HostComboBoxSetting *gc = new HostComboBoxSetting("MythArchiveDefaultEncProfile");
auto *gc = new HostComboBoxSetting("MythArchiveDefaultEncProfile");
gc->setLabel(ArchiveSettings::tr("Default Encoder Profile"));

gc->addSelection(ArchiveSettings::tr("HQ", "Encoder profile"), "HQ");
Expand All @@ -295,7 +295,7 @@ static HostComboBoxSetting *MythArchiveDefaultEncProfile()

static HostTextEditSetting *MythArchiveMplexCmd()
{
HostTextEditSetting *gc = new HostTextEditSetting("MythArchiveMplexCmd");
auto *gc = new HostTextEditSetting("MythArchiveMplexCmd");

gc->setLabel(ArchiveSettings::tr("mplex Command"));

Expand All @@ -308,7 +308,7 @@ static HostTextEditSetting *MythArchiveMplexCmd()

static HostTextEditSetting *MythArchiveDvdauthorCmd()
{
HostTextEditSetting *gc = new HostTextEditSetting("MythArchiveDvdauthorCmd");
auto *gc = new HostTextEditSetting("MythArchiveDvdauthorCmd");

gc->setLabel(ArchiveSettings::tr("dvdauthor command"));

Expand All @@ -321,7 +321,7 @@ static HostTextEditSetting *MythArchiveDvdauthorCmd()

static HostTextEditSetting *MythArchiveMkisofsCmd()
{
HostTextEditSetting *gc = new HostTextEditSetting("MythArchiveMkisofsCmd");
auto *gc = new HostTextEditSetting("MythArchiveMkisofsCmd");

gc->setLabel(ArchiveSettings::tr("mkisofs command"));

Expand All @@ -334,7 +334,7 @@ static HostTextEditSetting *MythArchiveMkisofsCmd()

static HostTextEditSetting *MythArchiveGrowisofsCmd()
{
HostTextEditSetting *gc = new HostTextEditSetting("MythArchiveGrowisofsCmd");
auto *gc = new HostTextEditSetting("MythArchiveGrowisofsCmd");

gc->setLabel(ArchiveSettings::tr("growisofs command"));

Expand All @@ -347,7 +347,7 @@ static HostTextEditSetting *MythArchiveGrowisofsCmd()

static HostTextEditSetting *MythArchiveM2VRequantiserCmd()
{
HostTextEditSetting *gc = new HostTextEditSetting("MythArchiveM2VRequantiserCmd");
auto *gc = new HostTextEditSetting("MythArchiveM2VRequantiserCmd");

gc->setLabel(ArchiveSettings::tr("M2VRequantiser command"));

Expand All @@ -361,7 +361,7 @@ static HostTextEditSetting *MythArchiveM2VRequantiserCmd()

static HostTextEditSetting *MythArchiveJpeg2yuvCmd()
{
HostTextEditSetting *gc = new HostTextEditSetting("MythArchiveJpeg2yuvCmd");
auto *gc = new HostTextEditSetting("MythArchiveJpeg2yuvCmd");

gc->setLabel(ArchiveSettings::tr("jpeg2yuv command"));

Expand All @@ -374,7 +374,7 @@ static HostTextEditSetting *MythArchiveJpeg2yuvCmd()

static HostTextEditSetting *MythArchiveSpumuxCmd()
{
HostTextEditSetting *gc = new HostTextEditSetting("MythArchiveSpumuxCmd");
auto *gc = new HostTextEditSetting("MythArchiveSpumuxCmd");

gc->setLabel(ArchiveSettings::tr("spumux command"));

Expand All @@ -387,7 +387,7 @@ static HostTextEditSetting *MythArchiveSpumuxCmd()

static HostTextEditSetting *MythArchiveMpeg2encCmd()
{
HostTextEditSetting *gc = new HostTextEditSetting("MythArchiveMpeg2encCmd");
auto *gc = new HostTextEditSetting("MythArchiveMpeg2encCmd");

gc->setLabel(ArchiveSettings::tr("mpeg2enc command"));

Expand All @@ -400,7 +400,7 @@ static HostTextEditSetting *MythArchiveMpeg2encCmd()

static HostTextEditSetting *MythArchiveProjectXCmd()
{
HostTextEditSetting *gc = new HostTextEditSetting("MythArchiveProjectXCmd");
auto *gc = new HostTextEditSetting("MythArchiveProjectXCmd");

gc->setLabel(ArchiveSettings::tr("projectx command"));

Expand Down Expand Up @@ -430,15 +430,15 @@ ArchiveSettings::ArchiveSettings()
addChild(MythArchiveUseFIFO());
addChild(MythArchiveDefaultEncProfile());

GroupSetting* DVDSettings = new GroupSetting();
auto* DVDSettings = new GroupSetting();
DVDSettings->setLabel(ArchiveSettings::tr("DVD Menu Settings"));
DVDSettings->addChild(MainMenuAspectRatio());
DVDSettings->addChild(ChapterMenuAspectRatio());
DVDSettings->addChild(MythArchiveDateFormat());
DVDSettings->addChild(MythArchiveTimeFormat());
addChild(DVDSettings);

GroupSetting* externalCmdSettings = new GroupSetting();
auto* externalCmdSettings = new GroupSetting();
externalCmdSettings->setLabel(ArchiveSettings::tr("MythArchive External Commands"));
externalCmdSettings->addChild(MythArchiveMplexCmd());
externalCmdSettings->addChild(MythArchiveDvdauthorCmd());
Expand Down
2 changes: 1 addition & 1 deletion mythplugins/mytharchive/mytharchive/archiveutil.cpp
Expand Up @@ -288,7 +288,7 @@ bool getFileDetails(ArchiveItem *a)
void showWarningDialog(const QString &msg)
{
MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
MythConfirmationDialog *dialog = new MythConfirmationDialog(popupStack, msg, false);
auto *dialog = new MythConfirmationDialog(popupStack, msg, false);

if (dialog->Create())
popupStack->AddScreen(dialog);
Expand Down
14 changes: 7 additions & 7 deletions mythplugins/mytharchive/mytharchive/exportnative.cpp
Expand Up @@ -181,7 +181,7 @@ void ExportNative::updateSizeBar()

void ExportNative::titleChanged(MythUIButtonListItem *item)
{
ArchiveItem *a = item->GetData().value<ArchiveItem *>();
auto *a = item->GetData().value<ArchiveItem *>();
if (!a)
return;

Expand Down Expand Up @@ -238,7 +238,7 @@ void ExportNative::updateArchiveList(void)
{
ArchiveItem *a = m_archiveList.at(x);

MythUIButtonListItem* item = new MythUIButtonListItem(m_archiveButtonList, a->title);
auto* item = new MythUIButtonListItem(m_archiveButtonList, a->title);
item->SetData(qVariantFromValue(a));
}

Expand Down Expand Up @@ -266,7 +266,7 @@ void ExportNative::getArchiveListFromDB(void)
{
while (query.next())
{
ArchiveItem *item = new ArchiveItem;
auto *item = new ArchiveItem;

item->id = query.value(0).toInt();
item->type = query.value(1).toString();
Expand Down Expand Up @@ -348,7 +348,7 @@ void ExportNative::ShowMenu()
{
MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");

MythDialogBox *menuPopup = new MythDialogBox(tr("Menu"), popupStack, "actionmenu");
auto *menuPopup = new MythDialogBox(tr("Menu"), popupStack, "actionmenu");

if (menuPopup->Create())
popupStack->AddScreen(menuPopup);
Expand All @@ -361,7 +361,7 @@ void ExportNative::ShowMenu()
void ExportNative::removeItem()
{
MythUIButtonListItem *item = m_archiveButtonList->GetItemCurrent();
ArchiveItem *curItem = item->GetData().value<ArchiveItem *>();
auto *curItem = item->GetData().value<ArchiveItem *>();

if (!curItem)
return;
Expand Down Expand Up @@ -461,7 +461,7 @@ void ExportNative::handleAddRecording()
{
MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();

RecordingSelector *selector = new RecordingSelector(mainStack, &m_archiveList);
auto *selector = new RecordingSelector(mainStack, &m_archiveList);

connect(selector, SIGNAL(haveResult(bool)),
this, SLOT(selectorClosed(bool)));
Expand Down Expand Up @@ -491,7 +491,7 @@ void ExportNative::handleAddVideo()

MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();

VideoSelector *selector = new VideoSelector(mainStack, &m_archiveList);
auto *selector = new VideoSelector(mainStack, &m_archiveList);

connect(selector, SIGNAL(haveResult(bool)),
this, SLOT(selectorClosed(bool)));
Expand Down
14 changes: 7 additions & 7 deletions mythplugins/mytharchive/mytharchive/fileselector.cpp
Expand Up @@ -123,7 +123,7 @@ void FileSelector::itemClicked(MythUIButtonListItem *item)
if (!item)
return;

FileData *fileData = item->GetData().value<FileData*>();
auto *fileData = item->GetData().value<FileData*>();

if (fileData->directory)
{
Expand Down Expand Up @@ -263,7 +263,7 @@ void FileSelector::OKPressed()
if (pos > 0)
title = f.mid(pos + 1);

ArchiveItem *a = new ArchiveItem;
auto *a = new ArchiveItem;
a->type = "File";
a->title = title;
a->subtitle = "";
Expand All @@ -289,7 +289,7 @@ void FileSelector::OKPressed()
else
{
MythUIButtonListItem *item = m_fileButtonList->GetItemCurrent();
FileData *fileData = item->GetData().value<FileData*>();
auto *fileData = item->GetData().value<FileData*>();

if (m_selectorType == FSTYPE_DIRECTORY)
{
Expand Down Expand Up @@ -389,15 +389,15 @@ void FileSelector::updateFileList()
fi = list.at(x);
if (fi.fileName() != ".")
{
FileData *data = new FileData;
auto *data = new FileData;
data->selected = false;
data->directory = true;
data->filename = fi.fileName();
data->size = 0;
m_fileData.append(data);

// add a row to the MythUIButtonList
MythUIButtonListItem* item = new
auto* item = new
MythUIButtonListItem(m_fileButtonList, data->filename);
item->setCheckable(false);
item->SetImage("ma_folder.png");
Expand All @@ -414,15 +414,15 @@ void FileSelector::updateFileList()
for (int x = 0; x < list.size(); x++)
{
fi = list.at(x);
FileData *data = new FileData;
auto *data = new FileData;
data->selected = false;
data->directory = false;
data->filename = fi.fileName();
data->size = fi.size();
m_fileData.append(data);

// add a row to the UIListBtnArea
MythUIButtonListItem* item =
auto* item =
new MythUIButtonListItem(m_fileButtonList, data->filename);
item->SetText(formatSize(data->size / 1024, 2), "size");

Expand Down

0 comments on commit 0c79cdb

Please sign in to comment.