Skip to content

Commit

Permalink
sdlwindow.cpp: close m_thread w/o std::terminate being called
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkautarch committed Oct 24, 2024
1 parent 056b79e commit 5cdf460
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Backends/SDLBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace gamescope
GAMESCOPE_SDL_EVENT_CURSOR,

GAMESCOPE_SDL_EVENT_COUNT,
GAMESCOPE_SDL_EVENT_REQ_EXIT,
};

class CSDLConnector final : public IBackendConnector
Expand Down Expand Up @@ -113,6 +114,7 @@ namespace gamescope
{
public:
CSDLBackend();
~CSDLBackend();

/////////////
// IBackend
Expand Down Expand Up @@ -515,6 +517,11 @@ namespace gamescope
// Do nothing.
}

CSDLBackend::~CSDLBackend() {
PushUserEvent(GAMESCOPE_SDL_EVENT_REQ_EXIT);
m_SDLThread.join();
}

void CSDLBackend::SDLThreadFunc()
{
pthread_setname_np( pthread_self(), "gamescope-sdl" );
Expand Down Expand Up @@ -912,6 +919,9 @@ namespace gamescope

SDL_SetCursor( m_pCursor );
}
else if ( event.type == GetUserEventIndex( GAMESCOPE_SDL_EVENT_REQ_EXIT ) ) {
return;
}
}
break;
}
Expand Down

0 comments on commit 5cdf460

Please sign in to comment.