A collection of cppcheck fixes

This commit is contained in:
Sune Vuorela 2024-04-15 17:02:52 +02:00
parent 465b9ff5ce
commit bfc3e46f9c
10 changed files with 20 additions and 19 deletions

View File

@ -48,6 +48,7 @@ Document::Document()
: mDirectory(nullptr)
, mUnrar(nullptr)
, mArchive(nullptr)
, mArchiveDir(nullptr)
{
}

View File

@ -107,6 +107,7 @@ UnrarHelper::~UnrarHelper()
Unrar::Unrar()
: QObject(nullptr)
, mProcess(nullptr)
, mLoop(nullptr)
, mTempDir(nullptr)
{

View File

@ -542,7 +542,7 @@ void KDjVu::Private::fillBookmarksRecurse(QDomDocument &maindoc, QDomNode &curno
if (dest.at(0) == QLatin1Char('#')) {
dest.remove(0, 1);
bool isNumber = false;
dest.toInt(&isNumber);
(void)dest.toInt(&isNumber);
if (isNumber) {
// it might be an actual page number, but could also be a page label
// so resolve the number, and get the real page number

View File

@ -71,7 +71,7 @@ private:
class DocumentInfo;
DocumentInfo *mDocumentInfo;
int mSectionCounter;
int mSectionCounter = 0;
QMap<QString, QTextBlock> mSectionMap;
QMap<QString, QPair<int, int>> mLocalLinks;

View File

@ -258,7 +258,7 @@ QImage TIFFGenerator::image(Okular::PixmapRequest *request)
int reqwidth = request->width();
int reqheight = request->height();
if (rotation % 2 == 1) {
qSwap(reqwidth, reqheight);
std::swap(reqwidth, reqheight);
}
img = image.scaled(reqwidth, reqheight, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);

View File

@ -686,7 +686,7 @@ static QString unicodeString(const QString &raw)
return ret;
}
void XpsPage::processGlyph(QPainter *painter, XpsRenderNode &node)
void XpsPage::processGlyph(QPainter *painter, const XpsRenderNode &node)
{
// TODO Currently ignored attributes: CaretStops, DeviceFontName, IsSideways, OpacityMask, Name, FixedPage.NavigateURI, xml:lang, x:key
// TODO Indices is only partially implemented
@ -893,7 +893,7 @@ void XpsPage::processImageBrush(XpsRenderNode &node)
node.data = QVariant::fromValue(brush);
}
void XpsPage::processPath(QPainter *painter, XpsRenderNode &node)
void XpsPage::processPath(QPainter *painter, const XpsRenderNode &node)
{
// TODO Ignored attributes: Clip, OpacityMask, StrokeEndLineCap, StorkeStartLineCap, Name, FixedPage.NavigateURI, xml:lang, x:key, AutomationProperties.Name, AutomationProperties.HelpText, SnapsToDevicePixels
// TODO Ignored child elements: RenderTransform, Clip, OpacityMask
@ -1172,7 +1172,7 @@ void XpsPage::processPathFigure(XpsRenderNode &node)
}
}
void XpsPage::processStartElement(QPainter *painter, XpsRenderNode &node)
void XpsPage::processStartElement(QPainter *painter, const XpsRenderNode &node)
{
if (node.name == QLatin1String("Canvas")) {
painter->save();
@ -1982,7 +1982,7 @@ bool XpsGenerator::loadDocument(const QString &fileName, QVector<Okular::Page *>
int pagesVectorOffset = 0;
for (int docNum = 0; docNum < m_xpsFile->numDocuments(); ++docNum) {
XpsDocument *doc = m_xpsFile->document(docNum);
const XpsDocument *doc = m_xpsFile->document(docNum);
for (int pageNum = 0; pageNum < doc->numPages(); ++pageNum) {
QSizeF pageSize = doc->page(pageNum)->size();
pagesVector[pagesVectorOffset] = new Okular::Page(pagesVectorOffset, pageSize.width(), pageSize.height(), Okular::Rotation0);

View File

@ -122,10 +122,10 @@ public:
private:
// Methods for processing of different xml elements
void processStartElement(QPainter *painter, XpsRenderNode &node);
void processStartElement(QPainter *painter, const XpsRenderNode &node);
void processEndElement(QPainter *painter, XpsRenderNode &node);
void processGlyph(QPainter *painter, XpsRenderNode &node);
void processPath(QPainter *painter, XpsRenderNode &node);
void processGlyph(QPainter *painter, const XpsRenderNode &node);
void processPath(QPainter *painter, const XpsRenderNode &node);
void processPathData(XpsRenderNode &node);
void processFill(XpsRenderNode &node);
void processStroke(XpsRenderNode &node);
@ -142,7 +142,6 @@ private:
QString m_thumbnailFileName;
bool m_thumbnailMightBeAvailable;
QImage m_thumbnail;
bool m_thumbnailIsLoaded;
QImage *m_pageImage;
bool m_pageIsRendered;

View File

@ -226,7 +226,7 @@ QVariant TOCModel::data(const QModelIndex &index, int role) const
QFont font;
font.setBold(true);
TOCItem *lastHighlighted = d->currentPage.last();
const TOCItem *lastHighlighted = d->currentPage.last();
// in the mobile version our parent is not a QTreeView; embolden the last highlighted item
// TODO misusing parent() here, fix
@ -449,7 +449,7 @@ QString TOCModel::externalFileNameForIndex(const QModelIndex &index) const
return QString();
}
TOCItem *item = static_cast<TOCItem *>(index.internalPointer());
const TOCItem *item = static_cast<TOCItem *>(index.internalPointer());
return item->extFileName;
}
@ -459,7 +459,7 @@ Okular::DocumentViewport TOCModel::viewportForIndex(const QModelIndex &index) co
return Okular::DocumentViewport();
}
TOCItem *item = static_cast<TOCItem *>(index.internalPointer());
const TOCItem *item = static_cast<TOCItem *>(index.internalPointer());
return item->viewport;
}
@ -469,7 +469,7 @@ QString TOCModel::urlForIndex(const QModelIndex &index) const
return QString();
}
TOCItem *item = static_cast<TOCItem *>(index.internalPointer());
const TOCItem *item = static_cast<TOCItem *>(index.internalPointer());
return item->url;
}

View File

@ -48,7 +48,7 @@ struct RadioData {
}
QList<int> ids;
QButtonGroup *group;
QButtonGroup *group = nullptr;
};
class FormWidgetsController : public QObject

View File

@ -78,7 +78,8 @@
// a frame contains a pointer to the page object, its geometry and the
// transition effect to the next frame
struct PresentationFrame {
PresentationFrame() = default;
explicit PresentationFrame(const Okular::Page *_page)
: page(_page) {};
~PresentationFrame()
{
@ -335,8 +336,7 @@ void PresentationWidget::notifySetup(const QVector<Okular::Page *> &pageSet, int
// create the new frames
float screenRatio = (float)m_height / (float)m_width;
for (const Okular::Page *page : pageSet) {
PresentationFrame *frame = new PresentationFrame();
frame->page = page;
PresentationFrame *frame = new PresentationFrame(page);
const QList<Okular::Annotation *> annotations = page->annotations();
for (Okular::Annotation *a : annotations) {
if (a->subType() == Okular::Annotation::AMovie) {