Graphics window freezes when minimizing, maximizing or quitting

Hello there, I’ve recently encountered a problem where my graphics window (besides the console output) freezes and becomes unusable after minimizing, maximizing, closing (attempt), or dragging it.

My program is wrapped in a structure where there is a “Main.cpp” file which contains a “while-loop” that stops running if the boolean “isRunning” is set to false.
This loop continuously calls the “handleEvents” method in another file.
The “handleEvents” method looks like this.

//Aforementioned while-loop
while (game->running()) {
		game->setFrameStart();

		game->handleEvents();
		game->update();
		game->render();

		game->computeFrameTime();

		game->runFrameDelay();
	}
//HandleEvents Method
void Game::handleEvents() {

	SDL_Event event;
	SDL_PollEvent(&event);

	if (event.type == SDL_QUIT) {
		isRunning = false;
		SDL_DestroyWindow(window);
		printf("Quitting");
	}

}

I’ve been in forums where people have encountered similar problems caused by them not polling events properly or not at all, but as seen above, I am indeed doing so.
Furthermore I’ve not been able to find any articles at all that match my problem.

I would greatly appreciate any help, also this is my first post here, so please, if I did something wrong do remind me of it.

Which is your platform? (Windows, Mac, Linux, HTML5, …)

Generally speaking, it is recommended to process multiple events at once by putting SDL_PollEvent inside a loop as we can see in SDL_PollEvent - SDL Wiki' It seems your runFrameDelay() function waiting for a frame for each single events; but events can happen multiple times in a frame.

I guess the first thing that needs to be ensured is making sure we’re calling SDL_PollEvent. I’d insert some printf()s to ensure we’re still calling SDL_PollEvent() correctly on that case.

Like @OKUMURA_Yuki said, multiple events can come in each frame, so change your code to

void Game::handleEvents() {

	SDL_Event event;
	while(SDL_PollEvent(&event)) {
		if (event.type == SDL_QUIT) {
			isRunning = false;
			SDL_DestroyWindow(window);
			printf("Quitting");
		}
	}
}

@OKUMURA_Yuki @sjr
I took in both of your ideas and it works now! I highly appreciate it and cheers!