Skip to content

Commit

Permalink
MainWindow: Fix segfault when calling dtor due to static singleton ob…
Browse files Browse the repository at this point in the history
…ject. Uses static pointer again.
  • Loading branch information
Arne-W committed Mar 11, 2023
1 parent 1fba2b8 commit ba4aff2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/ui/MainWindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,14 @@ void LogWindowSingleton::removeDebugOutput()

MainWindow* MainWindow::instance()
{
static MainWindow myWindow;
return &myWindow;
// This singleton impl. is NOT thread safe. Fortunately we do not need
// thread safety as the first call is always done @ application start.
static MainWindow* instance{nullptr};
if(instance == nullptr)
{
instance = new MainWindow();
}
return instance;
}

// inline function definitions
Expand Down

0 comments on commit ba4aff2

Please sign in to comment.