Skip to content

Commit

Permalink
Small code tweaks here and there
Browse files Browse the repository at this point in the history
* No need to call QStaticText::prepare, it will be done when needed.
* Removed some superfluous includes.
* Use convenient QProcess::startCommand from Qt 6 onwards.
* Fixed leaking of IssueDelegate (thanks AddressSanitizer).
  • Loading branch information
bjorn committed Aug 3, 2023
1 parent 99e0599 commit fb2390a
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 10 deletions.
2 changes: 0 additions & 2 deletions src/tiled/actionsearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ void ActionMatchDelegate::paint(QPainter *painter,
QStaticText staticText(nameHtml);
staticText.setTextOption(textOption);
staticText.setTextFormat(Qt::RichText);
staticText.prepare(painter->transform(), fonts.big);

painter->setFont(fonts.big);
painter->drawStaticText(nameRect.topLeft(), staticText);
Expand All @@ -170,7 +169,6 @@ void ActionMatchDelegate::paint(QPainter *painter,

staticText.setTextFormat(Qt::PlainText);
staticText.setText(shortcutText);
staticText.prepare(painter->transform(), fonts.small);

const int centeringMargin = (shortcutRect.height() - smallFontMetrics.height()) / 2;
painter->setOpacity(0.75);
Expand Down
4 changes: 3 additions & 1 deletion src/tiled/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,12 @@ CommandProcess::CommandProcess(const Command &command, bool inTerminal, bool sho

#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
start(mFinalCommand);
#else
#elif QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QStringList args = QProcess::splitCommand(mFinalCommand);
const QString executable = args.takeFirst();
start(executable, args);
#else
startCommand(mFinalCommand);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion src/tiled/issuesdock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ IssuesDock::IssuesDock(QWidget *parent)

mIssuesView->setModel(mProxyModel);
mIssuesView->setIconSize(Utils::dpiScaled(QSize(16, 16)));
mIssuesView->setItemDelegate(new IssueDelegate);
mIssuesView->setItemDelegate(new IssueDelegate(this));
mIssuesView->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);

mFilterEdit->setFilteredView(mIssuesView);
Expand Down
2 changes: 0 additions & 2 deletions src/tiled/locatorwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,11 @@ void FileMatchDelegate::paint(QPainter *painter,
QStaticText staticText(fileNameHtml);
staticText.setTextOption(textOption);
staticText.setTextFormat(Qt::RichText);
staticText.prepare(painter->transform(), fonts.big);

painter->setFont(fonts.big);
painter->drawStaticText(fileNameRect.topLeft(), staticText);

staticText.setText(filePathHtml);
staticText.prepare(painter->transform(), fonts.small);

painter->setOpacity(0.75);
painter->setFont(fonts.small);
Expand Down
2 changes: 0 additions & 2 deletions src/tmxrasterizer/tmxrasterizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
#include "imagelayer.h"
#include "map.h"
#include "mapformat.h"
#include "mapreader.h"
#include "maprenderer.h"
#include "objectgroup.h"
#include "tilelayer.h"
#include "tilesetmanager.h"
Expand Down
4 changes: 2 additions & 2 deletions src/tmxrasterizer/tmxrasterizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

#include "layer.h"

#include "map.h"
#include "mapreader.h"
#include "maprenderer.h"

#include <QString>
#include <QStringList>

Expand Down

0 comments on commit fb2390a

Please sign in to comment.