Skip to content

Commit 1a884a0

Browse files
committed
Add cppcoreguidelines-pro-type-member-init check
1 parent 0d0b646 commit 1a884a0

File tree

4 files changed

+12
-36
lines changed

4 files changed

+12
-36
lines changed

.clang-tidy

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ Checks: >
1919
-cppcoreguidelines-pro-bounds-constant-array-index,
2020
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
2121
-cppcoreguidelines-pro-type-cstyle-cast,
22-
-cppcoreguidelines-pro-type-member-init,
2322
-cppcoreguidelines-pro-type-union-access,
2423
-cppcoreguidelines-special-member-functions,
2524
-misc-non-private-member-variables-in-classes,
2625
-modernize-avoid-c-arrays,
27-
-modernize-loop-convert,
2826
-modernize-use-trailing-return-type,
2927
-performance-no-int-to-ptr,
3028
-readability-avoid-const-params-in-decls,

examples/minimal/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ int main() {
1717

1818
sf::Clock deltaClock;
1919
while (window.isOpen()) {
20-
sf::Event event;
20+
sf::Event event{};
2121
while (window.pollEvent(event)) {
2222
ImGui::SFML::ProcessEvent(window, event);
2323

examples/multiple_windows/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ int main() {
1919
sf::Clock deltaClock;
2020
while (window.isOpen()) {
2121
// Main window event processing
22-
sf::Event event;
22+
sf::Event event{};
2323
while (window.pollEvent(event)) {
2424
ImGui::SFML::ProcessEvent(window, event);
2525
if (event.type == sf::Event::Closed) {

imgui-SFML.cpp

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -177,56 +177,34 @@ struct WindowContext {
177177

178178
bool windowHasFocus;
179179
bool mouseMoved{false};
180-
bool mousePressed[3];
181-
ImGuiMouseCursor lastCursor;
180+
bool mousePressed[3] = {false};
181+
ImGuiMouseCursor lastCursor{ImGuiMouseCursor_COUNT};
182182

183-
bool touchDown[3];
183+
bool touchDown[3] = {false};
184184
sf::Vector2i touchPos;
185185

186-
unsigned int joystickId;
187-
ImGuiKey joystickMapping[sf::Joystick::ButtonCount];
186+
unsigned int joystickId{getConnectedJoystickId()};
187+
ImGuiKey joystickMapping[sf::Joystick::ButtonCount] = {ImGuiKey_None};
188188
StickInfo dPadInfo;
189189
StickInfo lStickInfo;
190190
StickInfo rStickInfo;
191191
TriggerInfo lTriggerInfo;
192192
TriggerInfo rTriggerInfo;
193193

194194
sf::Cursor mouseCursors[ImGuiMouseCursor_COUNT];
195-
bool mouseCursorLoaded[ImGuiMouseCursor_COUNT];
195+
bool mouseCursorLoaded[ImGuiMouseCursor_COUNT] = {ImGuiKey_None};
196196

197197
#ifdef ANDROID
198198
#ifdef USE_JNI
199-
bool wantTextInput;
199+
bool wantTextInput{false};
200200
#endif
201201
#endif
202202

203+
WindowContext(const sf::Window* w) : window(w), windowHasFocus(window->hasFocus()) {}
204+
~WindowContext() { ImGui::DestroyContext(imContext); }
205+
203206
WindowContext(const WindowContext&) = delete; // non construction-copyable
204207
WindowContext& operator=(const WindowContext&) = delete; // non copyable
205-
206-
WindowContext(const sf::Window* w) : window(w), windowHasFocus(window->hasFocus()) {
207-
for (int i = 0; i < 3; ++i) {
208-
mousePressed[i] = false;
209-
touchDown[i] = false;
210-
}
211-
lastCursor = ImGuiMouseCursor_COUNT;
212-
213-
joystickId = getConnectedJoystickId();
214-
for (int i = 0; i < static_cast<int>(sf::Joystick::ButtonCount); ++i) {
215-
joystickMapping[i] = ImGuiKey_None;
216-
}
217-
218-
for (int i = 0; i < ImGuiMouseCursor_COUNT; ++i) {
219-
mouseCursorLoaded[i] = false;
220-
}
221-
222-
#ifdef ANDROID
223-
#ifdef USE_JNI
224-
wantTextInput = false;
225-
#endif
226-
#endif
227-
}
228-
229-
~WindowContext() { ImGui::DestroyContext(imContext); }
230208
};
231209

232210
std::vector<std::unique_ptr<WindowContext>> s_windowContexts;

0 commit comments

Comments
 (0)