aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorraysan5 <raysan5@gmail.com>2016-06-24 19:34:47 +0200
committerraysan5 <raysan5@gmail.com>2016-06-24 19:34:47 +0200
commita522b6e23b8ef5cb5ffc006320c300f7c7bf191c (patch)
tree13bd1258a697f8dc6527cb6e538f05266e73a1a3 /src
parent03d9583b945dcf17d6a93ed97deeb9f9721284b5 (diff)
downloadraylib-a522b6e23b8ef5cb5ffc006320c300f7c7bf191c.tar.gz
raylib-a522b6e23b8ef5cb5ffc006320c300f7c7bf191c.zip
Corrected issue with unclosed threads
Diffstat (limited to 'src')
-rw-r--r--src/core.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/core.c b/src/core.c
index 1073ae6a..bc195219 100644
--- a/src/core.c
+++ b/src/core.c
@@ -444,7 +444,15 @@ void CloseWindow(void)
eglTerminate(display);
display = EGL_NO_DISPLAY;
- }
+ }
+#endif
+
+#if defined(PLATFORM_RPI)
+ // Wait for mouse and gamepad threads to finish before closing
+ // NOTE: Those threads should already have finished at this point
+ // because they are controlled by windowShouldClose variable
+ pthread_join(mouseThreadId, NULL);
+ pthread_join(gamepadThreadId, NULL);
#endif
TraceLog(INFO, "Window closed successfully");
@@ -1766,12 +1774,12 @@ static void InitGraphics(void)
ClearBackground(RAYWHITE); // Default background color for raylib games :P
#if defined(PLATFORM_ANDROID)
- windowReady = true; // IMPORTANT!
+ windowReady = true; // IMPORTANT!
#endif
}
// Compute framebuffer size relative to screen size and display size
-// NOTE: Global variables renderWidth/renderHeight can be modified
+// NOTE: Global variables renderWidth/renderHeight and renderOffsetX/renderOffsetY can be modified
static void SetupFramebufferSize(int displayWidth, int displayHeight)
{
// TODO: SetupFramebufferSize() does not consider properly display video modes.
@@ -2662,7 +2670,7 @@ static void *MouseThread(void *arg)
int mouseRelX = 0;
int mouseRelY = 0;
- while(1)
+ while (1)
{
if (read(mouseStream, &mouse, sizeof(MouseEvent)) == (int)sizeof(MouseEvent))
{
@@ -2752,7 +2760,7 @@ static void *GamepadThread(void *arg)
// Read gamepad event
struct js_event gamepadEvent;
- while (1)
+ while (!windowShouldClose)
{
for (int i = 0; i < MAX_GAMEPADS; i++)
{
@@ -2787,7 +2795,7 @@ static void *GamepadThread(void *arg)
return NULL;
}
-#endif
+#endif // PLATFORM_RPI
// Plays raylib logo appearing animation
static void LogoAnimation(void)