mirror of
				https://github.com/raysan5/raylib.git
				synced 2025-11-04 09:44:20 +00:00 
			
		
		
		
	Corrected issue with unclosed threads
This commit is contained in:
		
							
								
								
									
										16
									
								
								src/core.c
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								src/core.c
									
									
									
									
									
								
							@@ -447,6 +447,14 @@ void CloseWindow(void)
 | 
				
			|||||||
    }   
 | 
					    }   
 | 
				
			||||||
#endif
 | 
					#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");
 | 
					    TraceLog(INFO, "Window closed successfully");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1771,7 +1779,7 @@ static void InitGraphics(void)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Compute framebuffer size relative to screen size and display size
 | 
					// 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)
 | 
					static void SetupFramebufferSize(int displayWidth, int displayHeight)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    // TODO: SetupFramebufferSize() does not consider properly display video modes.
 | 
					    // TODO: SetupFramebufferSize() does not consider properly display video modes.
 | 
				
			||||||
@@ -2662,7 +2670,7 @@ static void *MouseThread(void *arg)
 | 
				
			|||||||
    int mouseRelX = 0;
 | 
					    int mouseRelX = 0;
 | 
				
			||||||
    int mouseRelY = 0;
 | 
					    int mouseRelY = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while(1)
 | 
					    while (1)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (read(mouseStream, &mouse, sizeof(MouseEvent)) == (int)sizeof(MouseEvent))
 | 
					        if (read(mouseStream, &mouse, sizeof(MouseEvent)) == (int)sizeof(MouseEvent))
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@@ -2752,7 +2760,7 @@ static void *GamepadThread(void *arg)
 | 
				
			|||||||
    // Read gamepad event
 | 
					    // Read gamepad event
 | 
				
			||||||
    struct js_event gamepadEvent;
 | 
					    struct js_event gamepadEvent;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    while (1) 
 | 
					    while (!windowShouldClose)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        for (int i = 0; i < MAX_GAMEPADS; i++)
 | 
					        for (int i = 0; i < MAX_GAMEPADS; i++)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@@ -2787,7 +2795,7 @@ static void *GamepadThread(void *arg)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    return NULL;
 | 
					    return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif      // PLATFORM_RPI
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Plays raylib logo appearing animation
 | 
					// Plays raylib logo appearing animation
 | 
				
			||||||
static void LogoAnimation(void)
 | 
					static void LogoAnimation(void)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user