Sfoglia il codice sorgente

Various minor fixes following a pass of cppcheck static analyzer

ocornut 9 anni fa
parent
commit
4e3c6f64c0
3 ha cambiato i file con 5 aggiunte e 3 eliminazioni
  1. 0 1
      extra_fonts/binary_to_compressed_c.cpp
  2. 2 2
      imgui.cpp
  3. 3 0
      imgui_internal.h

+ 0 - 1
extra_fonts/binary_to_compressed_c.cpp

@@ -79,7 +79,6 @@ bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_b
     if (use_base85_encoding)
     {
         fprintf(out, "static const char %s_%sdata_base85[%d+1] =\n    \"", symbol, compressed_str, (int)((compressed_sz+3)/4)*5);
-        int column = 0;
         for (int i = 0; i < compressed_sz; i += 4)
         {
             unsigned int d = *(unsigned int*)(compressed + i);

+ 2 - 2
imgui.cpp

@@ -774,7 +774,7 @@ void ImGuiIO::AddInputCharactersUTF8(const char* utf8_chars)
     const int wchars_buf_len = sizeof(ImGuiIO::InputCharacters) / sizeof(ImWchar);
     ImWchar wchars[wchars_buf_len];
     ImTextStrFromUtf8(wchars, wchars_buf_len, utf8_chars, NULL);
-    for (int i = 0; wchars[i] != 0 && i < wchars_buf_len; i++)
+    for (int i = 0; i < wchars_buf_len && wchars[i] != 0; i++)
         AddInputCharacter(wchars[i]);
 }
 
@@ -7323,7 +7323,6 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
     }
 
     bool value_changed = false;
-    bool cancel_edit = false;
     bool enter_pressed = false;
 
     if (g.ActiveId == id)
@@ -7388,6 +7387,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
         }
 
         // Handle various key-presses
+        bool cancel_edit = false;
         const int k_mask = (is_shift_down ? STB_TEXTEDIT_K_SHIFT : 0);
         const bool is_ctrl_only = is_ctrl_down && !is_alt_down && !is_shift_down;
         if (IsKeyPressedMap(ImGuiKey_LeftArrow))                        { edit_state.OnKeyPressed(is_ctrl_down ? STB_TEXTEDIT_K_WORDLEFT | k_mask : STB_TEXTEDIT_K_LEFT | k_mask); }

+ 3 - 0
imgui_internal.h

@@ -462,6 +462,7 @@ struct ImGuiState
         SetNextWindowCollapsedVal = false;
         SetNextWindowPosCond = 0;
         SetNextWindowSizeCond = 0;
+        SetNextWindowContentSizeCond = 0;
         SetNextWindowCollapsedCond = 0;
         SetNextWindowFocus = false;
         SetNextTreeNodeOpenedVal = false;
@@ -482,6 +483,7 @@ struct ImGuiState
         ModalWindowDarkeningRatio = 0.0f;
         OverlayDrawList._OwnerName = "##Overlay"; // Give it a name for debugging
         MouseCursor = ImGuiMouseCursor_Arrow;
+        memset(MouseCursorData, 0, sizeof(MouseCursorData));
 
         LogEnabled = false;
         LogFile = NULL;
@@ -493,6 +495,7 @@ struct ImGuiState
         FramerateSecPerFrameIdx = 0;
         FramerateSecPerFrameAccum = 0.0f;
         CaptureMouseNextFrame = CaptureKeyboardNextFrame = false;
+        memset(TempBuffer, 0, sizeof(TempBuffer));
     }
 };