From 36e830fe935e46f0e8b41d2b037efefd561a5660 Mon Sep 17 00:00:00 2001 From: Jonathan Marten Date: Wed, 9 Nov 2022 18:31:09 +0000 Subject: [PATCH 1/5] Eliminate many "declaration shadows a member" warnings src/common.h: In constructor 'BaseEvent::BaseEvent(SCRef, int)': src/common.h:448: warning: declaration of 'd' shadows a member of 'BaseEvent' /usr/include/qt5/QtCore/qcoreevent.h:313: note: shadowed declaration is here src/common.h: In constructor 'MessageEvent::MessageEvent(SCRef)': src/common.h:455: warning: declaration of 'd' shadows a member of 'MessageEvent' src/common.h:457: note: in expansion of macro 'DEF_EVENT' --- src/common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common.h b/src/common.h index c01c538..04704a3 100644 --- a/src/common.h +++ b/src/common.h @@ -445,14 +445,14 @@ typedef QHash AnnotateHistory; class BaseEvent: public QEvent { public: - BaseEvent(SCRef d, int id) : QEvent((QEvent::Type)id), payLoad(d) {} + BaseEvent(SCRef ref, int id) : QEvent((QEvent::Type)id), payLoad(ref) {} const QString myData() const { return payLoad; } private: const QString payLoad; // passed by copy }; #define DEF_EVENT(X, T) class X : public BaseEvent { public: \ - explicit X (SCRef d) : BaseEvent(d, T) {} } + explicit X (SCRef ref) : BaseEvent(ref, T) {} } DEF_EVENT(MessageEvent, QGit::MSG_EV); DEF_EVENT(AnnotateProgressEvent, QGit::ANN_PRG_EV); From 5087d407a86b7b48ca867821e88dd39b56a22418 Mon Sep 17 00:00:00 2001 From: Jonathan Marten Date: Wed, 9 Nov 2022 18:55:12 +0000 Subject: [PATCH 2/5] Eliminate "use of old-style cast" warnings --- src/FileHistory.cc | 2 +- src/cache.cpp | 10 +++++----- src/common.cpp | 12 ++++++------ src/common.h | 10 +++++----- src/dataloader.cpp | 2 +- src/domain.cpp | 10 ++++++---- src/domain.h | 4 ++-- src/git.cpp | 10 +++++----- src/lanes.cpp | 2 +- src/listview.cpp | 2 +- src/mainimpl.cpp | 4 ++-- src/treeview.cpp | 4 ++-- 12 files changed, 37 insertions(+), 35 deletions(-) diff --git a/src/FileHistory.cc b/src/FileHistory.cc index 77ed4b0..0dade16 100644 --- a/src/FileHistory.cc +++ b/src/FileHistory.cc @@ -204,7 +204,7 @@ QModelIndex FileHistory::index(int row, int column, const QModelIndex&) const { if (row < 0 || row >= rowCnt) return QModelIndex(); - return createIndex(row, column, (void*)0); + return createIndex(row, column, nullptr); } QModelIndex FileHistory::parent(const QModelIndex&) const { diff --git a/src/cache.cpp b/src/cache.cpp index 33d4129..f1ba350 100644 --- a/src/cache.cpp +++ b/src/cache.cpp @@ -38,14 +38,14 @@ bool Cache::save(const QString& gitDir, const RevFileMap& rf, QDataStream stream(&data, QIODevice::WriteOnly); // Write a header with a "magic number" and a version - stream << (quint32)C_MAGIC; - stream << (qint32)C_VERSION; + stream << static_cast(C_MAGIC); + stream << static_cast(C_VERSION); - stream << (qint32)dirs.count(); + stream << static_cast(dirs.count()); for (int i = 0; i < dirs.count(); ++i) stream << dirs.at(i); - stream << (qint32)files.count(); + stream << static_cast(files.count()); for (int i = 0; i < files.count(); ++i) stream << files.at(i); @@ -83,7 +83,7 @@ bool Cache::save(const QString& gitDir, const RevFileMap& rf, } } buf.resize(newSize); - stream << (qint32)newSize; + stream << static_cast(newSize); stream << buf; for (int i = 0; i < v.size(); ++i) diff --git a/src/common.cpp b/src/common.cpp index a13fc2a..876726e 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -217,19 +217,19 @@ const RevFile& RevFile::operator>>(QDataStream& stream) const { // skip common case of only modified files bool isEmpty = onlyModified; - stream << (quint32)isEmpty; + stream << static_cast(isEmpty); if (!isEmpty) stream << status; // skip common case of just one parent isEmpty = (mergeParent.isEmpty() || mergeParent.last() == 1); - stream << (quint32)isEmpty; + stream << static_cast(isEmpty); if (!isEmpty) stream << mergeParent; // skip common case of no rename/copies isEmpty = extStatus.isEmpty(); - stream << (quint32)isEmpty; + stream << static_cast(isEmpty); if (!isEmpty) stream << extStatus; @@ -247,17 +247,17 @@ RevFile& RevFile::operator<<(QDataStream& stream) { quint32 tmp; stream >> tmp; - onlyModified = (bool)tmp; + onlyModified = static_cast(tmp); if (!onlyModified) stream >> status; stream >> tmp; - isEmpty = (bool)tmp; + isEmpty = static_cast(tmp); if (!isEmpty) stream >> mergeParent; stream >> tmp; - isEmpty = (bool)tmp; + isEmpty = static_cast(tmp); if (!isEmpty) stream >> extStatus; diff --git a/src/common.h b/src/common.h index 04704a3..511ab35 100644 --- a/src/common.h +++ b/src/common.h @@ -34,7 +34,7 @@ template inline const QString _valueOf(const T& x) { return QVariant(x).toString(); } template<> inline const QString _valueOf(const QStringList& x) { return x.join(" "); } inline const QString& _valueOf(const QString& x) { return x; } -inline const QString _valueOf(size_t x) { return QString::number((uint)x); } +inline const QString _valueOf(size_t x) { return QString::number(static_cast(x)); } // some debug macros #define constlatin(x) (_valueOf(x).toLatin1().constData()) @@ -403,15 +403,15 @@ class RevFile { */ QByteArray pathsIdx; - int dirAt(uint idx) const { return ((const int*)pathsIdx.constData())[idx]; } - int nameAt(uint idx) const { return ((const int*)pathsIdx.constData())[count() + idx]; } + int dirAt(uint idx) const { return reinterpret_cast(pathsIdx.constData())[idx]; } + int nameAt(uint idx) const { return reinterpret_cast(pathsIdx.constData())[count() + idx]; } QVector mergeParent; // helper functions int count() const { - return pathsIdx.size() / ((int)sizeof(int) * 2); + return pathsIdx.size() / (sizeof(int) * 2); } bool statusCmp(int idx, StatusFlag sf) const { @@ -445,7 +445,7 @@ typedef QHash AnnotateHistory; class BaseEvent: public QEvent { public: - BaseEvent(SCRef ref, int id) : QEvent((QEvent::Type)id), payLoad(ref) {} + BaseEvent(SCRef ref, int id) : QEvent(static_cast(id)), payLoad(ref) {} const QString myData() const { return payLoad; } private: const QString payLoad; // passed by copy diff --git a/src/dataloader.cpp b/src/dataloader.cpp index 48f5ea2..27083bf 100644 --- a/src/dataloader.cpp +++ b/src/dataloader.cpp @@ -168,7 +168,7 @@ void DataLoader::addSplittedChunks(const QByteArray* hc) { } // do not assume we have only one chunk in hc int ofs = 0; - while (ofs != -1 && ofs != (int)hc->size()) + while (ofs != -1 && ofs != static_cast(hc->size())) ofs = git->addChunk(fh, *hc, ofs); } diff --git a/src/domain.cpp b/src/domain.cpp index 74cba4d..2c385ae 100644 --- a/src/domain.cpp +++ b/src/domain.cpp @@ -217,13 +217,13 @@ bool Domain::event(QEvent* e) { fromMaster = true; // fall through case UPD_DM_EV: - update(fromMaster, ((UpdateDomainEvent*)e)->isForced()); + update(fromMaster, static_cast(e)->isForced()); break; case MSG_EV: if (!busy && !st.requestPending()) - QApplication::postEvent(m(), new MessageEvent(((MessageEvent*)e)->myData())); + QApplication::postEvent(m(), new MessageEvent(static_cast(e)->myData())); else // waiting for the end of updating - statusBarRequest = ((MessageEvent*)e)->myData(); + statusBarRequest = static_cast(e)->myData(); break; default: break; @@ -275,7 +275,9 @@ void Domain::update(bool fromMaster, bool force) { busy = false; if (git->curContext() != this) qDebug("ASSERT in Domain::update, context is %p " - "instead of %p", (void*)git->curContext(), (void*)this); + "instead of %p", + static_cast(git->curContext()), + static_cast(this)); git->setCurContext(NULL); git->setThrowOnStop(false); diff --git a/src/domain.h b/src/domain.h index 117b906..565534d 100644 --- a/src/domain.h +++ b/src/domain.h @@ -24,8 +24,8 @@ class MainImpl; class UpdateDomainEvent : public QEvent { public: explicit UpdateDomainEvent(bool fromMaster, bool force = false) - : QEvent(fromMaster ? (QEvent::Type)QGit::UPD_DM_MST_EV - : (QEvent::Type)QGit::UPD_DM_EV), f(force) {} + : QEvent(fromMaster ? static_cast(QGit::UPD_DM_MST_EV) + : static_cast(QGit::UPD_DM_EV)), f(force) {} bool isForced() const { return f; } private: bool f; diff --git a/src/git.cpp b/src/git.cpp index 6a5a44c..6f671fc 100644 --- a/src/git.cpp +++ b/src/git.cpp @@ -1705,7 +1705,7 @@ const QStringList Git::getArgs(bool* quit, bool repoChanged) { } if (!startup || args.isEmpty()) { // need to retrieve args if (testFlag(RANGE_SELECT_F)) { // open range dialog - RangeSelectImpl rs((QWidget*)parent(), &args, repoChanged, this); + RangeSelectImpl rs(qobject_cast(parent()), &args, repoChanged, this); *quit = (rs.exec() == QDialog::Rejected); // modal execution if (*quit) return QStringList(); @@ -2430,7 +2430,7 @@ void Git::on_loaded(FileHistory* fh, ulong byteSize, int loadTime, fh->loadTime += loadTime; ulong kb = byteSize / 1024; - double mbs = (double)byteSize / fh->loadTime / 1000; + double mbs = static_cast(byteSize) / fh->loadTime / 1000; QString tmp; tmp.asprintf("Loaded %i revisions (%li KB), " "time elapsed: %i ms (%.2f MB/s)", @@ -2888,7 +2888,7 @@ void Git::flushFileNames(FileNamesLoader& fl) { b.clear(); b.resize(2 * dirs.size() * static_cast(sizeof(int))); - int* d = (int*)(b.data()); + int* d = reinterpret_cast(b.data()); for (int i = 0; i < dirs.size(); i++) { @@ -2952,7 +2952,7 @@ void Git::updateDescMap(const Rev* r,uint idx, QHash, bool>& d for (int y = 0; y < dvv.count(); y++) { - uint v = (uint)dvv[y]; + uint v = static_cast(dvv[y]); QPair key = qMakePair(idx, v); QPair keyN = qMakePair(v, idx); dm.insert(key, true); @@ -3018,7 +3018,7 @@ void Git::mergeNearTags(bool down, Rev* p, const Rev* r, const QHash key = qMakePair((uint)src2[s2], (uint)src1[s1]); + QPair key = qMakePair(static_cast(src2[s2]), static_cast(src1[s1])); if (!dm.contains(key)) { // could be empty if all tags are independent add = true; // could be an independent path diff --git a/src/lanes.cpp b/src/lanes.cpp index 335822e..0334779 100644 --- a/src/lanes.cpp +++ b/src/lanes.cpp @@ -282,7 +282,7 @@ int Lanes::findType(int type, int pos) { int Lanes::add(int type, const QString& next, int pos) { // first check empty lanes starting from pos - if (pos < (int)typeVec.count()) { + if (pos < static_cast(typeVec.count())) { pos = findType(EMPTY, pos); if (pos != -1) { typeVec[pos] = type; diff --git a/src/listview.cpp b/src/listview.cpp index f5e7204..ab76a73 100644 --- a/src/listview.cpp +++ b/src/listview.cpp @@ -752,7 +752,7 @@ void RefNameIterator::next() case Git::TAG: cur_state = Git::REF; break; default: cur_state = -1; // indicate end } - ref_names = git->getRefNames(sha, (Git::RefType)cur_state); + ref_names = git->getRefNames(sha, static_cast(cur_state)); cur_name = ref_names.begin(); } } diff --git a/src/mainimpl.cpp b/src/mainimpl.cpp index c81097a..d89938a 100644 --- a/src/mainimpl.cpp +++ b/src/mainimpl.cpp @@ -997,11 +997,11 @@ bool MainImpl::event(QEvent* e) { SCRef data = de->myData(); bool ret = true; - switch ((EventType)e->type()) { + switch (static_cast(e->type())) { case ERROR_EV: { QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); EM_PROCESS_EVENTS; - MainExecErrorEvent* me = (MainExecErrorEvent*)e; + MainExecErrorEvent* me = static_cast(e); QString text("An error occurred while executing command:\n\n"); text.append(me->command() + "\n\n" + me->report()); QMessageBox::warning(this, "Error - QGit", text); diff --git a/src/treeview.cpp b/src/treeview.cpp index 5a72de0..bcea327 100644 --- a/src/treeview.cpp +++ b/src/treeview.cpp @@ -66,7 +66,7 @@ void TreeView::setup(Domain* dm, Git* g) { void TreeView::on_currentItemChanged(QTreeWidgetItem* item, QTreeWidgetItem*) { if (item) { - SCRef fn = ((FileItem*)item)->fullName(); + SCRef fn = (static_cast(item))->fullName(); if (!ignoreCurrentChanged && fn != st->fileName()) { st->setFileName(fn); st->setSelectItem(true); @@ -262,7 +262,7 @@ void TreeView::updateTree() { // could be a different subdirectory with the // same name that appears before in tree view // to be sure we need to check the names - SCRef fn = ((FileItem*)*item)->fullName(); + SCRef fn = static_cast(*item)->fullName(); if (st->fileName().startsWith(fn)) { if (dynamic_cast(*item)) { From 5768d521066e7121245e3758127f605692354b79 Mon Sep 17 00:00:00 2001 From: Jonathan Marten Date: Wed, 9 Nov 2022 19:57:07 +0000 Subject: [PATCH 3/5] Eliminate "can be marked override" warnings --- src/FileHistory.h | 16 ++++++++-------- src/commitimpl.h | 4 ++-- src/consoleimpl.h | 2 +- src/customactionimpl.h | 2 +- src/domain.h | 2 +- src/filecontent.cpp | 2 +- src/filecontent.h | 2 +- src/filelist.h | 4 ++-- src/fileview.h | 8 ++++---- src/inputdialog.cpp | 4 ++-- src/listview.h | 22 +++++++++++----------- src/mainimpl.h | 6 +++--- src/patchcontent.h | 2 +- src/patchview.h | 6 +++--- src/revdesc.h | 2 +- src/revsview.h | 4 ++-- src/smartbrowse.h | 6 +++--- 17 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/FileHistory.h b/src/FileHistory.h index 53ff285..311498b 100644 --- a/src/FileHistory.h +++ b/src/FileHistory.h @@ -32,14 +32,14 @@ class FileHistory : public QAbstractItemModel void setEarlyOutputState(bool b = true) { earlyOutputCnt = (b ? earlyOutputCntBase : -1); } void setAnnIdValid(bool b = true) { annIdValid = b; } - virtual QVariant data(const QModelIndex &index, int role) const; - virtual Qt::ItemFlags flags(const QModelIndex& index) const; - virtual QVariant headerData(int s, Qt::Orientation o, int role = Qt::DisplayRole) const; - virtual QModelIndex index(int r, int c, const QModelIndex& par = QModelIndex()) const; - virtual QModelIndex parent(const QModelIndex& index) const; - virtual int rowCount(const QModelIndex& par = QModelIndex()) const; - virtual bool hasChildren(const QModelIndex& par = QModelIndex()) const; - virtual int columnCount(const QModelIndex&) const { return 6; } + virtual QVariant data(const QModelIndex &index, int role) const override; + virtual Qt::ItemFlags flags(const QModelIndex& index) const override; + virtual QVariant headerData(int s, Qt::Orientation o, int role = Qt::DisplayRole) const override; + virtual QModelIndex index(int r, int c, const QModelIndex& par = QModelIndex()) const override; + virtual QModelIndex parent(const QModelIndex& index) const override; + virtual int rowCount(const QModelIndex& par = QModelIndex()) const override; + virtual bool hasChildren(const QModelIndex& par = QModelIndex()) const override; + virtual int columnCount(const QModelIndex&) const override { return 6; } public slots: void on_changeFont(const QFont&); diff --git a/src/commitimpl.h b/src/commitimpl.h index 266fce1..19a7e23 100644 --- a/src/commitimpl.h +++ b/src/commitimpl.h @@ -21,7 +21,7 @@ Q_OBJECT void changesCommitted(bool); public slots: - virtual void closeEvent(QCloseEvent*); + virtual void closeEvent(QCloseEvent*) override; void pushButtonCommit_clicked(); void pushButtonAmend_clicked(); void pushButtonCancel_clicked(); @@ -43,7 +43,7 @@ private slots: bool checkPatchName(QString& patchName); bool checkConfirm(SCRef msg, SCRef patchName, SCList selFiles, bool amend); void computePosition(int &col_pos, int &line_pos); - bool eventFilter(QObject* obj, QEvent* event); + bool eventFilter(QObject* obj, QEvent* event) override; Git* git; QString origMsg; diff --git a/src/consoleimpl.h b/src/consoleimpl.h index 5e83147..4094704 100644 --- a/src/consoleimpl.h +++ b/src/consoleimpl.h @@ -31,7 +31,7 @@ public slots: void procFinished(); protected slots: - virtual void closeEvent(QCloseEvent* ce); + virtual void closeEvent(QCloseEvent* ce) override; void pushButtonTerminate_clicked(); void pushButtonOk_clicked(); diff --git a/src/customactionimpl.h b/src/customactionimpl.h index 01ceadc..abea21e 100644 --- a/src/customactionimpl.h +++ b/src/customactionimpl.h @@ -20,7 +20,7 @@ Q_OBJECT void listChanged(const QStringList&); protected slots: - virtual void closeEvent(QCloseEvent*); + virtual void closeEvent(QCloseEvent*) override; void listWidgetNames_currentItemChanged(QListWidgetItem*, QListWidgetItem*); void pushButtonNew_clicked(); void pushButtonRename_clicked(); diff --git a/src/domain.h b/src/domain.h index 565534d..5ebb555 100644 --- a/src/domain.h +++ b/src/domain.h @@ -131,7 +131,7 @@ protected slots: protected: virtual void clear(bool complete = true); - virtual bool event(QEvent* e); + virtual bool event(QEvent* e) override; virtual bool doUpdate(bool force) = 0; void linkDomain(Domain* d); void unlinkDomain(Domain* d); diff --git a/src/filecontent.cpp b/src/filecontent.cpp index 354e18b..7a70888 100644 --- a/src/filecontent.cpp +++ b/src/filecontent.cpp @@ -24,7 +24,7 @@ class FileHighlighter : public QSyntaxHighlighter { public: FileHighlighter(FileContent* fc) : QSyntaxHighlighter(fc), f(fc) {} - virtual void highlightBlock(const QString& p) { + virtual void highlightBlock(const QString& p) override { // state is used to count lines, starting from 0 if (currentBlockState() == -1) // only once diff --git a/src/filecontent.h b/src/filecontent.h index 29a7340..3f3f95b 100644 --- a/src/filecontent.h +++ b/src/filecontent.h @@ -56,7 +56,7 @@ public slots: void typeWriterFontChanged(); protected: - virtual void resizeEvent(QResizeEvent* e); + virtual void resizeEvent(QResizeEvent* e) override; private slots: void on_list_doubleClicked(QListWidgetItem*); diff --git a/src/filelist.h b/src/filelist.h index e097cb9..9d1d446 100644 --- a/src/filelist.h +++ b/src/filelist.h @@ -29,8 +29,8 @@ public slots: void on_changeFont(const QFont& f); protected: - virtual void focusInEvent(QFocusEvent*); - virtual void mouseMoveEvent(QMouseEvent*); + virtual void focusInEvent(QFocusEvent*) override; + virtual void mouseMoveEvent(QMouseEvent*) override; bool startDragging(QMouseEvent *e); private slots: diff --git a/src/fileview.h b/src/fileview.h index 3996e3a..9bb9de2 100644 --- a/src/fileview.h +++ b/src/fileview.h @@ -21,7 +21,7 @@ Q_OBJECT FileView() {} FileView(MainImpl* m, Git* git); ~FileView(); - virtual void clear(bool complete = true); + virtual void clear(bool complete = true) override; void append(SCRef data); void historyReady(); void updateHistViewer(SCRef revSha, SCRef fileName, bool fromUpstream = true); @@ -44,9 +44,9 @@ public slots: void on_revIdSelected(int); protected: - virtual bool doUpdate(bool force); - virtual bool isMatch(SCRef sha); - virtual bool eventFilter(QObject *obj, QEvent *e); + virtual bool doUpdate(bool force) override; + virtual bool isMatch(SCRef sha) override; + virtual bool eventFilter(QObject *obj, QEvent *e) override; private: friend class MainImpl; diff --git a/src/inputdialog.cpp b/src/inputdialog.cpp index 5244e46..02cffa2 100644 --- a/src/inputdialog.cpp +++ b/src/inputdialog.cpp @@ -44,8 +44,8 @@ class RefNameValidator : public QValidator { , allowEmpty(allowEmpty) {} - void fixup(QString& input) const; - State validate(QString & input, int & pos) const; + void fixup(QString& input) const override; + State validate(QString & input, int & pos) const override; private: const QRegExp invalid; bool allowEmpty; diff --git a/src/listview.h b/src/listview.h index dc1e06b..7d904cf 100644 --- a/src/listview.h +++ b/src/listview.h @@ -58,19 +58,19 @@ public slots: void on_keyDown(); protected: - virtual void mousePressEvent(QMouseEvent* e); - virtual void mouseMoveEvent(QMouseEvent* e); - virtual void mouseReleaseEvent(QMouseEvent* e); - virtual void dragEnterEvent(QDragEnterEvent* e); - virtual void dragMoveEvent(QDragMoveEvent* e); - virtual void dragLeaveEvent(QDragLeaveEvent* event); - virtual void dropEvent(QDropEvent* e); + virtual void mousePressEvent(QMouseEvent* e) override; + virtual void mouseMoveEvent(QMouseEvent* e) override; + virtual void mouseReleaseEvent(QMouseEvent* e) override; + virtual void dragEnterEvent(QDragEnterEvent* e) override; + virtual void dragMoveEvent(QDragMoveEvent* e) override; + virtual void dragLeaveEvent(QDragLeaveEvent* event) override; + virtual void dropEvent(QDropEvent* e) override; void startDragging(QMouseEvent *e); QPixmap pixmapFromSelection(const QStringList &revs, const QString &ref) const; private slots: void on_customContextMenuRequested(const QPoint&); - virtual void currentChanged(const QModelIndex&, const QModelIndex&); + virtual void currentChanged(const QModelIndex&, const QModelIndex&) override; private: void setupGeometry(); @@ -95,8 +95,8 @@ Q_OBJECT public: ListViewDelegate(Git* git, ListViewProxy* lp, QObject* parent); - virtual void paint(QPainter* p, const QStyleOptionViewItem& o, const QModelIndex &i) const; - virtual QSize sizeHint(const QStyleOptionViewItem& o, const QModelIndex &i) const; + virtual void paint(QPainter* p, const QStyleOptionViewItem& o, const QModelIndex &i) const override; + virtual QSize sizeHint(const QStyleOptionViewItem& o, const QModelIndex &i) const override; int laneWidth() const { return 3 * laneHeight / 4; } void setLaneHeight(int h) { laneHeight = h; } @@ -130,7 +130,7 @@ Q_OBJECT bool isHighlighted(int row) const; protected: - virtual bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const; + virtual bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override; private: bool isMatch(int row) const; diff --git a/src/mainimpl.h b/src/mainimpl.h index 3089a95..693a2e4 100644 --- a/src/mainimpl.h +++ b/src/mainimpl.h @@ -75,7 +75,7 @@ private slots: void shortCutActivated(); protected: - virtual bool event(QEvent* e); + virtual bool event(QEvent* e) override; protected slots: void initWithEventLoopActive(); @@ -134,12 +134,12 @@ protected slots: void ActAbout_activated(); void ActHelp_activated(); void ActMarkDiffToSha_activated(); - void closeEvent(QCloseEvent* ce); + void closeEvent(QCloseEvent* ce) override; private: friend class setRepoDelayed; - virtual bool eventFilter(QObject* obj, QEvent* ev); + virtual bool eventFilter(QObject* obj, QEvent* ev) override; void updateGlobalActions(bool b); void updateRevVariables(SCRef sha); void setupShortcuts(); diff --git a/src/patchcontent.h b/src/patchcontent.h index f9f1912..50f82d6 100644 --- a/src/patchcontent.h +++ b/src/patchcontent.h @@ -21,7 +21,7 @@ class DiffHighlighter : public QSyntaxHighlighter { public: DiffHighlighter(QTextEdit* p) : QSyntaxHighlighter(p), cl(0) {} void setCombinedLength(uint c) { cl = c; } - virtual void highlightBlock(const QString& text); + virtual void highlightBlock(const QString& text) override; private: uint cl; }; diff --git a/src/patchview.h b/src/patchview.h index a25d84d..eec9b93 100644 --- a/src/patchview.h +++ b/src/patchview.h @@ -18,7 +18,7 @@ Q_OBJECT PatchView() {} PatchView(MainImpl* mi, Git* g); ~PatchView(); - void clear(bool complete = true); + void clear(bool complete = true) override; Ui_TabPatch* tab() { return patchTab; } signals: @@ -32,10 +32,10 @@ public slots: void buttonFilterPatch_clicked(); protected slots: - virtual void on_contextMenu(const QString&, int); + virtual void on_contextMenu(const QString&, int) override; protected: - virtual bool doUpdate(bool force); + virtual bool doUpdate(bool force) override; private: void updatePatch(); diff --git a/src/revdesc.h b/src/revdesc.h index 457a09c..8066683 100644 --- a/src/revdesc.h +++ b/src/revdesc.h @@ -17,7 +17,7 @@ Q_OBJECT void setup(Domain* dm) { d = dm; } protected: - virtual void contextMenuEvent(QContextMenuEvent* e); + virtual void contextMenuEvent(QContextMenuEvent* e) override; private slots: void on_anchorClicked(const QUrl& link); diff --git a/src/revsview.h b/src/revsview.h index e7b1fff..a31ee4f 100644 --- a/src/revsview.h +++ b/src/revsview.h @@ -22,7 +22,7 @@ Q_OBJECT public: RevsView(MainImpl* parent, Git* git, bool isMain = false); ~RevsView(); - void clear(bool complete); + void clear(bool complete) override; void viewPatch(bool newTab); void setEnabled(bool b); void setTabLogDiffVisible(bool); @@ -39,7 +39,7 @@ private slots: void on_flagChanged(uint flag); protected: - virtual bool doUpdate(bool force); + virtual bool doUpdate(bool force) override; private: friend class MainImpl; diff --git a/src/smartbrowse.h b/src/smartbrowse.h index 7c76255..5939b6f 100644 --- a/src/smartbrowse.h +++ b/src/smartbrowse.h @@ -15,10 +15,10 @@ class SmartLabel : public QLabel { Q_OBJECT public: SmartLabel(const QString& text, QWidget* par); - void paintEvent(QPaintEvent* event); + void paintEvent(QPaintEvent* event) override; protected: - virtual void contextMenuEvent(QContextMenuEvent* e); + virtual void contextMenuEvent(QContextMenuEvent* e) override; private slots: void switchLinks(); @@ -30,7 +30,7 @@ Q_OBJECT SmartBrowse(RevsView* par); protected: - bool eventFilter(QObject *obj, QEvent *event); + bool eventFilter(QObject *obj, QEvent *event) override; public slots: void updateVisibility(); From 9c9035f2b7b46ac3c5c2e6c3225e4a9a6f03c48d Mon Sep 17 00:00:00 2001 From: Jonathan Marten Date: Wed, 9 Nov 2022 20:25:16 +0000 Subject: [PATCH 4/5] Eliminate more "declaration shadows a member/parameter/previous" warnings --- src/FileHistory.cc | 10 ++++---- src/annotate.cpp | 26 +++++++++---------- src/common.cpp | 8 +++--- src/consoleimpl.cpp | 4 +-- src/customactionimpl.cpp | 3 +-- src/exceptionmanager.cpp | 54 ++++++++++++++++++++-------------------- src/filecontent.cpp | 4 +-- src/git.cpp | 30 +++++++++++----------- src/inputdialog.cpp | 8 +++--- src/lanes.cpp | 14 +++++------ src/listview.cpp | 10 ++++---- src/mainimpl.cpp | 36 ++++++++++++--------------- src/myprocess.cpp | 4 +-- src/patchcontent.cpp | 10 ++++---- 14 files changed, 108 insertions(+), 113 deletions(-) diff --git a/src/FileHistory.cc b/src/FileHistory.cc index 0dade16..2789d85 100644 --- a/src/FileHistory.cc +++ b/src/FileHistory.cc @@ -213,12 +213,12 @@ QModelIndex FileHistory::parent(const QModelIndex&) const { return no_parent; } -const QString FileHistory::timeDiff(unsigned long secs) const { +const QString FileHistory::timeDiff(unsigned long s) const { - ulong days = secs / (3600 * 24); - ulong hours = (secs - days * 3600 * 24) / 3600; - ulong min = (secs - days * 3600 * 24 - hours * 3600) / 60; - ulong sec = secs - days * 3600 * 24 - hours * 3600 - min * 60; + ulong days = s / (3600 * 24); + ulong hours = (s - days * 3600 * 24) / 3600; + ulong min = (s - days * 3600 * 24 - hours * 3600) / 60; + ulong sec = s - days * 3600 * 24 - hours * 3600 - min * 60; QString tmp; if (days > 0) tmp.append(QString::number(days) + "d "); diff --git a/src/annotate.cpp b/src/annotate.cpp index a1758f7..6ccf7ec 100644 --- a/src/annotate.cpp +++ b/src/annotate.cpp @@ -165,10 +165,10 @@ void Annotate::doAnnotate(const ShaString& ss) { int parentNum = 1; while (it != parents.constEnd()) { - FileAnnotation* pa = getFileAnnotation(*it); - const QString& diff(getPatch(sha, parentNum++)); + pa = getFileAnnotation(*it); + const QString& diff2(getPatch(sha, parentNum++)); QStringList tmpAnn; - setAnnotation(diff, "Merge", pa->lines, tmpAnn); + setAnnotation(diff2, "Merge", pa->lines, tmpAnn); // the two annotations must be of the same length if (fa->lines.count() != tmpAnn.count()) { @@ -214,7 +214,7 @@ void Annotate::setInitialAnnotation(SCRef fileSha, FileAnnotation* fa) { fa->lines.append(empty); } -const QString Annotate::setupAuthor(SCRef origAuthor, int annId) { +const QString Annotate::setupAuthor(SCRef origAuthor, int id) { QString tmp(origAuthor.section('<', 0, 0).trimmed()); // strip e-mail address if (tmp.isEmpty()) { // probably only e-mail @@ -232,7 +232,7 @@ const QString Annotate::setupAuthor(SCRef origAuthor, int annId) { tmp.truncate(MAX_AUTHOR_LEN); } - return QString("%1.%2").arg(annId, annNumLen).arg(tmp); + return QString("%1.%2").arg(id, annNumLen).arg(tmp); } void Annotate::unify(SList dst, SCList src) { @@ -786,23 +786,23 @@ const QString Annotate::computeRanges(SCRef sha, int paraFrom, int paraTo, SCRef for ( ; shaIdx >= 0; shaIdx--) { - SCRef sha(histRevOrder[shaIdx]); + SCRef sha2(histRevOrder[shaIdx]); - if (!ranges.contains(sha)) { + if (!ranges.contains(sha2)) { - curRev = git->revLookup(sha, fh); + curRev = git->revLookup(sha2, fh); if (curRev->parentsCount() == 0) { // the start of an independent branch is found in this case // insert an empty range, the whole branch will be ignored. // Merge of outside branches are very rare so this solution // seems enough if we don't want to dive in (useless) complications. - ranges.insert(sha, RangeInfo()); + ranges.insert(sha2, RangeInfo()); continue; } - const QString& diff(getPatch(sha)); + const QString& diff(getPatch(sha2)); if (diff.isEmpty()) { - dbp("ASSERT in rangeFilter 2: diff for %1 not found", sha); + dbp("ASSERT in rangeFilter 2: diff for %1 not found", sha2); return ""; } QString parSha(curRev->parent(0)); @@ -817,9 +817,9 @@ const QString Annotate::computeRanges(SCRef sha, int paraFrom, int paraTo, SCRef } RangeInfo r(ranges[parSha]); updateRange(&r, diff, false); - ranges.insert(sha, r); + ranges.insert(sha2, r); - if (sha == target) // stop now, no need to continue + if (sha2 == target) // stop now, no need to continue return ancestor; } } diff --git a/src/common.cpp b/src/common.cpp index 876726e..8359ae9 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -11,18 +11,18 @@ #include #include "common.h" -const QString Rev::mid(int start, int len) const { +const QString Rev::mid(int from, int len) const { // warning no sanity check is done on arguments const char* data = ba.constData(); - return QString::fromLocal8Bit(data + start, len); + return QString::fromLocal8Bit(data + from, len); } -const QString Rev::midSha(int start, int len) const { +const QString Rev::midSha(int from, int len) const { // warning no sanity check is done on arguments const char* data = ba.constData(); - return QString::fromLatin1(data + start, len); // faster then formAscii + return QString::fromLatin1(data + from, len); // faster then formAscii } const ShaString Rev::parent(int idx) const { diff --git a/src/consoleimpl.cpp b/src/consoleimpl.cpp index 7d1d7ea..1eb298b 100644 --- a/src/consoleimpl.cpp +++ b/src/consoleimpl.cpp @@ -78,10 +78,10 @@ bool ConsoleImpl::start(const QString& cmd) { return !proc.isNull(); } -void ConsoleImpl::procReadyRead(const QByteArray& data) { +void ConsoleImpl::procReadyRead(const QByteArray& read) { QString newParagraph; - if (QGit::stripPartialParaghraps(data, &newParagraph, &inpBuf)) + if (QGit::stripPartialParaghraps(read, &newParagraph, &inpBuf)) // QTextEdit::append() adds a new paragraph, // i.e. inserts a LF if not already present. textEditOutput->append(newParagraph); diff --git a/src/customactionimpl.cpp b/src/customactionimpl.cpp index 447079a..2bdddd6 100644 --- a/src/customactionimpl.cpp +++ b/src/customactionimpl.cpp @@ -42,8 +42,7 @@ void CustomActionImpl::loadAction(const QString& name) { const QString flags(ACT_GROUP_KEY + name + ACT_FLAGS_KEY); checkBoxRefreshAfterAction->setChecked(testFlag(ACT_REFRESH_F, flags)); QSettings set; - const QString& data(set.value(ACT_GROUP_KEY + name + ACT_TEXT_KEY, "").toString()); - textEditAction->setPlainText(data); + textEditAction->setPlainText(set.value(ACT_GROUP_KEY + name + ACT_TEXT_KEY, "").toString()); } void CustomActionImpl::removeAction(const QString& name) { diff --git a/src/exceptionmanager.cpp b/src/exceptionmanager.cpp index 7c830b1..3b62b35 100644 --- a/src/exceptionmanager.cpp +++ b/src/exceptionmanager.cpp @@ -24,9 +24,9 @@ void ExceptionManager::init(int* excp, const QString& desc) { descriptions.append(desc); } -const QString ExceptionManager::desc(int excpId) { +const QString ExceptionManager::desc(int exId) { - return descriptions[excpId]; + return descriptions[exId]; } bool ExceptionManager::isMatch(int value, int excp, const QString& context) { @@ -40,79 +40,79 @@ bool ExceptionManager::isMatch(int value, int excp, const QString& context) { return match; } -void ExceptionManager::add(int excpId, bool verbose) { +void ExceptionManager::add(int exId, bool verbose) { // add a new exception in currentThrowableSet // are prepended so to use a for loop starting // from begin to find the latest. Exceptions are // always added/removed from both totalThrowableSet // and regionThrowableSet - totalThrowableSet.prepend(Exception(excpId, verbose)); - regionThrowableSet.prepend(Exception(excpId, verbose)); + totalThrowableSet.prepend(Exception(exId, verbose)); + regionThrowableSet.prepend(Exception(exId, verbose)); } -void ExceptionManager::remove(int excpId) { +void ExceptionManager::remove(int exId) { // removes ONE exception in totalThrowableSet and ONE in regionThrowableSet. // if add and remove calls are correctly nested the removed // excp should be the first in both throwable sets if (totalThrowableSet.isEmpty() || regionThrowableSet.isEmpty()) { - qDebug("ASSERT in remove: removing %i from an empty set", excpId); + qDebug("ASSERT in remove: removing %i from an empty set", exId); return; } // remove from region. SetIt itReg(regionThrowableSet.begin()); - if ((*itReg).excpId != excpId) { - qDebug("ASSERT in remove: %i is not the first in list", excpId); + if ((*itReg).excpId != exId) { + qDebug("ASSERT in remove: %i is not the first in list", exId); return; } regionThrowableSet.erase(itReg); // remove from total. SetIt itTot(totalThrowableSet.begin()); - if ((*itTot).excpId != excpId) { - qDebug("ASSERT in remove: %i is not the first in list", excpId); + if ((*itTot).excpId != exId) { + qDebug("ASSERT in remove: %i is not the first in list", exId); return; } totalThrowableSet.erase(itTot); } ExceptionManager::SetIt ExceptionManager::findExcp(ThrowableSet& ts, - const SetIt& startIt, int excpId) { + const SetIt& startIt, int exId) { SetIt it(startIt); for ( ; it != ts.end(); ++it) - if ((*it).excpId == excpId) + if ((*it).excpId == exId) break; return it; } -void ExceptionManager::setRaisedFlag(ThrowableSet& ts, int excpId) { +void ExceptionManager::setRaisedFlag(ThrowableSet& ts, int exId) { - SetIt it(findExcp(ts, ts.begin(), excpId)); + SetIt it(findExcp(ts, ts.begin(), exId)); while (it != ts.end()) { (*it).isRaised = true; - it = findExcp(ts, ++it, excpId); + it = findExcp(ts, ++it, exId); } } -void ExceptionManager::raise(int excpId) { +void ExceptionManager::raise(int exId) { if (totalThrowableSet.isEmpty()) return; // check totalThrowableSet to find if excpId is throwable - SetIt it = findExcp(totalThrowableSet, totalThrowableSet.begin(), excpId); + SetIt it = findExcp(totalThrowableSet, totalThrowableSet.begin(), exId); if (it == totalThrowableSet.end()) return; // we have found an exception. Set raised flag in regionThrowableSet - setRaisedFlag(regionThrowableSet, excpId); + setRaisedFlag(regionThrowableSet, exId); // then set the flag in all regions throwableSetList QMap::iterator itList(throwableSetMap.begin()); while (itList != throwableSetMap.end()) { - setRaisedFlag(*itList, excpId); + setRaisedFlag(*itList, exId); ++itList; } } @@ -134,17 +134,17 @@ int ExceptionManager::saveThrowableSet() { return oldCurrentRegionId; } -void ExceptionManager::restoreThrowableSet(int regionId) { +void ExceptionManager::restoreThrowableSet(int regId) { - if (!throwableSetMap.contains(regionId)) { - qDebug("ASSERT in restoreThrowableSet: region %i not found", regionId); + if (!throwableSetMap.contains(regId)) { + qDebug("ASSERT in restoreThrowableSet: region %i not found", regId); return; } - regionThrowableSet = throwableSetMap[regionId]; - throwableSetMap.remove(regionId); + regionThrowableSet = throwableSetMap[regId]; + throwableSetMap.remove(regId); } -bool ExceptionManager::isPending(int excpId) { +bool ExceptionManager::isPending(int exId) { // check in ALL regions if an exception request is pending QMap::const_iterator itList(throwableSetMap.constBegin()); @@ -152,7 +152,7 @@ bool ExceptionManager::isPending(int excpId) { ThrowableSet::const_iterator it((*itList).constBegin()); for ( ; it != (*itList).constEnd(); ++it) - if ((*it).isRaised && (*it).excpId == excpId) + if ((*it).isRaised && (*it).excpId == exId) return true; ++itList; } diff --git a/src/filecontent.cpp b/src/filecontent.cpp index 7a70888..7bb9e95 100644 --- a/src/filecontent.cpp +++ b/src/filecontent.cpp @@ -601,8 +601,8 @@ void FileContent::setAnnList() { QBrush back(Qt::lightGray); QFont f(listWidgetAnn->font()); f.setBold(true); - FOREACH (QVector, it, curIdLines) { - QListWidgetItem* item = listWidgetAnn->item(*it); + FOREACH (QVector, it2, curIdLines) { + QListWidgetItem* item = listWidgetAnn->item(*it2); item->setForeground(fore); item->setBackground(back); item->setFont(f); diff --git a/src/git.cpp b/src/git.cpp index 6f671fc..e799775 100644 --- a/src/git.cpp +++ b/src/git.cpp @@ -630,8 +630,8 @@ const QStringList Git::getChildren(SCRef parent) { // reorder children by loading order QStringList::iterator itC(children.begin()); for ( ; itC != children.end(); ++itC) { - const Rev* r = revLookup(*itC); - (*itC).prepend(QString("%1 ").arg(r->orderIdx, 6)); + const Rev* rev = revLookup(*itC); + (*itC).prepend(QString("%1 ").arg(rev->orderIdx, 6)); } children.sort(); for (itC = children.begin(); itC != children.end(); ++itC) @@ -926,13 +926,13 @@ const QStringList Git::getDescendantBranches(SCRef sha, bool shaOnly) { for (int i = 0; i < nr.count(); i++) { - const ShaString& sha = revData->revOrder[nr[i]]; + const ShaString& sha2 = revData->revOrder[nr[i]]; if (shaOnly) { - tl.append(sha); + tl.append(sha2); continue; } - SCRef cap = " (" + sha + ") "; - RefMap::const_iterator it(refsShaMap.find(sha)); + SCRef cap = " (" + sha2 + ") "; + RefMap::const_iterator it(refsShaMap.find(sha2)); if (it == refsShaMap.constEnd()) continue; @@ -961,9 +961,9 @@ const QStringList Git::getNearTags(bool goDown, SCRef sha) { for (int i = 0; i < nr.count(); i++) { - const ShaString& sha = revData->revOrder[nr[i]]; - SCRef cap = " (" + sha + ")"; - RefMap::const_iterator it(refsShaMap.find(sha)); + const ShaString& sha2 = revData->revOrder[nr[i]]; + SCRef cap = " (" + sha2 + ")"; + RefMap::const_iterator it(refsShaMap.find(sha2)); if (it != refsShaMap.constEnd()) tl.append((*it).tags.join(cap).append(cap)); } @@ -2912,19 +2912,19 @@ void Git::appendFileName(RevFile& rf, SCRef name, FileNamesLoader& fl) { QHash::const_iterator it(dirNamesMap.constFind(dr)); if (it == dirNamesMap.constEnd()) { - int idx = dirNamesVec.count(); - dirNamesMap.insert(dr, idx); + int num = dirNamesVec.count(); + dirNamesMap.insert(dr, num); dirNamesVec.append(dr); - fl.rfDirs.append(idx); + fl.rfDirs.append(num); } else fl.rfDirs.append(*it); it = fileNamesMap.constFind(nm); if (it == fileNamesMap.constEnd()) { - int idx = fileNamesVec.count(); - fileNamesMap.insert(nm, idx); + int num = fileNamesVec.count(); + fileNamesMap.insert(nm, num); fileNamesVec.append(nm); - fl.rfNames.append(idx); + fl.rfNames.append(num); } else fl.rfNames.append(*it); } diff --git a/src/inputdialog.cpp b/src/inputdialog.cpp index 02cffa2..07aedfd 100644 --- a/src/inputdialog.cpp +++ b/src/inputdialog.cpp @@ -38,10 +38,10 @@ QStringList parseStringList(const QString &value, const InputDialog::VariableMap class RefNameValidator : public QValidator { public: - RefNameValidator(bool allowEmpty=false, QObject *parent=0) + RefNameValidator(bool allowEmptyP=false, QObject *parent=0) : QValidator(parent) , invalid("[ ~^:\?*[]") - , allowEmpty(allowEmpty) + , allowEmpty(allowEmptyP) {} void fixup(QString& input) const override; @@ -81,10 +81,10 @@ QValidator::State RefNameValidator::validate(QString &input, int &pos) const } -InputDialog::InputDialog(const QString &cmd, const VariableMap &variables, +InputDialog::InputDialog(const QString &c, const VariableMap &variables, const QString &title, QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) - , cmd(cmd) + , cmd(c) { this->setWindowTitle(title); QGridLayout *layout = new QGridLayout(this); diff --git a/src/lanes.cpp b/src/lanes.cpp index 0334779..ecb1981 100644 --- a/src/lanes.cpp +++ b/src/lanes.cpp @@ -159,16 +159,16 @@ void Lanes::setMerge(const QStringList& parents) { for (int i = rangeStart + 1; i < rangeEnd; i++) { - int& t = typeVec[i]; + int& type = typeVec[i]; - if (t == NOT_ACTIVE) - t = CROSS; + if (type == NOT_ACTIVE) + type = CROSS; - else if (t == EMPTY) - t = CROSS_EMPTY; + else if (type == EMPTY) + type = CROSS_EMPTY; - else if (t == TAIL_R || t == TAIL_L) - t = TAIL; + else if (type == TAIL_R || type == TAIL_L) + type = TAIL; } } diff --git a/src/listview.cpp b/src/listview.cpp index ab76a73..898d367 100644 --- a/src/listview.cpp +++ b/src/listview.cpp @@ -717,8 +717,8 @@ class RefNameIterator { void next(); }; -RefNameIterator::RefNameIterator(const QString &sha, Git *git) - : git(git), sha(sha), cur_state(0), cur_branch(git->getCurrentBranchName()) +RefNameIterator::RefNameIterator(const QString &s, Git *g) + : git(g), sha(s), cur_state(0), cur_branch(git->getCurrentBranchName()) { ref_types = git->checkRef(sha); if (ref_types == 0) { @@ -990,20 +990,20 @@ void ListViewDelegate::paintGraphLane(QPainter* p, int type, int x1, int x2, } void ListViewDelegate::paintGraph(QPainter* p, const QStyleOptionViewItem& opt, - const QModelIndex& i) const { + const QModelIndex& idx) const { static const QColor & baseColor = QPalette().color(QPalette::WindowText); static const QColor colors[COLORS_NUM] = { baseColor, Qt::red, DARK_GREEN, Qt::blue, Qt::darkGray, BROWN, Qt::magenta, ORANGE }; if (opt.state & QStyle::State_Selected) p->fillRect(opt.rect, opt.palette.highlight()); - else if (i.row() & 1) + else if (idx.row() & 1) p->fillRect(opt.rect, opt.palette.alternateBase()); else p->fillRect(opt.rect, opt.palette.base()); FileHistory* fh; - const Rev* r = revLookup(i.row(), &fh); + const Rev* r = revLookup(idx. row(), &fh); if (!r) return; diff --git a/src/mainimpl.cpp b/src/mainimpl.cpp index d89938a..a1b88be 100644 --- a/src/mainimpl.cpp +++ b/src/mainimpl.cpp @@ -994,7 +994,7 @@ bool MainImpl::event(QEvent* e) { if (!de) return QWidget::event(e); - SCRef data = de->myData(); + SCRef d = de->myData(); bool ret = true; switch (static_cast(e->type())) { @@ -1008,14 +1008,14 @@ bool MainImpl::event(QEvent* e) { QApplication::restoreOverrideCursor(); } break; case MSG_EV: - statusBar()->showMessage(data); + statusBar()->showMessage(d); break; case POPUP_LIST_EV: - doContexPopup(data); + doContexPopup(d); break; case POPUP_FILE_EV: case POPUP_TREE_EV: - doFileContexPopup(data, e->type()); + doFileContexPopup(d, e->type()); break; default: dbp("ASSERT in MainImpl::event unhandled event %1", e->type()); @@ -1285,11 +1285,11 @@ void MainImpl::updateCommitMenu(bool isStGITStack) { void MainImpl::updateRecentRepoMenu(SCRef newEntry) { // update menu of all windows - foreach (QWidget* widget, QApplication::topLevelWidgets()) { + foreach (QWidget* w, QApplication::topLevelWidgets()) { - MainImpl* w = dynamic_cast(widget); - if (w) - w->doUpdateRecentRepoMenu(newEntry); + MainImpl* wmi = qobject_cast(w); + if (wmi) + wmi->doUpdateRecentRepoMenu(newEntry); } } @@ -1475,19 +1475,16 @@ void MainImpl::ActSplitView_activated() { Domain* t; switch (currentTabType(&t)) { case TAB_REV: { - RevsView* rv = static_cast(t); - QWidget* w = rv->tab()->fileList; + QWidget* w = static_cast(t)->tab()->fileList; QSplitter* sp = static_cast(w->parent()); sp->setHidden(w->isVisible()); } break; case TAB_PATCH: { - PatchView* pv = static_cast(t); - QWidget* w = pv->tab()->textBrowserDesc; + QWidget* w = static_cast(t)->tab()->textBrowserDesc; w->setHidden(w->isVisible()); } break; case TAB_FILE: { - FileView* fv = static_cast(t); - QWidget* w = fv->tab()->histListView; + QWidget* w = static_cast(t)->tab()->histListView; w->setHidden(w->isVisible()); } break; default: @@ -1500,8 +1497,7 @@ void MainImpl::ActToggleLogsDiff_activated() { Domain* t; if (currentTabType(&t) == TAB_REV) { - RevsView* rv = static_cast(t); - rv->toggleDiffView(); + static_cast(t)->toggleDiffView(); } } @@ -1702,11 +1698,11 @@ void MainImpl::ActCustomActionSetup_activated() { void MainImpl::customActionListChanged(const QStringList& list) { // update menu of all windows - foreach (QWidget* widget, QApplication::topLevelWidgets()) { + foreach (QWidget* w, QApplication::topLevelWidgets()) { - MainImpl* w = dynamic_cast(widget); - if (w) - w->doUpdateCustomActionMenu(list); + MainImpl* wmi = qobject_cast(w); + if (wmi) + wmi->doUpdateCustomActionMenu(list); } } diff --git a/src/myprocess.cpp b/src/myprocess.cpp index e159173..4d9c397 100644 --- a/src/myprocess.cpp +++ b/src/myprocess.cpp @@ -108,9 +108,9 @@ void MyProcess::sendErrorMsg(bool notStarted) { QApplication::postEvent(guiObject, e); } -bool MyProcess::launchMe(SCRef runCmd, SCRef buf) { +bool MyProcess::launchMe(SCRef cmd, SCRef buf) { - arguments = splitArgList(runCmd); + arguments = splitArgList(cmd); if (arguments.isEmpty()) return false; diff --git a/src/patchcontent.cpp b/src/patchcontent.cpp index 831d950..0259b09 100644 --- a/src/patchcontent.cpp +++ b/src/patchcontent.cpp @@ -159,12 +159,12 @@ int PatchContent::topToLineNum() { return cursorForPosition(QPoint(1, 1)).blockNumber(); } -bool PatchContent::centerTarget(SCRef target) { +bool PatchContent::centerTarget(SCRef tgt) { moveCursor(QTextCursor::Start); // find() updates cursor position - if (!find(target, QTextDocument::FindCaseSensitively | QTextDocument::FindWholeWords)) + if (!find(tgt, QTextDocument::FindCaseSensitively | QTextDocument::FindWholeWords)) return false; // move to the beginning of the line @@ -202,11 +202,11 @@ void PatchContent::centerMatch(int id) { // matches[id].paraTo, matches[id].indexTo); } -void PatchContent::procReadyRead(const QByteArray& data) { +void PatchContent::procReadyRead(const QByteArray& read) { - patchRowData.append(data); + patchRowData.append(read); if (document()->isEmpty() && isVisible()) - processData(data); + processData(read); } void PatchContent::typeWriterFontChanged() { From b9d467bbc65bf074d50e89c4aa0fbb7320cc215c Mon Sep 17 00:00:00 2001 From: Jonathan Marten Date: Wed, 9 Nov 2022 20:35:10 +0000 Subject: [PATCH 5/5] Eliminate "implicly-declared (constructor) is deprecated" warning --- src/domain.cpp | 6 ++++++ src/domain.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/domain.cpp b/src/domain.cpp index 2c385ae..0e7fd26 100644 --- a/src/domain.cpp +++ b/src/domain.cpp @@ -59,6 +59,12 @@ StateInfo& StateInfo::operator=(const StateInfo& newState) { return *this; } +StateInfo::StateInfo(const StateInfo& newState) { + + isLocked = false; + curS = newState.curS; // prevS is mot modified to allow a rollback +} + bool StateInfo::operator==(const StateInfo& newState) const { if (&newState == this) diff --git a/src/domain.h b/src/domain.h index 5ebb555..a4b8709 100644 --- a/src/domain.h +++ b/src/domain.h @@ -35,6 +35,7 @@ class StateInfo { public: StateInfo() { clear(); } StateInfo& operator=(const StateInfo& newState); + StateInfo(const StateInfo& newState); bool operator==(const StateInfo& newState) const; bool operator!=(const StateInfo& newState) const; void clear();