Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed using unitialized variables in mouse button handling #1726

Closed
wants to merge 1 commit into from
Closed

Fixed using unitialized variables in mouse button handling #1726

wants to merge 1 commit into from

Conversation

Zeno-
Copy link
Contributor

@Zeno- Zeno- commented Oct 6, 2014

See also: #1707

event.MouseInput.Event is not initialized if event.EventType != EET_MOUSE_INPUT_EVENT and the previous code didn't check that EET_MOUSE_INPUT_EVENT was indeed the event type before checking the MouseEvent (and it was therefore invalid/not initialized).

(event.EventType == EET_MOUSE_INPUT_EVENT
&& event.MouseInput.Event == EMIE_MOUSE_MOVED
&& event.MouseInput.isRightPressed()
&& getItemAtPos(m_pointer).i != getItemAtPos(m_old_pointer).i)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since event.EventType == EET_MOUSE_INPUT_EVENT is checked in both sides of the "or" you can move it out and do:

-   if((event.EventType==EET_MOUSE_INPUT_EVENT &&
-           event.MouseInput.Event != EMIE_MOUSE_MOVED) ||
-           (event.MouseInput.Event == EMIE_MOUSE_MOVED &&
-           event.MouseInput.isRightPressed() && getItemAtPos(m_pointer).i != getItemAtPos(m_old_pointer).i)){
+   if(event.EventType == EET_MOUSE_INPUT_EVENT &&
+           (event.MouseInput.Event != EMIE_MOUSE_MOVED ||
+            (event.MouseInput.Event == EMIE_MOUSE_MOVED &&
+             event.MouseInput.isRightPressed() &&
+             getItemAtPos(m_pointer).i != getItemAtPos(m_old_pointer).i)) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, you're right

@ShadowNinja ShadowNinja added @ Client / Audiovisuals @ Startup / Config / Util Maintenance Tasks to keep the codebase and related parts in order, including architectural improvements and removed @ Client / Audiovisuals labels Oct 8, 2014
@ShadowNinja
Copy link
Member

914f850

@ShadowNinja ShadowNinja closed this Oct 8, 2014
@Zeno- Zeno- deleted the mouse_input_bugfix branch December 6, 2014 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintenance Tasks to keep the codebase and related parts in order, including architectural improvements @ Startup / Config / Util
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants