#192 Size parsing bug 4.x-dev

Wed, 07 Oct 2020 20:33:51 +0300

author
cemkalyoncu
date
Wed, 07 Oct 2020 20:33:51 +0300
branch
4.x-dev
changeset 1461
6bbecfcb304e
parent 1460
d0d48718575e
child 1462
a750ce7fd0d7

#192 Size parsing bug

Source/Gorgon/Geometry/Size.h file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/Common.h file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/Generator.cpp file | annotate | diff | comparison | revisions
Source/Gorgon/Widgets/Slider.h file | annotate | diff | comparison | revisions
--- a/Source/Gorgon/Geometry/Size.h	Wed Oct 07 16:46:11 2020 +0300
+++ b/Source/Gorgon/Geometry/Size.h	Wed Oct 07 20:33:51 2020 +0300
@@ -48,8 +48,14 @@
 		/// Conversion from string
 		explicit basic_Size(const std::string &str) {
 			auto s=str.begin();
+
+			if(s == str.end())
+				Width = Height = 0;
 			
-			while(*s==' ' || *s=='\t') s++;
+			while(s != str.end() && (*s==' ' || *s=='\t')) s++;
+
+			if(s == str.end())
+				Width = Height = 0;
             
             auto pos = str.find_first_of('x', s-str.begin());
             if(pos != str.npos)
@@ -59,9 +65,11 @@
             
 			while(s!=str.end() && *s!='x' && *s!=',') s++;
 			
-			if(*s=='x' || *s==',') s++;
-			
-			Height=String::To<T_>(&str[s-str.begin()]);
+			if(s != str.end()) {
+				if(*s=='x' || *s==',') s++;
+
+				Height = String::To<T_>(&str[s-str.begin()]);
+			}
 		}
 		
 		
--- a/Source/Gorgon/Widgets/Common.h	Wed Oct 07 16:46:11 2020 +0300
+++ b/Source/Gorgon/Widgets/Common.h	Wed Oct 07 20:33:51 2020 +0300
@@ -14,7 +14,7 @@
     
     template<class T_>
     T_ FloatToValue(float value, T_ min, T_ max) {
-        return (max - min) * value + min;
+        return T_((max - min) * value + min);
     }
     
     ///@endcond
--- a/Source/Gorgon/Widgets/Generator.cpp	Wed Oct 07 16:46:11 2020 +0300
+++ b/Source/Gorgon/Widgets/Generator.cpp	Wed Oct 07 20:33:51 2020 +0300
@@ -128,7 +128,7 @@
         lettervsize = regularrenderer->GetLetterHeight();
         asciivsize = regularrenderer->GetLetterHeight(true);
         
-        int totalh = regularrenderer->GetLineGap();
+        int totalh = (int)regularrenderer->GetLineGap();
         
         Spacing = (int)std::round((float)totalh / (2 * Density / 3));
         Focus.Spacing = std::max(1, Spacing / 2);
@@ -780,7 +780,7 @@
                 }, CGI::SolidFill<>(color));
             }
             else {
-                CGI::DrawLines(*icon, tick, 1.2*ShapeBorder, CGI::SolidFill<>(color));
+                CGI::DrawLines(*icon, tick, 1.2f*ShapeBorder, CGI::SolidFill<>(color));
             }
             icon->Prepare();
             
--- a/Source/Gorgon/Widgets/Slider.h	Wed Oct 07 16:46:11 2020 +0300
+++ b/Source/Gorgon/Widgets/Slider.h	Wed Oct 07 20:33:51 2020 +0300
@@ -512,7 +512,7 @@
             
             stack.SetOtherMouseEvent([this](UI::ComponentTemplate::Tag, Input::Mouse::EventType type, Geometry::Point, float amount) {
                 if(type == Input::Mouse::EventType::Scroll_Vert || type == Input::Mouse::EventType::Scroll_Hor) {
-                    SetValue(GetValue() - amount * smallchange);
+                    SetValue(T_(GetValue() - amount * smallchange));
                     
                     return true;
                 }

mercurial