summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-07-25 14:53:25 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-07-25 13:22:26 +0000
commit6078bd1b060d2e315e251357573b2eb3b00c129f (patch)
tree25dc18b0d7b0624fcaa9f7bdcce79f77e18c5bc1
parent3ce4782101ba9ddc711d00aa0de5f15bda721405 (diff)
Fix some clang-tidy warnings
- Fix 'if (foo) delete foo' to 'delete foo' - Use ' = default' for trivial constructors/destructors - Use range based for where possible - Fix invocations of static methods - Replace some reinterpret_cast by static_cast Change-Id: I998572f370f3e8a1fc39e6c763e941d5a2f598b0 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
-rw-r--r--examples/winextras/iconextractor/main.cpp24
-rw-r--r--src/winextras/qwinevent.cpp12
-rw-r--r--src/winextras/qwinjumplist.cpp3
-rw-r--r--src/winextras/qwinjumplistitem.cpp4
-rw-r--r--src/winextras/qwintaskbarbutton.cpp7
-rw-r--r--src/winextras/qwinthumbnailtoolbar.cpp14
-rw-r--r--src/winextras/qwinthumbnailtoolbutton.cpp4
7 files changed, 26 insertions, 42 deletions
diff --git a/examples/winextras/iconextractor/main.cpp b/examples/winextras/iconextractor/main.cpp
index d630f9b..0d7ebbd 100644
--- a/examples/winextras/iconextractor/main.cpp
+++ b/examples/winextras/iconextractor/main.cpp
@@ -189,17 +189,15 @@ static PixmapEntryList extractShellIcons(const QString &sourceFile, bool addOver
if (!QFileInfo(sourceFile).isDir())
baseFlags |= SHGFI_USEFILEATTRIBUTES;
- const size_t modeEntryCount = sizeof(modeEntries) / sizeof(modeEntries[0]);
- const size_t standardSizeEntryCount = sizeof(standardSizeEntries) / sizeof(standardSizeEntries[0]);
PixmapEntryList result;
- for (size_t m = 0; m < modeEntryCount; ++m) {
- const unsigned modeFlags = baseFlags | modeEntries[m].flags;
+ for (auto modeEntry : modeEntries) {
+ const unsigned modeFlags = baseFlags | modeEntry.flags;
QString modePrefix = QLatin1String("_shell_");
- if (modeEntries[m].name[0])
- modePrefix += QLatin1String(modeEntries[m].name) + QLatin1Char('_');
- for (size_t s = 0; s < standardSizeEntryCount; ++s) {
- const unsigned flags = modeFlags | standardSizeEntries[s].flags;
- const QString prefix = modePrefix + QLatin1String(standardSizeEntries[s].name)
+ if (modeEntry.name[0])
+ modePrefix += QLatin1String(modeEntry.name) + QLatin1Char('_');
+ for (auto standardSizeEntry : standardSizeEntries) {
+ const unsigned flags = modeFlags | standardSizeEntry.flags;
+ const QString prefix = modePrefix + QLatin1String(standardSizeEntry.name)
+ QLatin1Char('_');
ZeroMemory(&info, sizeof(SHFILEINFO));
const HRESULT hr = SHGetFileInfo(sourceFileC, 0, &info, sizeof(SHFILEINFO), flags);
@@ -280,7 +278,7 @@ int main(int argc, char *argv[])
const QCommandLineOption shellOverlayOption(QStringLiteral("overlay"), QStringLiteral("Extract shell overlay icons"));
parser.addOption(shellOverlayOption);
parser.addPositionalArgument(QStringLiteral("file"), QStringLiteral("The file to open."));
- parser.addPositionalArgument(QStringLiteral("image file folder"), QStringLiteral("The folder to store the images."));
+ parser.addPositionalArgument(QStringLiteral("image_file_folder"), QStringLiteral("The folder to store the images."));
parser.process(app);
const QStringList &positionalArguments = parser.positionalArguments();
if (positionalArguments.isEmpty())
@@ -299,9 +297,9 @@ int main(int argc, char *argv[])
? extractShellIcons(sourceFile, parser.isSet(shellOverlayOption))
: extractIcons(sourceFile, parser.isSet(largeIconOption));
- for (int i = 0, count = pixmaps.size(); i < count; ++i) {
- const QString fileName = imageFileRoot + pixmaps.at(i).name + QLatin1String(".png");
- if (!pixmaps.at(i).pixmap.save(fileName)) {
+ for (const auto &entry : pixmaps) {
+ const QString fileName = imageFileRoot + entry.name + QLatin1String(".png");
+ if (!entry.pixmap.save(fileName)) {
std::wcerr << "Error writing image file " << fileName << ".\n";
return 1;
}
diff --git a/src/winextras/qwinevent.cpp b/src/winextras/qwinevent.cpp
index 13642f4..a1e77b4 100644
--- a/src/winextras/qwinevent.cpp
+++ b/src/winextras/qwinevent.cpp
@@ -49,24 +49,18 @@ QWinEvent::QWinEvent(int type) : QEvent(static_cast<QEvent::Type>(type))
{
}
-QWinEvent::~QWinEvent()
-{
-}
+QWinEvent::~QWinEvent() = default;
QWinColorizationChangeEvent::QWinColorizationChangeEvent(QRgb color, bool opaque)
: QWinEvent(ColorizationChange), rgb(color), opaque(opaque)
{
}
-QWinColorizationChangeEvent::~QWinColorizationChangeEvent()
-{
-}
+QWinColorizationChangeEvent::~QWinColorizationChangeEvent() = default;
QWinCompositionChangeEvent::QWinCompositionChangeEvent(bool enabled)
: QWinEvent(CompositionChange), enabled(enabled)
{
}
-QWinCompositionChangeEvent::~QWinCompositionChangeEvent()
-{
-}
+QWinCompositionChangeEvent::~QWinCompositionChangeEvent() = default;
diff --git a/src/winextras/qwinjumplist.cpp b/src/winextras/qwinjumplist.cpp
index 19a63a6..ca1b20a 100644
--- a/src/winextras/qwinjumplist.cpp
+++ b/src/winextras/qwinjumplist.cpp
@@ -120,7 +120,8 @@ void QWinJumpListPrivate::warning(const char *function, HRESULT hresult)
QString QWinJumpListPrivate::iconsDirPath()
{
- QString iconDirPath = QDir::tempPath() + QLatin1Char('/') + QCoreApplication::instance()->applicationName() + QLatin1String("/qt-jl-icons/");
+ QString iconDirPath = QDir::tempPath() + QLatin1Char('/')
+ + QCoreApplication::applicationName() + QLatin1String("/qt-jl-icons/");
QDir().mkpath(iconDirPath);
return iconDirPath;
}
diff --git a/src/winextras/qwinjumplistitem.cpp b/src/winextras/qwinjumplistitem.cpp
index 7357892..6c183ec 100644
--- a/src/winextras/qwinjumplistitem.cpp
+++ b/src/winextras/qwinjumplistitem.cpp
@@ -86,9 +86,7 @@ QWinJumpListItem::QWinJumpListItem(QWinJumpListItem::Type type) :
/*!
Destroys the QWinJumpListItem.
*/
-QWinJumpListItem::~QWinJumpListItem()
-{
-}
+QWinJumpListItem::~QWinJumpListItem() = default;
/*!
Sets the item \a type.
diff --git a/src/winextras/qwintaskbarbutton.cpp b/src/winextras/qwintaskbarbutton.cpp
index 2516865..a1475d3 100644
--- a/src/winextras/qwintaskbarbutton.cpp
+++ b/src/winextras/qwintaskbarbutton.cpp
@@ -152,8 +152,7 @@ void QWinTaskbarButtonPrivate::updateOverlayIcon()
if (hicon)
DestroyIcon(hicon);
- if (descrPtr)
- delete[] descrPtr;
+ delete[] descrPtr;
}
void QWinTaskbarButtonPrivate::_q_updateProgress()
@@ -189,9 +188,7 @@ QWinTaskbarButton::QWinTaskbarButton(QObject *parent) :
/*!
Destroys the QWinTaskbarButton.
*/
-QWinTaskbarButton::~QWinTaskbarButton()
-{
-}
+QWinTaskbarButton::~QWinTaskbarButton() = default;
/*!
\property QWinTaskbarButton::window
diff --git a/src/winextras/qwinthumbnailtoolbar.cpp b/src/winextras/qwinthumbnailtoolbar.cpp
index 244520a..3aa39b6 100644
--- a/src/winextras/qwinthumbnailtoolbar.cpp
+++ b/src/winextras/qwinthumbnailtoolbar.cpp
@@ -119,9 +119,7 @@ QWinThumbnailToolBar::QWinThumbnailToolBar(QObject *parent) :
/*!
Destroys and clears the QWinThumbnailToolBar.
*/
-QWinThumbnailToolBar::~QWinThumbnailToolBar()
-{
-}
+QWinThumbnailToolBar::~QWinThumbnailToolBar() = default;
/*!
\property QWinThumbnailToolBar::window
@@ -518,12 +516,12 @@ void QWinThumbnailToolBarPrivate::_q_updateToolbar()
if (FAILED(hresult))
qWarning() << msgComFailed("ThumbBarUpdateButtons", hresult);
updateIconicPixmapsEnabled(false);
- for (int i = 0; i < windowsLimitedThumbbarSize; i++) {
- if (buttons[i].hIcon) {
- if (createdIcons.contains(buttons[i].hIcon))
- DestroyIcon(buttons[i].hIcon);
+ for (auto & button : buttons) {
+ if (button.hIcon) {
+ if (createdIcons.contains(button.hIcon))
+ DestroyIcon(button.hIcon);
else
- DeleteObject(buttons[i].hIcon);
+ DeleteObject(button.hIcon);
}
}
}
diff --git a/src/winextras/qwinthumbnailtoolbutton.cpp b/src/winextras/qwinthumbnailtoolbutton.cpp
index e89815c..9d04324 100644
--- a/src/winextras/qwinthumbnailtoolbutton.cpp
+++ b/src/winextras/qwinthumbnailtoolbutton.cpp
@@ -80,9 +80,7 @@ QWinThumbnailToolButton::QWinThumbnailToolButton(QObject *parent) :
/*!
Destroys the QWinThumbnailToolButton.
*/
-QWinThumbnailToolButton::~QWinThumbnailToolButton()
-{
-}
+QWinThumbnailToolButton::~QWinThumbnailToolButton() = default;
/*!
\property QWinThumbnailToolButton::toolTip