mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Merge pull request #6945 from spycrab/qt_sighandler
Qt/Unix: Implement signal handler
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
|
||||
// Copyright 2015 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
@ -20,6 +19,12 @@
|
||||
#include <future>
|
||||
#include <optional>
|
||||
|
||||
#if defined(__unix__) || defined(__unix) || defined(__APPLE__)
|
||||
#include <signal.h>
|
||||
|
||||
#include "QtUtils/SignalDaemon.h"
|
||||
#endif
|
||||
|
||||
#include "Common/Version.h"
|
||||
|
||||
#include "Core/Boot/Boot.h"
|
||||
@ -86,6 +91,23 @@
|
||||
#include "UICommon/X11Utils.h"
|
||||
#endif
|
||||
|
||||
#if defined(__unix__) || defined(__unix) || defined(__APPLE__)
|
||||
void MainWindow::OnSignal()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
static void InstallSignalHandler()
|
||||
{
|
||||
struct sigaction sa;
|
||||
sa.sa_handler = &SignalDaemon::HandleInterrupt;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = SA_RESETHAND;
|
||||
sigaction(SIGINT, &sa, nullptr);
|
||||
sigaction(SIGTERM, &sa, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
MainWindow::MainWindow(std::unique_ptr<BootParameters> boot_parameters) : QMainWindow(nullptr)
|
||||
{
|
||||
setWindowTitle(QString::fromStdString(Common::scm_rev_str));
|
||||
@ -109,6 +131,14 @@ MainWindow::MainWindow(std::unique_ptr<BootParameters> boot_parameters) : QMainW
|
||||
|
||||
NetPlayInit();
|
||||
|
||||
#if defined(__unix__) || defined(__unix) || defined(__APPLE__)
|
||||
auto* daemon = new SignalDaemon(this);
|
||||
|
||||
connect(daemon, &SignalDaemon::InterruptReceived, this, &MainWindow::OnSignal);
|
||||
|
||||
InstallSignalHandler();
|
||||
#endif
|
||||
|
||||
if (boot_parameters)
|
||||
m_pending_boot = std::move(boot_parameters);
|
||||
|
||||
|
Reference in New Issue
Block a user