Fix uninitialized variable warning 1781/head
authorkwolekr <kwolekr@minetest.net>
Thu, 30 Oct 2014 06:53:20 +0000 (02:53 -0400)
committerkwolekr <kwolekr@minetest.net>
Thu, 30 Oct 2014 06:53:20 +0000 (02:53 -0400)
src/guiFormSpecMenu.cpp
src/guiFormSpecMenu.h

index e82ea829c34f8ca3c53a76bc2a44f0adf5841aba..edbb595c295348506038377b785d692251af03c5 100644 (file)
@@ -83,6 +83,7 @@ GUIFormSpecMenu::GUIFormSpecMenu(irr::IrrlichtDevice* dev,
        m_selected_amount(0),
        m_selected_dragging(false),
        m_tooltip_element(NULL),
+       m_hovered_time(0),
        m_old_tooltip_id(-1),
        m_allowclose(true),
        m_lock(false),
@@ -2346,18 +2347,20 @@ void GUIFormSpecMenu::drawMenu()
 
        if (hovered != NULL) {
                s32 id = hovered->getID();
-               u32 delta;
+
+               u32 delta = 0;
                if (id == -1) {
                        m_old_tooltip_id = id;
                        m_old_tooltip = "";
-                       delta = 0;
-               } else if (id != m_old_tooltip_id) {
-                       m_hoovered_time = getTimeMs();
-                       m_old_tooltip_id = id;
-                       delta = 0;
-               } else if (id == m_old_tooltip_id) {
-                       delta = porting::getDeltaMs(m_hoovered_time, getTimeMs());
+               } else {
+                       if (id == m_old_tooltip_id) {
+                               delta = porting::getDeltaMs(m_hovered_time, getTimeMs());
+                       } else {
+                               m_hovered_time = getTimeMs();
+                               m_old_tooltip_id = id;
+                       }
                }
+
                if (id != -1 && delta >= m_tooltip_show_delay) {
                        for(std::vector<FieldSpec>::iterator iter =  m_fields.begin();
                                        iter != m_fields.end(); iter++) {
index d38e9ec468e5973a9d57c1f521efd7ce0318e49e..d5bd112cc4f5d2de669ada0bce8c9bf9269b6364 100644 (file)
@@ -324,7 +324,7 @@ protected:
        gui::IGUIStaticText *m_tooltip_element;
 
        u32 m_tooltip_show_delay;
-       s32 m_hoovered_time;
+       s32 m_hovered_time;
        s32 m_old_tooltip_id;
        std::string m_old_tooltip;