Qt: Fix or suppress various recursion warnings
Add MainApplication::maxMenuDepth and use it where needed.
This commit is contained in:
parent
4a7dea6464
commit
90a4925206
@ -29,8 +29,6 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define EXT_MENUBAR_MAX_DEPTH 5
|
||||
|
||||
typedef enum
|
||||
{
|
||||
EXT_MENUBAR_GTK_GUI,
|
||||
|
@ -88,7 +88,8 @@ ph_node_is_proto(proto_node *ptree_node)
|
||||
return proto_registrar_is_protocol(hfinfo->id) && hfinfo->id != pc_proto_id;
|
||||
}
|
||||
|
||||
static void
|
||||
static void
|
||||
// NOLINTNEXTLINE(misc-no-recursion)
|
||||
process_node(proto_node *ptree_node, GNode *parent_stat_node, ph_stats_t *ps)
|
||||
{
|
||||
field_info *finfo;
|
||||
@ -135,6 +136,7 @@ process_node(proto_node *ptree_node, GNode *parent_stat_node, ph_stats_t *ps)
|
||||
}
|
||||
|
||||
if (proto_sibling_node) {
|
||||
// We recurse here but we're limited by proto tree checks
|
||||
process_node(proto_sibling_node, stat_node, ps);
|
||||
} else {
|
||||
stats->num_pkts_last++;
|
||||
|
@ -817,6 +817,7 @@ void BluetoothHciSummaryDialog::on_tableTreeWidget_itemActivated(QTreeWidgetItem
|
||||
}
|
||||
|
||||
|
||||
// NOLINTNEXTLINE(misc-no-recursion)
|
||||
void BluetoothHciSummaryDialog::recursiveCopyTreeItems(QTreeWidgetItem *item, QString ©, int ident_level)
|
||||
{
|
||||
QTreeWidgetItem *child_item;
|
||||
@ -839,6 +840,7 @@ void BluetoothHciSummaryDialog::recursiveCopyTreeItems(QTreeWidgetItem *item, QS
|
||||
.arg(child_item->text(column_number_hardware_error), -15)
|
||||
.arg(child_item->text(column_number_occurrence), -10);
|
||||
|
||||
// We recurse here but the tree is only three levels deep.
|
||||
recursiveCopyTreeItems(child_item, copy, ident_level + 1);
|
||||
}
|
||||
}
|
||||
|
@ -797,6 +797,7 @@ ExtcapArgument::ExtcapArgument(const ExtcapArgument &obj) :
|
||||
}
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(misc-no-recursion)
|
||||
ExtcapValueList ExtcapArgument::loadValues(QString parent)
|
||||
{
|
||||
if (_argument == 0 || _argument->values == 0)
|
||||
@ -824,6 +825,7 @@ ExtcapValueList ExtcapArgument::loadValues(QString parent)
|
||||
v->enabled == true, v->is_default == true);
|
||||
|
||||
if (!call.isEmpty())
|
||||
// We recurse here, but the tree is only two levels deep
|
||||
element.setChildren(this->loadValues(call));
|
||||
|
||||
elements.append(element);
|
||||
|
@ -35,6 +35,7 @@ ExtArgMultiSelect::~ExtArgMultiSelect()
|
||||
delete viewModel;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(misc-no-recursion)
|
||||
QList<QStandardItem *> ExtArgMultiSelect::valueWalker(ExtcapValueList list, QStringList &defaults)
|
||||
{
|
||||
ExtcapValueList::iterator iter = list.begin();
|
||||
@ -58,6 +59,7 @@ QList<QStandardItem *> ExtArgMultiSelect::valueWalker(ExtcapValueList list, QStr
|
||||
|
||||
item->setSelectable(false);
|
||||
item->setEditable(false);
|
||||
// We recurse here, but the tree is only two levels deep
|
||||
QList<QStandardItem *> childs = valueWalker((*iter).children(), defaults);
|
||||
if (childs.length() > 0)
|
||||
item->appendRows(childs);
|
||||
@ -69,6 +71,7 @@ QList<QStandardItem *> ExtArgMultiSelect::valueWalker(ExtcapValueList list, QStr
|
||||
return items;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(misc-no-recursion)
|
||||
void ExtArgMultiSelect::checkItemsWalker(QStandardItem * item, QStringList defaults)
|
||||
{
|
||||
QModelIndex index;
|
||||
@ -80,6 +83,7 @@ void ExtArgMultiSelect::checkItemsWalker(QStandardItem * item, QStringList defau
|
||||
QStandardItem * child = item->child(row);
|
||||
if (child != 0)
|
||||
{
|
||||
// We recurse here, but the tree is only two levels deep
|
||||
checkItemsWalker(child, defaults);
|
||||
}
|
||||
}
|
||||
@ -191,7 +195,7 @@ QString ExtArgMultiSelect::defaultValue()
|
||||
{
|
||||
QStringList checked;
|
||||
|
||||
QList<QStandardItem *> items = valueWalker(values, checked);
|
||||
valueWalker(values, checked);
|
||||
|
||||
return checked.join(QString(','));
|
||||
}
|
||||
|
@ -164,6 +164,8 @@ public:
|
||||
void popStatus(StatusInfo sinfo);
|
||||
|
||||
void gotoFrame(int frameNum);
|
||||
// Maximum nested menu depth.
|
||||
int maxMenuDepth(void) { return 5; }
|
||||
|
||||
private:
|
||||
bool initialized_;
|
||||
|
@ -75,13 +75,6 @@ bool IntegerTablesItem::lessThan(DissectorTablesItem &right) const
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
DissectorTablesModel::DissectorTablesModel(QObject *parent) :
|
||||
QAbstractItemModel(parent),
|
||||
root_(new DissectorTablesItem(QStringLiteral("ROOT"), QStringLiteral("ROOT"), NULL))
|
||||
@ -362,6 +355,7 @@ bool DissectorTablesProxyModel::lessThan(const QModelIndex &left, const QModelIn
|
||||
return false;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(misc-no-recursion)
|
||||
bool DissectorTablesProxyModel::filterAcceptItem(DissectorTablesItem& item) const
|
||||
{
|
||||
if (filter_.isEmpty())
|
||||
@ -374,6 +368,7 @@ bool DissectorTablesProxyModel::filterAcceptItem(DissectorTablesItem& item) cons
|
||||
for (int child_row = 0; child_row < item.childCount(); child_row++)
|
||||
{
|
||||
child_item = item.child(child_row);
|
||||
// We recurse here, but the tree is only three levels deep
|
||||
if ((child_item != NULL) && (filterAcceptItem(*child_item)))
|
||||
return true;
|
||||
}
|
||||
|
@ -479,6 +479,7 @@ void EnabledProtocolsProxyModel::setFilter(const QString& filter, EnabledProtoco
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(misc-no-recursion)
|
||||
void EnabledProtocolsProxyModel::setItemsEnable(EnabledProtocolsProxyModel::EnableType enableType, QModelIndex parent)
|
||||
{
|
||||
if (! sourceModel())
|
||||
@ -510,6 +511,7 @@ void EnabledProtocolsProxyModel::setItemsEnable(EnabledProtocolsProxyModel::Enab
|
||||
}
|
||||
}
|
||||
|
||||
// We recurse here, but the tree is only two levels deep
|
||||
setItemsEnable(enableType, idx);
|
||||
}
|
||||
|
||||
|
@ -621,6 +621,7 @@ int AdvancedPrefsModel::columnCount(const QModelIndex&) const
|
||||
return colLast;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(misc-no-recursion)
|
||||
void AdvancedPrefsModel::setFirstColumnSpanned(QTreeView* tree, const QModelIndex& mIndex)
|
||||
{
|
||||
int childCount, row;
|
||||
@ -630,6 +631,7 @@ void AdvancedPrefsModel::setFirstColumnSpanned(QTreeView* tree, const QModelInde
|
||||
if (item != NULL) {
|
||||
childCount = item->childCount();
|
||||
if (childCount > 0) {
|
||||
// We recurse here, but our depth is limited
|
||||
tree->setFirstColumnSpanned(mIndex.row(), mIndex.parent(), true);
|
||||
for (row = 0; row < childCount; row++) {
|
||||
setFirstColumnSpanned(tree, index(row, 0, mIndex));
|
||||
@ -643,6 +645,7 @@ void AdvancedPrefsModel::setFirstColumnSpanned(QTreeView* tree, const QModelInde
|
||||
}
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(misc-no-recursion)
|
||||
bool AdvancedPrefsModel::filterAcceptItem(PrefsItem& item) const
|
||||
{
|
||||
if (filter_.isEmpty() && !show_changed_values_)
|
||||
@ -680,6 +683,7 @@ bool AdvancedPrefsModel::filterAcceptItem(PrefsItem& item) const
|
||||
for (int child_row = 0; child_row < item.childCount(); child_row++)
|
||||
{
|
||||
child_item = item.child(child_row);
|
||||
// We recurse here, but our depth is limited
|
||||
if ((child_item != NULL) && (filterAcceptItem(*child_item)))
|
||||
return true;
|
||||
}
|
||||
|
@ -751,7 +751,7 @@ QModelIndex ProfileModel::addNewProfile(QString name)
|
||||
QString newName = name;
|
||||
while (findByNameAndVisibility(newName) >= 0)
|
||||
{
|
||||
newName = QStringLiteral("%1 %2").arg(name).arg(QString::number(cnt));
|
||||
newName = QStringLiteral("%1 %2").arg(name, QString::number(cnt));
|
||||
cnt++;
|
||||
}
|
||||
|
||||
@ -761,6 +761,7 @@ QModelIndex ProfileModel::addNewProfile(QString name)
|
||||
return index(findByName(newName), COL_NAME);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(misc-no-recursion)
|
||||
QModelIndex ProfileModel::duplicateEntry(QModelIndex idx, int new_status)
|
||||
{
|
||||
profile_def * prof = guard(idx);
|
||||
@ -779,6 +780,7 @@ QModelIndex ProfileModel::duplicateEntry(QModelIndex idx, int new_status)
|
||||
int row = findByNameAndVisibility(prof->reference, false);
|
||||
profile_def * copyParent = guard(row);
|
||||
if (copyParent && copyParent->status == PROF_STAT_NEW)
|
||||
// We recurse here, but our depth is limited
|
||||
return duplicateEntry(index(row, ProfileModel::COL_NAME), PROF_STAT_NEW);
|
||||
}
|
||||
|
||||
@ -812,13 +814,13 @@ QModelIndex ProfileModel::duplicateEntry(QModelIndex idx, int new_status)
|
||||
if (prof->is_global && findByNameAndVisibility(parentName) < 0)
|
||||
new_name = QString(prof->name);
|
||||
else
|
||||
new_name = QStringLiteral("%1 (%2)").arg(parentName).arg(tr("copy", "noun"));
|
||||
new_name = QStringLiteral("%1 (%2)").arg(parentName, tr("copy", "noun"));
|
||||
|
||||
/* check if copy already exists and iterate, until an unused version is found */
|
||||
int cnt = 1;
|
||||
while (findByNameAndVisibility(new_name) >= 0)
|
||||
{
|
||||
new_name = QStringLiteral("%1 (%2 %3)").arg(parentName).arg(tr("copy", "noun")).arg(QString::number(cnt));
|
||||
new_name = QStringLiteral("%1 (%2 %3)").arg(parentName, tr("copy", "noun"), QString::number(cnt));
|
||||
cnt++;
|
||||
}
|
||||
|
||||
@ -1044,6 +1046,7 @@ QFileInfoList ProfileModel::uniquePaths(QFileInfoList lst)
|
||||
return newLst;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(misc-no-recursion)
|
||||
QFileInfoList ProfileModel::filterProfilePath(QString path, QFileInfoList ent, bool fromZip)
|
||||
{
|
||||
QFileInfoList result = ent;
|
||||
@ -1073,6 +1076,7 @@ QFileInfoList ProfileModel::filterProfilePath(QString path, QFileInfoList ent, b
|
||||
else
|
||||
{
|
||||
if (path.compare(entry.absoluteFilePath()) != 0)
|
||||
// We recurse here, but our depth is limited
|
||||
result.append(filterProfilePath(entry.absoluteFilePath(), result, fromZip));
|
||||
}
|
||||
}
|
||||
@ -1273,7 +1277,7 @@ bool ProfileModel::clearImported(QString *msg)
|
||||
{
|
||||
if (msg)
|
||||
{
|
||||
QString errmsg = QStringLiteral("%1\n\"%2\":\n%3").arg(tr("Can't delete profile directory")).arg(ret_path).arg(g_strerror(errno));
|
||||
QString errmsg = QStringLiteral("%1\n\"%2\":\n%3").arg(tr("Can't delete profile directory"), ret_path, g_strerror(errno));
|
||||
msg->append(errmsg);
|
||||
}
|
||||
|
||||
|
@ -340,6 +340,7 @@ void FilterExpressionToolBar::closeMenu(QAction * /*sender*/)
|
||||
}
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(misc-no-recursion)
|
||||
QMenu * FilterExpressionToolBar::findParentMenu(const QStringList tree, void *fed_data, QMenu *parent )
|
||||
{
|
||||
if (!fed_data)
|
||||
@ -357,6 +358,7 @@ QMenu * FilterExpressionToolBar::findParentMenu(const QStringList tree, void *fe
|
||||
foreach(QAction * entry, data->toolbar->actions())
|
||||
{
|
||||
if (entry->text().compare(tree.at(0).trimmed()) == 0)
|
||||
// We recurse here, but we're limited to mainApp->maxMenuDepth
|
||||
return findParentMenu(tree.mid(1), fed_data, entry->menu());
|
||||
}
|
||||
}
|
||||
@ -366,8 +368,10 @@ QMenu * FilterExpressionToolBar::findParentMenu(const QStringList tree, void *fe
|
||||
/* Iterate to see if we next have to jump into another submenu */
|
||||
foreach(QAction *entry, parent->actions())
|
||||
{
|
||||
if (entry->menu() && entry->text().compare(menuName) == 0)
|
||||
if (entry->menu() && entry->text().compare(menuName) == 0) {
|
||||
// We recurse here, but we're limited to mainApp->maxMenuDepth
|
||||
return findParentMenu(tree.mid(1), fed_data, entry->menu());
|
||||
}
|
||||
}
|
||||
|
||||
/* Submenu not found, creating */
|
||||
@ -375,6 +379,7 @@ QMenu * FilterExpressionToolBar::findParentMenu(const QStringList tree, void *fe
|
||||
subMenu->installEventFilter(data->toolbar);
|
||||
subMenu->setProperty(dfe_menu_, QVariant::fromValue(true));
|
||||
parent->addMenu(subMenu);
|
||||
// We recurse here, but we're limited to mainApp->maxMenuDepth
|
||||
return findParentMenu(tree.mid(1), fed_data, subMenu);
|
||||
}
|
||||
|
||||
@ -395,6 +400,7 @@ QMenu * FilterExpressionToolBar::findParentMenu(const QStringList tree, void *fe
|
||||
if (menuButton != nullptr) {
|
||||
menuButton->setPopupMode(QToolButton::InstantPopup);
|
||||
}
|
||||
// We recurse here, but we're limited to mainApp->maxMenuDepth
|
||||
return findParentMenu(tree.mid(1), fed_data, parentMenu);
|
||||
}
|
||||
else if (parent)
|
||||
@ -414,17 +420,29 @@ bool FilterExpressionToolBar::filter_expression_add_action(const void *key _U_,
|
||||
QString label = QString(fe->label);
|
||||
|
||||
/* Search for parent menu and create if not found */
|
||||
QStringList tree = label.split(PARENT_SEPARATOR);
|
||||
if (!tree.isEmpty())
|
||||
QStringList full_tree = label.split(PARENT_SEPARATOR);
|
||||
QStringList tree = full_tree.mid(0, mainApp->maxMenuDepth());
|
||||
QString remaining_label = full_tree.mid(mainApp->maxMenuDepth()).join(" / ");
|
||||
|
||||
if (!remaining_label.isEmpty()) {
|
||||
tree << remaining_label;
|
||||
}
|
||||
if (!tree.isEmpty()) {
|
||||
tree.removeLast();
|
||||
}
|
||||
QMenu * parentMenu = findParentMenu(tree, data);
|
||||
if (parentMenu)
|
||||
label = label.mid(label.lastIndexOf(PARENT_SEPARATOR) + QString(PARENT_SEPARATOR).length()).trimmed();
|
||||
if (parentMenu) {
|
||||
if (!remaining_label.isEmpty()) {
|
||||
label = remaining_label;
|
||||
} else {
|
||||
label = label.mid(label.lastIndexOf(PARENT_SEPARATOR) + QString(PARENT_SEPARATOR).length()).trimmed();
|
||||
}
|
||||
}
|
||||
|
||||
QAction *dfb_action = new QAction(label, data->toolbar);
|
||||
if (strlen(fe->comment) > 0)
|
||||
{
|
||||
QString tooltip = QStringLiteral("%1\n%2").arg(fe->comment).arg(fe->expression);
|
||||
QString tooltip = QStringLiteral("%1\n%2").arg(fe->comment, fe->expression);
|
||||
dfb_action->setToolTip(tooltip);
|
||||
dfb_action->setProperty(dfe_property_comment_, tooltip);
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ void PrefModuleTreeView::setPane(const QString module_name)
|
||||
setCurrentIndex(newIndex);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(misc-no-recursion)
|
||||
QModelIndex PrefModuleTreeView::findModule(QModelIndex& parent, const QString& name)
|
||||
{
|
||||
QModelIndex findIndex, modelIndex;
|
||||
@ -76,6 +77,7 @@ QModelIndex PrefModuleTreeView::findModule(QModelIndex& parent, const QString& n
|
||||
break;
|
||||
}
|
||||
if (model()->rowCount(modelIndex) > 0) {
|
||||
// We recurse here, but our depth is limited
|
||||
findIndex = findModule(modelIndex, name);
|
||||
if (findIndex.isValid())
|
||||
break;
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
#include "qcustomplot.h"
|
||||
|
||||
// QCustomPlot uses recursion quite a bit, but depths are limted.
|
||||
// NOLINTBEGIN(misc-no-recursion)
|
||||
|
||||
/* including file 'src/vector2d.cpp' */
|
||||
/* modified 2022-11-06T12:45:56, size 7973 */
|
||||
@ -35538,4 +35540,5 @@ QVector<QPointF> QCPPolarGraph::dataToLines(const QVector<QCPGraphData> &data) c
|
||||
}
|
||||
/* end of 'src/polar/polargraph.cpp' */
|
||||
|
||||
// NOLINTEND(misc-no-recursion)
|
||||
|
||||
|
@ -199,7 +199,6 @@ void TrafficTab::disableTap()
|
||||
void TrafficTab::setOpenTabs(QList<int> protocols)
|
||||
{
|
||||
QList<int> tabs = _tabs.keys();
|
||||
QList<int> remove;
|
||||
blockSignals(true);
|
||||
|
||||
foreach(int protocol, protocols)
|
||||
@ -496,8 +495,7 @@ TrafficTab::writeGeoIPMapFile(QFile * fp, bool json_only, TrafficDataFilterProxy
|
||||
|
||||
if (!ipmap.open(QIODevice::ReadOnly)) {
|
||||
QMessageBox::warning(this, tr("Map file error"), tr("Could not open base file %1 for reading: %2")
|
||||
.arg(get_datafile_path("ipmap.html"))
|
||||
.arg(g_strerror(errno))
|
||||
.arg(get_datafile_path("ipmap.html"), g_strerror(errno))
|
||||
);
|
||||
return false;
|
||||
}
|
||||
@ -646,7 +644,7 @@ void TrafficTab::attachTab(QWidget * content, QString name)
|
||||
{
|
||||
ATapDataModel * model = dataModelForWidget(content);
|
||||
if (!model) {
|
||||
attachTab(content, name);
|
||||
DetachableTabWidget::attachTab(content, name);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2847,7 +2847,7 @@ void WiresharkMainWindow::externalMenuHelper(ext_menu_t * menu, QMenu * subMenu
|
||||
Q_ASSERT(subMenu != NULL);
|
||||
|
||||
/* If the depth counter exceeds, something must have gone wrong */
|
||||
Q_ASSERT(depth < EXT_MENUBAR_MAX_DEPTH);
|
||||
Q_ASSERT(depth < mainApp->maxMenuDepth());
|
||||
|
||||
children = menu->children;
|
||||
/* Iterate the child entries */
|
||||
|
@ -2610,7 +2610,7 @@ void StratosharkMainWindow::externalMenuHelper(ext_menu_t * menu, QMenu * subMe
|
||||
Q_ASSERT(subMenu != NULL);
|
||||
|
||||
/* If the depth counter exceeds, something must have gone wrong */
|
||||
Q_ASSERT(depth < EXT_MENUBAR_MAX_DEPTH);
|
||||
Q_ASSERT(depth < mainApp->maxMenuDepth());
|
||||
|
||||
children = menu->children;
|
||||
/* Iterate the child entries */
|
||||
|
Loading…
x
Reference in New Issue
Block a user