mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-16 04:13:50 +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 = ...;`
|
||||
* You can use `<atomic>`, `<thread>`, `<mutex>`, and `<condition_variable>`
|
||||
* 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
|
||||
https://en.cppreference.com/w/cpp/compiler_support
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Aseprite
|
||||
# Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
# Copyright (C) 2019-2022 Igara Studio S.A.
|
||||
# Copyright (C) 2001-2018 David Capello
|
||||
|
||||
######################################################################
|
||||
@ -8,6 +8,9 @@
|
||||
if(UNIX)
|
||||
# All warnings except for switch cases with missing enum items
|
||||
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()
|
||||
|
||||
if(MSVC)
|
||||
|
@ -110,6 +110,7 @@ public:
|
||||
|
||||
case ui::kMouseDownMessage:
|
||||
captureMouse();
|
||||
[[fallthrough]];
|
||||
|
||||
case ui::kMouseMoveMessage:
|
||||
if (hasCapture()) {
|
||||
|
@ -120,7 +120,8 @@ bool ColorCurveEditor::onProcessMessage(Message* msg)
|
||||
|
||||
captureMouse();
|
||||
|
||||
// continue in motion message...
|
||||
// Continue in motion message...
|
||||
[[fallthrough]];
|
||||
}
|
||||
|
||||
case kMouseMoveMessage: {
|
||||
|
@ -255,12 +255,14 @@ bool PngFormat::onLoad(FileOp* fop)
|
||||
|
||||
case PNG_COLOR_TYPE_RGB_ALPHA:
|
||||
fop->sequenceSetHasAlpha(true);
|
||||
[[fallthrough]];
|
||||
case PNG_COLOR_TYPE_RGB:
|
||||
pixelFormat = IMAGE_RGB;
|
||||
break;
|
||||
|
||||
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
||||
fop->sequenceSetHasAlpha(true);
|
||||
[[fallthrough]];
|
||||
case PNG_COLOR_TYPE_GRAY:
|
||||
pixelFormat = IMAGE_GRAYSCALE;
|
||||
break;
|
||||
@ -799,6 +801,7 @@ void PngFormat::saveColorSpace(png_structp png_ptr, png_infop info_ptr,
|
||||
}
|
||||
|
||||
// Continue to RGB case...
|
||||
[[fallthrough]];
|
||||
|
||||
case gfx::ColorSpace::RGB: {
|
||||
if (colorSpace->hasPrimaries()) {
|
||||
|
@ -417,6 +417,7 @@ private:
|
||||
inImage = true;
|
||||
else if (ev_type == CMARK_EVENT_EXIT)
|
||||
inImage = false;
|
||||
break;
|
||||
}
|
||||
|
||||
case CMARK_NODE_LINK: {
|
||||
@ -434,6 +435,7 @@ private:
|
||||
}
|
||||
inLink = nullptr;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -316,8 +316,7 @@ bool ColorSelector::onProcessMessage(ui::Message* msg)
|
||||
break;
|
||||
|
||||
captureMouse();
|
||||
|
||||
// Continue...
|
||||
[[fallthrough]];
|
||||
|
||||
case kMouseMoveMessage: {
|
||||
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
|
||||
|
@ -178,6 +178,7 @@ bool FileList::onProcessMessage(Message* msg)
|
||||
|
||||
case kMouseDownMessage:
|
||||
captureMouse();
|
||||
[[fallthrough]];
|
||||
|
||||
case kMouseMoveMessage:
|
||||
if (hasCapture()) {
|
||||
|
@ -339,8 +339,7 @@ bool PaletteView::onProcessMessage(Message* msg)
|
||||
}
|
||||
|
||||
captureMouse();
|
||||
|
||||
// Continue...
|
||||
[[fallthrough]];
|
||||
|
||||
case kMouseMoveMessage: {
|
||||
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
|
||||
|
@ -245,7 +245,7 @@ bool ToolBar::onProcessMessage(Message* msg)
|
||||
m_openedRecently = false;
|
||||
|
||||
releaseMouse();
|
||||
// fallthrough
|
||||
[[fallthrough]];
|
||||
|
||||
case kMouseLeaveMessage:
|
||||
if (hasCapture())
|
||||
@ -609,7 +609,7 @@ bool ToolBar::ToolStrip::onProcessMessage(Message* msg)
|
||||
|
||||
case kMouseDownMessage:
|
||||
captureMouse();
|
||||
// fallthrough
|
||||
[[fallthrough]];
|
||||
|
||||
case kMouseMoveMessage: {
|
||||
MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
|
||||
|
@ -50,6 +50,7 @@ frame_t calculate_next_frame(
|
||||
|
||||
case AniDir::REVERSE:
|
||||
frameDelta = -frameDelta;
|
||||
[[fallthrough]];
|
||||
|
||||
case AniDir::FORWARD:
|
||||
frame += frameDelta;
|
||||
|
@ -395,6 +395,8 @@ bool Entry::onProcessMessage(Message* msg)
|
||||
if (!m_selecting_words.isEmpty())
|
||||
m_selecting_words.reset();
|
||||
|
||||
[[fallthrough]];
|
||||
|
||||
case kMouseMoveMessage:
|
||||
if (hasCapture()) {
|
||||
bool is_dirty = false;
|
||||
|
@ -206,6 +206,7 @@ bool ListBox::onProcessMessage(Message* msg)
|
||||
|
||||
case kMouseDownMessage:
|
||||
captureMouse();
|
||||
[[fallthrough]];
|
||||
|
||||
case kMouseMoveMessage:
|
||||
if (hasCapture()) {
|
||||
|
@ -1858,11 +1858,10 @@ bool Manager::processFocusMovementMessage(Message* msg)
|
||||
break;
|
||||
|
||||
// Arrow keys
|
||||
case kKeyLeft: if (!cmp) cmp = cmp_left;
|
||||
case kKeyRight: if (!cmp) cmp = cmp_right;
|
||||
case kKeyUp: if (!cmp) cmp = cmp_up;
|
||||
case kKeyLeft: if (!cmp) cmp = cmp_left; [[fallthrough]];
|
||||
case kKeyRight: if (!cmp) cmp = cmp_right; [[fallthrough]];
|
||||
case kKeyUp: if (!cmp) cmp = cmp_up; [[fallthrough]];
|
||||
case kKeyDown: if (!cmp) cmp = cmp_down;
|
||||
|
||||
// More than one widget
|
||||
if (count > 1) {
|
||||
// Position where the focus come
|
||||
|
@ -443,7 +443,7 @@ bool MenuBox::onProcessMessage(Message* msg)
|
||||
if (!base->was_clicked)
|
||||
break;
|
||||
|
||||
//[[fallthrough]];
|
||||
[[fallthrough]];
|
||||
}
|
||||
|
||||
case kMouseDownMessage:
|
||||
|
@ -132,7 +132,8 @@ bool ScrollBar::onProcessMessage(Message* msg)
|
||||
setSelected(true);
|
||||
captureMouse();
|
||||
|
||||
// continue to kMouseMoveMessage handler...
|
||||
// Continue to kMouseMoveMessage handler...
|
||||
[[fallthrough]];
|
||||
}
|
||||
|
||||
case kMouseMoveMessage:
|
||||
|
@ -115,7 +115,7 @@ bool Slider::onProcessMessage(Message* msg)
|
||||
|
||||
setupSliderCursor();
|
||||
|
||||
// Fall through
|
||||
[[fallthrough]];
|
||||
|
||||
case kMouseMoveMessage:
|
||||
if (hasCapture()) {
|
||||
|
@ -100,6 +100,7 @@ bool Splitter::onProcessMessage(Message* msg)
|
||||
captureMouse();
|
||||
|
||||
// Continue with motion message...
|
||||
[[fallthrough]];
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user