Skip to content

Commit

Permalink
Fix coredump(s) at exit
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkautarch committed Jan 5, 2025
1 parent f873ec7 commit 5c2ad3f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 12 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,12 @@ 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 +920,10 @@ namespace gamescope

SDL_SetCursor( m_pCursor );
}
else if ( event.type == GetUserEventIndex( GAMESCOPE_SDL_EVENT_REQ_EXIT ) )
{
return;
}
}
break;
}
Expand Down
3 changes: 1 addition & 2 deletions src/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ namespace gamescope
{
if ( s_pBackend )
{
delete s_pBackend;
s_pBackend = nullptr;
std::destroy_at(s_pBackend);
}

if ( pBackend )
Expand Down

0 comments on commit 5c2ad3f

Please sign in to comment.