Skip to content

Commit b714a13

Browse files
committed
plugin-desktopswitch: Don't use DesktopSwitchButton::LabelType invalid value
Stops undefined behavior. Reference: enum foo { a = 0, b = UINT_MAX }; // range: [0, UINT_MAX] foo x = foo(-1); // undefined behavior since CWG 1766, // even if foo's underlying type is unsigned int
1 parent 468242a commit b714a13

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

plugin-desktopswitch/desktopswitch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ DesktopSwitch::DesktopSwitch(const ILXQtPanelPluginStartupInfo &startupInfo) :
5858
mRows(-1),
5959
mShowOnlyActive(false),
6060
mDesktops(nullptr),
61-
mLabelType(static_cast<DesktopSwitchButton::LabelType>(-1))
61+
mLabelType(DesktopSwitchButton::LABEL_TYPE_INVALID)
6262
{
6363
auto *x11Application = qGuiApp->nativeInterface<QNativeInterface::QX11Application>();
6464
Q_ASSERT_X(x11Application, "DesktopSwitch", "Expected X11 connection");

plugin-desktopswitch/desktopswitchbutton.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class DesktopSwitchButton : public QToolButton
4343

4444
public:
4545
enum LabelType { // Must match with combobox indexes
46+
LABEL_TYPE_INVALID = -1,
4647
LABEL_TYPE_NUMBER = 0,
4748
LABEL_TYPE_NAME = 1,
4849
LABEL_TYPE_NONE = 2

0 commit comments

Comments
 (0)