mirror of
https://github.com/Mudlet/Mudlet
synced 2026-08-13 18:26:27 -04:00
#### Brief overview of PR changes/additions Clears five open CodeQL "warning"-level alerts in `src/`, each with a minimal, behavior-preserving fix: - **`src/TMap.cpp`** (`cpp/catch-by-value`): the A* search catches the `found_goal` sentinel by value. `found_goal` (in `src/TAstar.h`) is an empty struct thrown by the goal visitor purely as a control-flow signal, and the handler never touches the caught object, so it is now caught as `const found_goal&`. - **`src/exitstreewidget.h`** (`cpp/integer-used-for-enum`, two alerts): the special-exit column indices were `static const int` constants, so the two `switch` statements in `dlgRoomExits::slot_editSpecialExit()` dispatched an `int` over const-int case labels. They are now an unscoped `enum ExitsTreeColumn : int` with identical values (0-8). Unscoped keeps the implicit `int` conversions, so every `ExitsTreeWidget::colIndex_*` call site (all passed to Qt column-index `int` parameters) is unchanged. - **`src/TMatchState.h`** (`cpp/rule-of-two`): the class had a user-defined copy constructor but only an implicit copy assignment. Added an explicit `= default` copy assignment. The defaulted assignment reproduces the previous implicit one exactly (full member-wise copy); the existing, deliberately partial copy constructor is untouched. - **`src/TConsole.h`** (`cpp/rule-of-two`): `TFontAttributes` had a `= default` copy assignment but only an implicit copy constructor. Added an explicit `= default` copy constructor. Move operations were already suppressed by the existing user-declared copy assignment, so nothing about copy/move behavior changes. #### Motivation for adding to Mudlet Reduces the open CodeQL alert backlog with small, low-risk hygiene fixes that also make the affected types' intent clearer (explicit special members, a named column enum) without altering any runtime behavior. #### Other info (issues closed, discussion etc) CodeQL alerts cleared: - `cpp/catch-by-value` - `src/TMap.cpp` (alert #140) - `cpp/integer-used-for-enum` - `src/dlgRoomExits.cpp` switch at ~318 (alert #1070) - `cpp/integer-used-for-enum` - `src/dlgRoomExits.cpp` switch at ~399 (alert #1071) - `cpp/rule-of-two` - `src/TMatchState.h` (alert #185) - `cpp/rule-of-two` - `src/TConsole.h` / `TFontAttributes` (alert #2148) Each fix is behavior-preserving. Verified with a full Ninja build (Qt 6.12.0, ASan) and the adjacent functional tests: `MapRoundTripTest`, `TAreaZLevelIndexTest`, `TAreaGridIndexTest`, `TriggerSameLineMatchTest`, `TFeedTriggersRecursionTest`, `ColorTriggerFilterChildTest`, `EnableDisableByNameTest`, `MainConsoleSelectionTest` - all pass.
61 lines
2.7 KiB
C++
61 lines
2.7 KiB
C++
#ifndef MUDLET_EXITSTREEWIDGET_H
|
|
#define MUDLET_EXITSTREEWIDGET_H
|
|
|
|
/***************************************************************************
|
|
* Copyright (C) 2012 by Vadim Peretokin - vperetokin@gmail.com *
|
|
* Copyright (C) 2014 by Ahmed Charles - acharles@outlook.com *
|
|
* Copyright (C) 2021-2022 by Stephen Lyons - slysven@virginmedia.com *
|
|
* *
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
* (at your option) any later version. *
|
|
* *
|
|
* This program is distributed in the hope that it will be useful, *
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
* GNU General Public License for more details. *
|
|
* *
|
|
* You should have received a copy of the GNU General Public License *
|
|
* along with this program; if not, write to the *
|
|
* Free Software Foundation, Inc., *
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
***************************************************************************/
|
|
|
|
|
|
#include <QTreeWidget>
|
|
|
|
|
|
class ExitsTreeWidget : public QTreeWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
friend class RoomIdLineEditDelegate;
|
|
friend class dlgRoomExits;
|
|
|
|
// The indexes that are used to identify the columns in the special exits
|
|
// treewidget have been collected into an enumeration so that we can
|
|
// tweak them and change all of them correctly - and by making the
|
|
// dlgRoomExits class a friend that can use the same set as defined here.
|
|
// Note that if any of these numbers are modified/extended the
|
|
// corresponding headings in the ./src/ui/room_exits.ui file will need
|
|
// to be adjusted as well - and visa versa:
|
|
enum ExitsTreeColumn : int {
|
|
colIndex_exitRoomId = 0,
|
|
colIndex_exitStatus = 1,
|
|
colIndex_lockExit = 2,
|
|
colIndex_exitWeight = 3,
|
|
colIndex_doorNone = 4,
|
|
colIndex_doorOpen = 5,
|
|
colIndex_doorClosed = 6,
|
|
colIndex_doorLocked = 7,
|
|
colIndex_command = 8,
|
|
};
|
|
|
|
public:
|
|
Q_DISABLE_COPY(ExitsTreeWidget)
|
|
explicit ExitsTreeWidget(QWidget* pParent);
|
|
void keyPressEvent(QKeyEvent* event) override;
|
|
};
|
|
|
|
#endif // MUDLET_EXITSTREEWIDGET_H
|