Fix warnings for operator precedence disambiguation [-Wparentheses]
Fixes the following GCC 5 warnings: ``` core/io/resource_format_binary.cpp:1721:29: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses] core/typedefs.h:108:24: warning: suggest parentheses around comparison in operand of '!=' [-Wparentheses] editor/plugins/spatial_editor_plugin.cpp:2202:58: warning: suggest parentheses around comparison in operand of '!=' [-Wparentheses] editor/plugins/spatial_editor_plugin.cpp:5002:12: warning: suggest explicit braces to avoid ambiguous 'else' [-Wparentheses] main/input_default.cpp:346:59: warning: suggest parentheses around '-' inside '<<' [-Wparentheses] main/input_default.cpp:348:60: warning: suggest parentheses around '-' inside '<<' [-Wparentheses] main/input_default.cpp:579:57: warning: suggest parentheses around '-' inside '<<' [-Wparentheses] modules/gridmap/grid_map_editor_plugin.cpp:613:14: warning: suggest explicit braces to avoid ambiguous 'else' [-Wparentheses] modules/theora/video_stream_theora.cpp:335:34: warning: suggest parentheses around '+' in operand of '&' [-Wparentheses] modules/theora/video_stream_theora.cpp:336:35: warning: suggest parentheses around '+' in operand of '&' [-Wparentheses] modules/visual_script/visual_script_property_selector.cpp:215:38: warning: suggest parentheses around '&&' within '||' [-Wparentheses] scene/gui/rich_text_label.cpp:424:84: warning: suggest parentheses around '&&' within '||' [-Wparentheses] scene/gui/rich_text_label.cpp:512:80: warning: suggest parentheses around '&&' within '||' [-Wparentheses] scene/gui/scroll_container.cpp:173:36: warning: suggest parentheses around '&&' within '||' [-Wparentheses] scene/gui/scroll_container.cpp:173:86: warning: suggest parentheses around '&&' within '||' [-Wparentheses] scene/gui/tree.cpp:1419:98: warning: suggest parentheses around '&&' within '||' [-Wparentheses] ```
This commit is contained in:
parent
2b084352b9
commit
d8b30d42f5
@ -1718,7 +1718,7 @@ void ResourceFormatSaverBinaryInstance::save_unicode_string(FileAccess *f, const
|
||||
|
||||
CharString utf8 = p_string.utf8();
|
||||
if (p_bit_on_len) {
|
||||
f->store_32(utf8.length() + 1 | 0x80000000);
|
||||
f->store_32((utf8.length() + 1) | 0x80000000);
|
||||
} else {
|
||||
f->store_32(utf8.length() + 1);
|
||||
}
|
||||
|
@ -105,11 +105,11 @@ T *_nullptr() {
|
||||
/** Generic ABS function, for math uses please use Math::abs */
|
||||
|
||||
#ifndef ABS
|
||||
#define ABS(m_v) ((m_v < 0) ? (-(m_v)) : (m_v))
|
||||
#define ABS(m_v) (((m_v) < 0) ? (-(m_v)) : (m_v))
|
||||
#endif
|
||||
|
||||
#ifndef SGN
|
||||
#define SGN(m_v) ((m_v < 0) ? (-1.0) : (+1.0))
|
||||
#define SGN(m_v) (((m_v) < 0) ? (-1.0) : (+1.0))
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
|
@ -2199,7 +2199,7 @@ void SpatialEditorViewport::_notification(int p_what) {
|
||||
|
||||
bool shrink = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_HALF_RESOLUTION));
|
||||
|
||||
if (shrink != viewport_container->get_stretch_shrink() > 1) {
|
||||
if (shrink != (viewport_container->get_stretch_shrink() > 1)) {
|
||||
viewport_container->set_stretch_shrink(shrink ? 2 : 1);
|
||||
}
|
||||
|
||||
@ -4979,32 +4979,29 @@ void SpatialEditor::_unhandled_key_input(Ref<InputEvent> p_event) {
|
||||
if (!k->is_pressed())
|
||||
return;
|
||||
|
||||
if (ED_IS_SHORTCUT("spatial_editor/tool_select", p_event))
|
||||
if (ED_IS_SHORTCUT("spatial_editor/tool_select", p_event)) {
|
||||
_menu_item_pressed(MENU_TOOL_SELECT);
|
||||
|
||||
else if (ED_IS_SHORTCUT("spatial_editor/tool_move", p_event))
|
||||
} else if (ED_IS_SHORTCUT("spatial_editor/tool_move", p_event)) {
|
||||
_menu_item_pressed(MENU_TOOL_MOVE);
|
||||
|
||||
else if (ED_IS_SHORTCUT("spatial_editor/tool_rotate", p_event))
|
||||
} else if (ED_IS_SHORTCUT("spatial_editor/tool_rotate", p_event)) {
|
||||
_menu_item_pressed(MENU_TOOL_ROTATE);
|
||||
|
||||
else if (ED_IS_SHORTCUT("spatial_editor/tool_scale", p_event))
|
||||
} else if (ED_IS_SHORTCUT("spatial_editor/tool_scale", p_event)) {
|
||||
_menu_item_pressed(MENU_TOOL_SCALE);
|
||||
else if (ED_IS_SHORTCUT("spatial_editor/snap_to_floor", p_event))
|
||||
} else if (ED_IS_SHORTCUT("spatial_editor/snap_to_floor", p_event)) {
|
||||
snap_selected_nodes_to_floor();
|
||||
|
||||
else if (ED_IS_SHORTCUT("spatial_editor/local_coords", p_event))
|
||||
} else if (ED_IS_SHORTCUT("spatial_editor/local_coords", p_event)) {
|
||||
if (are_local_coords_enabled()) {
|
||||
_menu_item_toggled(false, MENU_TOOL_LOCAL_COORDS);
|
||||
} else {
|
||||
_menu_item_toggled(true, MENU_TOOL_LOCAL_COORDS);
|
||||
}
|
||||
else if (ED_IS_SHORTCUT("spatial_editor/snap", p_event))
|
||||
} else if (ED_IS_SHORTCUT("spatial_editor/snap", p_event)) {
|
||||
if (is_snap_enabled()) {
|
||||
_menu_item_toggled(false, MENU_TOOL_USE_SNAP);
|
||||
} else {
|
||||
_menu_item_toggled(true, MENU_TOOL_USE_SNAP);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -343,9 +343,9 @@ void InputDefault::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool
|
||||
button_event->set_pressed(st->is_pressed());
|
||||
button_event->set_button_index(BUTTON_LEFT);
|
||||
if (st->is_pressed()) {
|
||||
button_event->set_button_mask(mouse_button_mask | (1 << BUTTON_LEFT - 1));
|
||||
button_event->set_button_mask(mouse_button_mask | (1 << (BUTTON_LEFT - 1)));
|
||||
} else {
|
||||
button_event->set_button_mask(mouse_button_mask & ~(1 << BUTTON_LEFT - 1));
|
||||
button_event->set_button_mask(mouse_button_mask & ~(1 << (BUTTON_LEFT - 1)));
|
||||
}
|
||||
|
||||
_parse_input_event_impl(button_event, true);
|
||||
@ -576,7 +576,7 @@ void InputDefault::ensure_touch_mouse_raised() {
|
||||
button_event->set_global_position(mouse_pos);
|
||||
button_event->set_pressed(false);
|
||||
button_event->set_button_index(BUTTON_LEFT);
|
||||
button_event->set_button_mask(mouse_button_mask & ~(1 << BUTTON_LEFT - 1));
|
||||
button_event->set_button_mask(mouse_button_mask & ~(1 << (BUTTON_LEFT - 1)));
|
||||
|
||||
_parse_input_event_impl(button_event, true);
|
||||
}
|
||||
|
@ -597,29 +597,31 @@ bool GridMapEditor::forward_spatial_input_event(Camera *p_camera, const Ref<Inpu
|
||||
if (mb->get_button_index() == BUTTON_LEFT) {
|
||||
|
||||
if (input_action == INPUT_DUPLICATE) {
|
||||
|
||||
//paste
|
||||
_duplicate_paste();
|
||||
input_action = INPUT_NONE;
|
||||
_update_duplicate_indicator();
|
||||
} else if (mb->get_shift()) {
|
||||
input_action = INPUT_SELECT;
|
||||
} else if (mb->get_command())
|
||||
} else if (mb->get_command()) {
|
||||
input_action = INPUT_COPY;
|
||||
else {
|
||||
} else {
|
||||
input_action = INPUT_PAINT;
|
||||
set_items.clear();
|
||||
}
|
||||
} else if (mb->get_button_index() == BUTTON_RIGHT)
|
||||
} else if (mb->get_button_index() == BUTTON_RIGHT) {
|
||||
if (input_action == INPUT_DUPLICATE) {
|
||||
|
||||
input_action = INPUT_NONE;
|
||||
_update_duplicate_indicator();
|
||||
} else if (mb->get_shift()) {
|
||||
input_action = INPUT_ERASE;
|
||||
set_items.clear();
|
||||
} else
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true);
|
||||
} else {
|
||||
|
@ -332,8 +332,8 @@ void VideoStreamPlaybackTheora::set_file(const String &p_file) {
|
||||
|
||||
int w;
|
||||
int h;
|
||||
w = (ti.pic_x + ti.frame_width + 1 & ~1) - (ti.pic_x & ~1);
|
||||
h = (ti.pic_y + ti.frame_height + 1 & ~1) - (ti.pic_y & ~1);
|
||||
w = ((ti.pic_x + ti.frame_width + 1) & ~1) - (ti.pic_x & ~1);
|
||||
h = ((ti.pic_y + ti.frame_height + 1) & ~1) - (ti.pic_y & ~1);
|
||||
size.x = w;
|
||||
size.y = h;
|
||||
|
||||
|
@ -190,15 +190,14 @@ void VisualScriptPropertySelector::_update_search() {
|
||||
if (type_filter.size() && type_filter.find(E->get().type) == -1)
|
||||
continue;
|
||||
|
||||
// capitalize() also converts underscore to space, we'll match again both possible styles
|
||||
String get_text_raw = String(vformat(TTR("Get %s"), E->get().name));
|
||||
String get_text = get_text_raw.capitalize();
|
||||
|
||||
String set_text_raw = String(vformat(TTR("Set %s"), E->get().name));
|
||||
String set_text = set_text_raw.capitalize();
|
||||
String input = search_box->get_text().capitalize();
|
||||
if (input == String() ||
|
||||
get_text_raw.findn(input) != -1 ||
|
||||
get_text.findn(input) != -1) {
|
||||
|
||||
if (input == String() || get_text_raw.findn(input) != -1 || get_text.findn(input) != -1) {
|
||||
TreeItem *item = search_options->create_item(category ? category : root);
|
||||
item->set_text(0, get_text);
|
||||
item->set_metadata(0, E->get().name);
|
||||
@ -211,9 +210,7 @@ void VisualScriptPropertySelector::_update_search() {
|
||||
item->set_metadata(2, connecting);
|
||||
}
|
||||
|
||||
if (input == String() ||
|
||||
set_text_raw.findn(input) != -1 &&
|
||||
set_text.findn(input) != -1) {
|
||||
if (input == String() || set_text_raw.findn(input) != -1 || set_text.findn(input) != -1) {
|
||||
TreeItem *item = search_options->create_item(category ? category : root);
|
||||
item->set_text(0, set_text);
|
||||
item->set_metadata(0, E->get().name);
|
||||
|
@ -421,7 +421,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
|
||||
|
||||
int cw = 0;
|
||||
|
||||
bool visible = visible_characters < 0 || p_char_count < visible_characters && YRANGE_VISIBLE(y + lh - line_descent - line_ascent, line_ascent + line_descent);
|
||||
bool visible = visible_characters < 0 || (p_char_count < visible_characters && YRANGE_VISIBLE(y + lh - line_descent - line_ascent, line_ascent + line_descent));
|
||||
if (visible)
|
||||
line_is_blank = false;
|
||||
|
||||
@ -509,7 +509,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
|
||||
|
||||
ENSURE_WIDTH(img->image->get_width());
|
||||
|
||||
bool visible = visible_characters < 0 || p_char_count < visible_characters && YRANGE_VISIBLE(y + lh - font->get_descent() - img->image->get_height(), img->image->get_height());
|
||||
bool visible = visible_characters < 0 || (p_char_count < visible_characters && YRANGE_VISIBLE(y + lh - font->get_descent() - img->image->get_height(), img->image->get_height()));
|
||||
if (visible)
|
||||
line_is_blank = false;
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include "scroll_container.h"
|
||||
#include "core/os/os.h"
|
||||
|
||||
bool ScrollContainer::clips_input() const {
|
||||
|
||||
return true;
|
||||
@ -170,7 +171,7 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) {
|
||||
Vector2 motion = Vector2(mm->get_relative().x, mm->get_relative().y);
|
||||
drag_accum -= motion;
|
||||
|
||||
if (beyond_deadzone || scroll_h && Math::abs(drag_accum.x) > deadzone || scroll_v && Math::abs(drag_accum.y) > deadzone) {
|
||||
if (beyond_deadzone || (scroll_h && Math::abs(drag_accum.x) > deadzone) || (scroll_v && Math::abs(drag_accum.y) > deadzone)) {
|
||||
if (!beyond_deadzone) {
|
||||
propagate_notification(NOTIFICATION_SCROLL_BEGIN);
|
||||
emit_signal("scroll_started");
|
||||
|
@ -1416,7 +1416,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
|
||||
|
||||
while (c) {
|
||||
|
||||
if (cache.draw_relationship_lines == 1 && (c->get_parent() != root || c->get_parent() == root && !hide_root)) {
|
||||
if (cache.draw_relationship_lines == 1 && (c->get_parent() != root || !hide_root)) {
|
||||
int root_ofs = children_pos.x + ((p_item->disable_folding || hide_folding) ? cache.hseparation : cache.item_margin);
|
||||
int parent_ofs = p_pos.x + ((p_item->disable_folding || hide_folding) ? cache.hseparation : cache.item_margin);
|
||||
Point2i root_pos = Point2i(root_ofs, children_pos.y + label_h / 2) - cache.offset + p_draw_ofs;
|
||||
|
Loading…
Reference in New Issue
Block a user