summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorHubert Jarosz <marqin.pl+git@gmail.com>2016-03-01 00:08:33 +0100
committerHubert Jarosz <marqin.pl@gmail.com>2016-03-09 00:18:23 +0100
commit7b07bcaf449ea6cf52c2ac501e48cddbe4bde035 (patch)
tree5d5c2abcc801262b72f02f5e9c7c70a20c729e73 /tools
parentbf7f9244a95962c9833e68743726fe83a00b732c (diff)
fix six possible "divide by zero"
Diffstat (limited to 'tools')
-rw-r--r--tools/editor/plugins/editor_preview_plugins.cpp6
-rw-r--r--tools/editor/plugins/script_editor_plugin.cpp4
-rw-r--r--tools/editor/plugins/spatial_editor_plugin.cpp7
3 files changed, 10 insertions, 7 deletions
diff --git a/tools/editor/plugins/editor_preview_plugins.cpp b/tools/editor/plugins/editor_preview_plugins.cpp
index f3b5272571..12d50cd4b8 100644
--- a/tools/editor/plugins/editor_preview_plugins.cpp
+++ b/tools/editor/plugins/editor_preview_plugins.cpp
@@ -725,7 +725,11 @@ Ref<Texture> EditorSamplePreviewPlugin::generate(const RES& p_from) {
} else {
half=1;
ofs=h/2;
- v = ((j-(h/2))/(float)(h/2)) * 2.0 - 1.0;
+ if( (float)(h/2) != 0 ) {
+ v = ((j-(h/2))/(float)(h/2)) * 2.0 - 1.0;
+ } else {
+ v = ((j-(h/2))/(float)(1/2)) * 2.0 - 1.0;
+ }
}
uint8_t* imgofs = &imgw[(j*w+i)*3];
diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp
index 2fb5dd619e..76c64beb61 100644
--- a/tools/editor/plugins/script_editor_plugin.cpp
+++ b/tools/editor/plugins/script_editor_plugin.cpp
@@ -1784,7 +1784,8 @@ void ScriptEditor::_update_script_colors() {
if (h>hist_size) {
continue;
}
- float v = Math::ease((edit_pass-pass)/float(hist_size),0.4);
+ int non_zero_hist_size = ( hist_size == 0 ) ? 1 : hist_size;
+ float v = Math::ease((edit_pass-pass)/float(non_zero_hist_size),0.4);
script_list->set_item_custom_bg_color(i,hot_color.linear_interpolate(cold_color,v));
@@ -2704,4 +2705,3 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) {
ScriptEditorPlugin::~ScriptEditorPlugin()
{
}
-
diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp
index e787c74702..79ff78ca0d 100644
--- a/tools/editor/plugins/spatial_editor_plugin.cpp
+++ b/tools/editor/plugins/spatial_editor_plugin.cpp
@@ -2084,7 +2084,9 @@ void SpatialEditorViewport::_menu_option(int p_option) {
count++;
}
- center/=float(count);
+ if( count != 0 ) {
+ center/=float(count);
+ }
cursor.pos=center;
} break;
@@ -4240,6 +4242,3 @@ SpatialEditorPlugin::SpatialEditorPlugin(EditorNode *p_node) {
SpatialEditorPlugin::~SpatialEditorPlugin() {
}
-
-
-