mirror of
				https://github.com/libsdl-org/SDL.git
				synced 2025-11-04 01:34:38 +00:00 
			
		
		
		
	Make sure we call SDL_Quit() before SDLTest_CommonDestroyState()
Otherwise we'll report leaks that will be cleaned up in SDL_Quit()
This commit is contained in:
		@@ -156,6 +156,8 @@ SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, SDL_InitFlags flags)
 | 
				
			|||||||
/**
 | 
					/**
 | 
				
			||||||
 * Free the common state object.
 | 
					 * Free the common state object.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 | 
					 * You should call SDL_Quit() before calling this function.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 * \param state The common state object to destroy
 | 
					 * \param state The common state object to destroy
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
void SDLTest_CommonDestroyState(SDLTest_CommonState *state);
 | 
					void SDLTest_CommonDestroyState(SDLTest_CommonState *state);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -134,6 +134,7 @@ void SDL_AppQuit(void *appstate)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    SDL_DestroyAudioStream(stream);
 | 
					    SDL_DestroyAudioStream(stream);
 | 
				
			||||||
    SDL_free(wave.sound);
 | 
					    SDL_free(wave.sound);
 | 
				
			||||||
 | 
					    SDL_Quit();
 | 
				
			||||||
    SDLTest_CommonDestroyState(state);
 | 
					    SDLTest_CommonDestroyState(state);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -210,8 +210,8 @@ void SDL_AppQuit(void *appstate)
 | 
				
			|||||||
    SDL_DestroyAudioStream(stream_out);
 | 
					    SDL_DestroyAudioStream(stream_out);
 | 
				
			||||||
    SDL_DestroyRenderer(renderer);
 | 
					    SDL_DestroyRenderer(renderer);
 | 
				
			||||||
    SDL_DestroyWindow(window);
 | 
					    SDL_DestroyWindow(window);
 | 
				
			||||||
    SDLTest_CommonDestroyState(state);
 | 
					 | 
				
			||||||
    SDL_Quit();
 | 
					    SDL_Quit();
 | 
				
			||||||
 | 
					    SDLTest_CommonDestroyState(state);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -74,6 +74,7 @@ int SDL_AppInit(void **appstate, int argc, char *argv[])
 | 
				
			|||||||
                NULL,
 | 
					                NULL,
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
            SDLTest_CommonLogUsage(state, argv[0], options);
 | 
					            SDLTest_CommonLogUsage(state, argv[0], options);
 | 
				
			||||||
 | 
					            SDL_Quit();
 | 
				
			||||||
            SDLTest_CommonDestroyState(state);
 | 
					            SDLTest_CommonDestroyState(state);
 | 
				
			||||||
            return 1;
 | 
					            return 1;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2243,6 +2243,7 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    result = run_test() ? 0 : 1;
 | 
					    result = run_test() ? 0 : 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SDL_Quit();
 | 
				
			||||||
    SDLTest_CommonDestroyState(state);
 | 
					    SDLTest_CommonDestroyState(state);
 | 
				
			||||||
    return result;
 | 
					    return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -58,6 +58,7 @@ iostrm_error_quit(unsigned line, SDL_IOStream *iostrm)
 | 
				
			|||||||
        SDL_CloseIO(iostrm);
 | 
					        SDL_CloseIO(iostrm);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    cleanup();
 | 
					    cleanup();
 | 
				
			||||||
 | 
					    SDL_Quit();
 | 
				
			||||||
    SDLTest_CommonDestroyState(state);
 | 
					    SDLTest_CommonDestroyState(state);
 | 
				
			||||||
    exit(1); /* quit with iostrm error (test failed) */
 | 
					    exit(1); /* quit with iostrm error (test failed) */
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -483,8 +483,8 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
    status += Test64Bit(verbose);
 | 
					    status += Test64Bit(verbose);
 | 
				
			||||||
    status += TestCPUInfo(verbose);
 | 
					    status += TestCPUInfo(verbose);
 | 
				
			||||||
    status += TestAssertions(verbose);
 | 
					    status += TestAssertions(verbose);
 | 
				
			||||||
    SDL_Quit();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SDL_Quit();
 | 
				
			||||||
    SDLTest_CommonDestroyState(state);
 | 
					    SDLTest_CommonDestroyState(state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return status;
 | 
					    return status;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -135,6 +135,7 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
        test_sort("random sorted", nums, arraylen);
 | 
					        test_sort("random sorted", nums, arraylen);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SDL_Quit();
 | 
				
			||||||
    SDLTest_CommonDestroyState(state);
 | 
					    SDLTest_CommonDestroyState(state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -171,8 +171,8 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    SDL_Log("Reader threads have terminated, quitting!");
 | 
					    SDL_Log("Reader threads have terminated, quitting!");
 | 
				
			||||||
    SDL_DestroyRWLock(rwlock);
 | 
					    SDL_DestroyRWLock(rwlock);
 | 
				
			||||||
    SDLTest_CommonDestroyState(state);
 | 
					 | 
				
			||||||
    SDL_Quit();
 | 
					    SDL_Quit();
 | 
				
			||||||
 | 
					    SDLTest_CommonDestroyState(state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -72,6 +72,7 @@ int main(int argc, char **argv)
 | 
				
			|||||||
    SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
 | 
					    SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
 | 
					    if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
 | 
				
			||||||
 | 
					        SDL_Quit();
 | 
				
			||||||
        SDLTest_CommonDestroyState(state);
 | 
					        SDLTest_CommonDestroyState(state);
 | 
				
			||||||
        return 1;
 | 
					        return 1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -79,6 +80,7 @@ int main(int argc, char **argv)
 | 
				
			|||||||
    /* Load the SDL library */
 | 
					    /* Load the SDL library */
 | 
				
			||||||
    if (SDL_Init(SDL_INIT_SENSOR) < 0) {
 | 
					    if (SDL_Init(SDL_INIT_SENSOR) < 0) {
 | 
				
			||||||
        SDL_Log("Couldn't initialize SDL: %s\n", SDL_GetError());
 | 
					        SDL_Log("Couldn't initialize SDL: %s\n", SDL_GetError());
 | 
				
			||||||
 | 
					        SDL_Quit();
 | 
				
			||||||
        SDLTest_CommonDestroyState(state);
 | 
					        SDLTest_CommonDestroyState(state);
 | 
				
			||||||
        return 1;
 | 
					        return 1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -149,6 +149,7 @@ int main(int argc, char **argv)
 | 
				
			|||||||
    SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
 | 
					    SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
 | 
					    if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
 | 
				
			||||||
 | 
					        SDL_Quit();
 | 
				
			||||||
        SDLTest_CommonDestroyState(state);
 | 
					        SDLTest_CommonDestroyState(state);
 | 
				
			||||||
        return 1;
 | 
					        return 1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,8 +28,8 @@ static SDLTest_CommonState *state;
 | 
				
			|||||||
static void
 | 
					static void
 | 
				
			||||||
quit(int rc)
 | 
					quit(int rc)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    SDLTest_CommonDestroyState(state);
 | 
					 | 
				
			||||||
    SDL_Quit();
 | 
					    SDL_Quit();
 | 
				
			||||||
 | 
					    SDLTest_CommonDestroyState(state);
 | 
				
			||||||
    /* Let 'main()' return normally */
 | 
					    /* Let 'main()' return normally */
 | 
				
			||||||
    if (rc != 0) {
 | 
					    if (rc != 0) {
 | 
				
			||||||
        exit(rc);
 | 
					        exit(rc);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -396,6 +396,7 @@ int main(int argc, char **argv)
 | 
				
			|||||||
                NULL,
 | 
					                NULL,
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
            SDLTest_CommonLogUsage(state, argv[0], options);
 | 
					            SDLTest_CommonLogUsage(state, argv[0], options);
 | 
				
			||||||
 | 
					            SDL_Quit();
 | 
				
			||||||
            SDLTest_CommonDestroyState(state);
 | 
					            SDLTest_CommonDestroyState(state);
 | 
				
			||||||
            return 1;
 | 
					            return 1;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -98,6 +98,7 @@ int main(int argc, char *argv[])
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
 | 
					    if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
 | 
				
			||||||
 | 
					        SDL_Quit();
 | 
				
			||||||
        SDLTest_CommonDestroyState(state);
 | 
					        SDLTest_CommonDestroyState(state);
 | 
				
			||||||
        return 1;
 | 
					        return 1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user