mirror of https://github.com/encounter/SDL.git
Fixed crash if allocating memory for mouse clicks failed.
This commit is contained in:
parent
e64c5186e2
commit
7b23eef3b0
|
@ -358,22 +358,26 @@ SDL_PrivateSendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state
|
||||||
|
|
||||||
if (clicks < 0) {
|
if (clicks < 0) {
|
||||||
SDL_MouseClickState *clickstate = GetMouseClickState(mouse, button);
|
SDL_MouseClickState *clickstate = GetMouseClickState(mouse, button);
|
||||||
if (state == SDL_PRESSED) {
|
if (clickstate) {
|
||||||
Uint32 now = SDL_GetTicks();
|
if (state == SDL_PRESSED) {
|
||||||
|
Uint32 now = SDL_GetTicks();
|
||||||
|
|
||||||
if (SDL_TICKS_PASSED(now, clickstate->last_timestamp + SDL_double_click_time) ||
|
if (SDL_TICKS_PASSED(now, clickstate->last_timestamp + SDL_double_click_time) ||
|
||||||
SDL_abs(mouse->x - clickstate->last_x) > SDL_double_click_radius ||
|
SDL_abs(mouse->x - clickstate->last_x) > SDL_double_click_radius ||
|
||||||
SDL_abs(mouse->y - clickstate->last_y) > SDL_double_click_radius) {
|
SDL_abs(mouse->y - clickstate->last_y) > SDL_double_click_radius) {
|
||||||
clickstate->click_count = 0;
|
clickstate->click_count = 0;
|
||||||
}
|
}
|
||||||
clickstate->last_timestamp = now;
|
clickstate->last_timestamp = now;
|
||||||
clickstate->last_x = mouse->x;
|
clickstate->last_x = mouse->x;
|
||||||
clickstate->last_y = mouse->y;
|
clickstate->last_y = mouse->y;
|
||||||
if (clickstate->click_count < 255) {
|
if (clickstate->click_count < 255) {
|
||||||
++clickstate->click_count;
|
++clickstate->click_count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
clicks = clickstate->click_count;
|
||||||
|
} else {
|
||||||
|
clicks = 1;
|
||||||
}
|
}
|
||||||
clicks = clickstate->click_count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Post the event, if desired */
|
/* Post the event, if desired */
|
||||||
|
|
Loading…
Reference in New Issue