Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: crash message popping up when (stupid) software crashes at exit #5

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.25 FATAL_ERROR)
# Create project
project(sdk_launcher
DESCRIPTION "A minimal SDK launcher for Strata Source engine games"
VERSION "0.4.1"
VERSION "0.4.2"
HOMEPAGE_URL "https://github.com/StrataSource/sdk-launcher")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down Expand Up @@ -103,6 +103,7 @@ function(sdk_launcher_configure_target TARGET)
endfunction()

# miniz
set(BUILD_NO_STDIO ON CACHE INTERNAL "" FORCE)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/ext/miniz")

# Qt
Expand Down
2 changes: 1 addition & 1 deletion ext/miniz
11 changes: 8 additions & 3 deletions src/Window.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "Window.h"

#include <chrono>
#include <QApplication>
#include <QDesktopServices>
#include <QDir>
Expand All @@ -13,7 +14,6 @@
#include <QSettings>
#include <QStyle>
#include <QStyleHints>
#include <QToolButton>
#include <QVBoxLayout>

#include "Config.h"
Expand Down Expand Up @@ -306,16 +306,21 @@ void Window::loadGameConfig(const QString& path) {
button->setToolTip(action + " " + entry.arguments.join(" "));
QObject::connect(button, &LaunchButton::doubleClicked, this, [this, action, args=entry.arguments, cwd=rootPath] {
auto* process = new QProcess;
QObject::connect(process, &QProcess::errorOccurred, this, [this](QProcess::ProcessError code) {
QObject::connect(process, &QProcess::errorOccurred, this, [this, timeStart = std::chrono::steady_clock::now()](QProcess::ProcessError code) {
QString error;
switch (code) {
using enum QProcess::ProcessError;
case FailedToStart:
error = tr("The process failed to start. Perhaps the executable it points to might not exist?");
break;
case Crashed:
case Crashed: {
auto timeEnd = std::chrono::steady_clock::now();
if (std::chrono::duration<float, std::milli>(timeEnd - timeStart).count() > 30'000) {
return;
}
error = tr("The process crashed.");
break;
}
case Timedout:
error = tr("The process timed out.");
break;
Expand Down
Loading