Fix many errors found by PVS-Studio
Fix errors 2, 3, 4, 6, 8, 9, 11, 12, 13, 14, and 15.
(cherry picked from commit cb01268562
)
This commit is contained in:
parent
dafdd9a08e
commit
58c87e5d26
|
@ -2149,7 +2149,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
|
|||
int idx = p_index;
|
||||
if (idx < 0)
|
||||
idx += 4;
|
||||
if (idx >= 0 || idx < 4) {
|
||||
if (idx >= 0 && idx < 4) {
|
||||
Color *v = reinterpret_cast<Color *>(_data._mem);
|
||||
(*v)[idx] = p_value;
|
||||
valid = true;
|
||||
|
@ -2524,7 +2524,7 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
|
|||
int idx = p_index;
|
||||
if (idx < 0)
|
||||
idx += 4;
|
||||
if (idx >= 0 || idx < 4) {
|
||||
if (idx >= 0 && idx < 4) {
|
||||
const Color *v = reinterpret_cast<const Color *>(_data._mem);
|
||||
valid = true;
|
||||
return (*v)[idx];
|
||||
|
|
|
@ -595,7 +595,7 @@ bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant &
|
|||
return false;
|
||||
|
||||
for (int i = 0; i < files.size(); i++) {
|
||||
String file = files[0];
|
||||
String file = files[i];
|
||||
String ftype = EditorFileSystem::get_singleton()->get_file_type(file);
|
||||
|
||||
if (!ClassDB::is_parent_class(ftype, "Texture")) {
|
||||
|
|
|
@ -180,7 +180,7 @@ static String dump_node_code(SL::Node *p_node, int p_level) {
|
|||
|
||||
String scode = dump_node_code(bnode->statements[i], p_level);
|
||||
|
||||
if (bnode->statements[i]->type == SL::Node::TYPE_CONTROL_FLOW || bnode->statements[i]->type == SL::Node::TYPE_CONTROL_FLOW) {
|
||||
if (bnode->statements[i]->type == SL::Node::TYPE_CONTROL_FLOW) {
|
||||
code += scode; //use directly
|
||||
} else {
|
||||
code += _mktab(p_level) + scode + ";\n";
|
||||
|
|
|
@ -909,11 +909,11 @@ void AtlasTexture::_bind_methods() {
|
|||
|
||||
void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const {
|
||||
|
||||
Rect2 rc = region;
|
||||
|
||||
if (!atlas.is_valid())
|
||||
return;
|
||||
|
||||
Rect2 rc = region;
|
||||
|
||||
if (rc.size.width == 0) {
|
||||
rc.size.width = atlas->get_width();
|
||||
}
|
||||
|
@ -928,11 +928,11 @@ void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_m
|
|||
|
||||
void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const {
|
||||
|
||||
Rect2 rc = region;
|
||||
|
||||
if (!atlas.is_valid())
|
||||
return;
|
||||
|
||||
Rect2 rc = region;
|
||||
|
||||
if (rc.size.width == 0) {
|
||||
rc.size.width = atlas->get_width();
|
||||
}
|
||||
|
@ -950,11 +950,11 @@ void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile
|
|||
void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map, bool p_clip_uv) const {
|
||||
|
||||
//this might not necessarily work well if using a rect, needs to be fixed properly
|
||||
Rect2 rc = region;
|
||||
|
||||
if (!atlas.is_valid())
|
||||
return;
|
||||
|
||||
Rect2 rc = region;
|
||||
|
||||
Rect2 src = p_src_rect;
|
||||
src.position += (rc.position - margin.position);
|
||||
Rect2 src_c = rc.clip(src);
|
||||
|
@ -981,11 +981,11 @@ void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, cons
|
|||
|
||||
bool AtlasTexture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const {
|
||||
|
||||
Rect2 rc = region;
|
||||
|
||||
if (!atlas.is_valid())
|
||||
return false;
|
||||
|
||||
Rect2 rc = region;
|
||||
|
||||
Rect2 src = p_src_rect;
|
||||
src.position += (rc.position - margin.position);
|
||||
Rect2 src_c = rc.clip(src);
|
||||
|
|
Loading…
Reference in New Issue