mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-29 03:32:48 +00:00
Use C++17 [[fallthrough]] if needed
This commit is contained in:
parent
b01c28c48d
commit
4f2eae6b77
@ -148,5 +148,6 @@ We are using C++17 standard. You can safely use:
|
|||||||
* Use `static constexpr T v = ...;`
|
* Use `static constexpr T v = ...;`
|
||||||
* You can use `<atomic>`, `<thread>`, `<mutex>`, and `<condition_variable>`
|
* You can use `<atomic>`, `<thread>`, `<mutex>`, and `<condition_variable>`
|
||||||
* Prefer `using T = ...;` instead of `typedef ... T`
|
* Prefer `using T = ...;` instead of `typedef ... T`
|
||||||
|
* Use `[[fallthrough]]` if needed
|
||||||
* We use gcc 9.2 or clang 9.0 on Linux, so check the features available in
|
* We use gcc 9.2 or clang 9.0 on Linux, so check the features available in
|
||||||
https://en.cppreference.com/w/cpp/compiler_support
|
https://en.cppreference.com/w/cpp/compiler_support
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Aseprite
|
# Aseprite
|
||||||
# Copyright (C) 2019-2020 Igara Studio S.A.
|
# Copyright (C) 2019-2022 Igara Studio S.A.
|
||||||
# Copyright (C) 2001-2018 David Capello
|
# Copyright (C) 2001-2018 David Capello
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
@ -8,6 +8,9 @@
|
|||||||
if(UNIX)
|
if(UNIX)
|
||||||
# All warnings except for switch cases with missing enum items
|
# All warnings except for switch cases with missing enum items
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-switch")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-switch")
|
||||||
|
|
||||||
|
# Prefer C++17 [[fallthrough]] attribute
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wimplicit-fallthrough")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
|
@ -110,6 +110,7 @@ public:
|
|||||||
|
|
||||||
case ui::kMouseDownMessage:
|
case ui::kMouseDownMessage:
|
||||||
captureMouse();
|
captureMouse();
|
||||||
|
[[fallthrough]];
|
||||||
|
|
||||||
case ui::kMouseMoveMessage:
|
case ui::kMouseMoveMessage:
|
||||||
if (hasCapture()) {
|
if (hasCapture()) {
|
||||||
|
@ -120,7 +120,8 @@ bool ColorCurveEditor::onProcessMessage(Message* msg)
|
|||||||
|
|
||||||
captureMouse();
|
captureMouse();
|
||||||
|
|
||||||
// continue in motion message...
|
// Continue in motion message...
|
||||||
|
[[fallthrough]];
|
||||||
}
|
}
|
||||||
|
|
||||||
case kMouseMoveMessage: {
|
case kMouseMoveMessage: {
|
||||||
|
@ -255,12 +255,14 @@ bool PngFormat::onLoad(FileOp* fop)
|
|||||||
|
|
||||||
case PNG_COLOR_TYPE_RGB_ALPHA:
|
case PNG_COLOR_TYPE_RGB_ALPHA:
|
||||||
fop->sequenceSetHasAlpha(true);
|
fop->sequenceSetHasAlpha(true);
|
||||||
|
[[fallthrough]];
|
||||||
case PNG_COLOR_TYPE_RGB:
|
case PNG_COLOR_TYPE_RGB:
|
||||||
pixelFormat = IMAGE_RGB;
|
pixelFormat = IMAGE_RGB;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
||||||
fop->sequenceSetHasAlpha(true);
|
fop->sequenceSetHasAlpha(true);
|
||||||
|
[[fallthrough]];
|
||||||
case PNG_COLOR_TYPE_GRAY:
|
case PNG_COLOR_TYPE_GRAY:
|
||||||
pixelFormat = IMAGE_GRAYSCALE;
|
pixelFormat = IMAGE_GRAYSCALE;
|
||||||
break;
|
break;
|
||||||
@ -799,6 +801,7 @@ void PngFormat::saveColorSpace(png_structp png_ptr, png_infop info_ptr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Continue to RGB case...
|
// Continue to RGB case...
|
||||||
|
[[fallthrough]];
|
||||||
|
|
||||||
case gfx::ColorSpace::RGB: {
|
case gfx::ColorSpace::RGB: {
|
||||||
if (colorSpace->hasPrimaries()) {
|
if (colorSpace->hasPrimaries()) {
|
||||||
|
@ -417,6 +417,7 @@ private:
|
|||||||
inImage = true;
|
inImage = true;
|
||||||
else if (ev_type == CMARK_EVENT_EXIT)
|
else if (ev_type == CMARK_EVENT_EXIT)
|
||||||
inImage = false;
|
inImage = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case CMARK_NODE_LINK: {
|
case CMARK_NODE_LINK: {
|
||||||
@ -434,6 +435,7 @@ private:
|
|||||||
}
|
}
|
||||||
inLink = nullptr;
|
inLink = nullptr;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -316,8 +316,7 @@ bool ColorSelector::onProcessMessage(ui::Message* msg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
captureMouse();
|
captureMouse();
|
||||||
|
[[fallthrough]];
|
||||||
// Continue...
|
|
||||||
|
|
||||||
case kMouseMoveMessage: {
|
case kMouseMoveMessage: {
|
||||||
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
|
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
|
||||||
|
@ -178,6 +178,7 @@ bool FileList::onProcessMessage(Message* msg)
|
|||||||
|
|
||||||
case kMouseDownMessage:
|
case kMouseDownMessage:
|
||||||
captureMouse();
|
captureMouse();
|
||||||
|
[[fallthrough]];
|
||||||
|
|
||||||
case kMouseMoveMessage:
|
case kMouseMoveMessage:
|
||||||
if (hasCapture()) {
|
if (hasCapture()) {
|
||||||
|
@ -339,8 +339,7 @@ bool PaletteView::onProcessMessage(Message* msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
captureMouse();
|
captureMouse();
|
||||||
|
[[fallthrough]];
|
||||||
// Continue...
|
|
||||||
|
|
||||||
case kMouseMoveMessage: {
|
case kMouseMoveMessage: {
|
||||||
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
|
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
|
||||||
|
@ -245,7 +245,7 @@ bool ToolBar::onProcessMessage(Message* msg)
|
|||||||
m_openedRecently = false;
|
m_openedRecently = false;
|
||||||
|
|
||||||
releaseMouse();
|
releaseMouse();
|
||||||
// fallthrough
|
[[fallthrough]];
|
||||||
|
|
||||||
case kMouseLeaveMessage:
|
case kMouseLeaveMessage:
|
||||||
if (hasCapture())
|
if (hasCapture())
|
||||||
@ -609,7 +609,7 @@ bool ToolBar::ToolStrip::onProcessMessage(Message* msg)
|
|||||||
|
|
||||||
case kMouseDownMessage:
|
case kMouseDownMessage:
|
||||||
captureMouse();
|
captureMouse();
|
||||||
// fallthrough
|
[[fallthrough]];
|
||||||
|
|
||||||
case kMouseMoveMessage: {
|
case kMouseMoveMessage: {
|
||||||
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
|
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
|
||||||
|
@ -50,6 +50,7 @@ frame_t calculate_next_frame(
|
|||||||
|
|
||||||
case AniDir::REVERSE:
|
case AniDir::REVERSE:
|
||||||
frameDelta = -frameDelta;
|
frameDelta = -frameDelta;
|
||||||
|
[[fallthrough]];
|
||||||
|
|
||||||
case AniDir::FORWARD:
|
case AniDir::FORWARD:
|
||||||
frame += frameDelta;
|
frame += frameDelta;
|
||||||
|
@ -395,6 +395,8 @@ bool Entry::onProcessMessage(Message* msg)
|
|||||||
if (!m_selecting_words.isEmpty())
|
if (!m_selecting_words.isEmpty())
|
||||||
m_selecting_words.reset();
|
m_selecting_words.reset();
|
||||||
|
|
||||||
|
[[fallthrough]];
|
||||||
|
|
||||||
case kMouseMoveMessage:
|
case kMouseMoveMessage:
|
||||||
if (hasCapture()) {
|
if (hasCapture()) {
|
||||||
bool is_dirty = false;
|
bool is_dirty = false;
|
||||||
|
@ -206,6 +206,7 @@ bool ListBox::onProcessMessage(Message* msg)
|
|||||||
|
|
||||||
case kMouseDownMessage:
|
case kMouseDownMessage:
|
||||||
captureMouse();
|
captureMouse();
|
||||||
|
[[fallthrough]];
|
||||||
|
|
||||||
case kMouseMoveMessage:
|
case kMouseMoveMessage:
|
||||||
if (hasCapture()) {
|
if (hasCapture()) {
|
||||||
|
@ -1858,11 +1858,10 @@ bool Manager::processFocusMovementMessage(Message* msg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
// Arrow keys
|
// Arrow keys
|
||||||
case kKeyLeft: if (!cmp) cmp = cmp_left;
|
case kKeyLeft: if (!cmp) cmp = cmp_left; [[fallthrough]];
|
||||||
case kKeyRight: if (!cmp) cmp = cmp_right;
|
case kKeyRight: if (!cmp) cmp = cmp_right; [[fallthrough]];
|
||||||
case kKeyUp: if (!cmp) cmp = cmp_up;
|
case kKeyUp: if (!cmp) cmp = cmp_up; [[fallthrough]];
|
||||||
case kKeyDown: if (!cmp) cmp = cmp_down;
|
case kKeyDown: if (!cmp) cmp = cmp_down;
|
||||||
|
|
||||||
// More than one widget
|
// More than one widget
|
||||||
if (count > 1) {
|
if (count > 1) {
|
||||||
// Position where the focus come
|
// Position where the focus come
|
||||||
|
@ -443,7 +443,7 @@ bool MenuBox::onProcessMessage(Message* msg)
|
|||||||
if (!base->was_clicked)
|
if (!base->was_clicked)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//[[fallthrough]];
|
[[fallthrough]];
|
||||||
}
|
}
|
||||||
|
|
||||||
case kMouseDownMessage:
|
case kMouseDownMessage:
|
||||||
|
@ -132,7 +132,8 @@ bool ScrollBar::onProcessMessage(Message* msg)
|
|||||||
setSelected(true);
|
setSelected(true);
|
||||||
captureMouse();
|
captureMouse();
|
||||||
|
|
||||||
// continue to kMouseMoveMessage handler...
|
// Continue to kMouseMoveMessage handler...
|
||||||
|
[[fallthrough]];
|
||||||
}
|
}
|
||||||
|
|
||||||
case kMouseMoveMessage:
|
case kMouseMoveMessage:
|
||||||
|
@ -115,7 +115,7 @@ bool Slider::onProcessMessage(Message* msg)
|
|||||||
|
|
||||||
setupSliderCursor();
|
setupSliderCursor();
|
||||||
|
|
||||||
// Fall through
|
[[fallthrough]];
|
||||||
|
|
||||||
case kMouseMoveMessage:
|
case kMouseMoveMessage:
|
||||||
if (hasCapture()) {
|
if (hasCapture()) {
|
||||||
|
@ -100,6 +100,7 @@ bool Splitter::onProcessMessage(Message* msg)
|
|||||||
captureMouse();
|
captureMouse();
|
||||||
|
|
||||||
// Continue with motion message...
|
// Continue with motion message...
|
||||||
|
[[fallthrough]];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user