-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #830 from matty0ung/usability
Fixes for start-up crashes
- Loading branch information
Showing
49 changed files
with
896 additions
and
346 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,36 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
.signpath/artifact-configurations/default.xml is part of Brewtarget | ||
See .github/workflows/windows.yml for more general info on how we use SignPath to sign the Windows binaries | ||
See https://about.signpath.io/documentation/artifact-configuration/ for the syntax for this file | ||
--> | ||
<artifact-configuration xmlns="http://signpath.io/artifact-configuration/v1"> | ||
<!-- | ||
Note, per https://github.com/SignPath/github-action-submit-signing-request, that "the used artifact configuration must | ||
have a zip-file element at its root, as all artifacts are packaged as ZIP archives on GitHub by default." | ||
--> | ||
<zip-file> | ||
<!-- | ||
Prior to the signing step, our build will have generated two files (where x.y.z is the version number - eg 4.0.4): | ||
Brewtarget x.y.z Installer.exe | ||
Brewtarget x.y.z Installer.exe.sha256sum | ||
We want to create a signed version of the first file, and then generate a new checksum for it. | ||
<msi-file path="DemoExample.msi"> | ||
<directory path="application/SignPath Demo"> | ||
|
||
<pe-file-set> | ||
<include path="Microsoft.*.dll" min-matches="0" max-matches="unbounded" /> | ||
<include path="Microsoft.*.exe" min-matches="0" max-matches="unbounded" /> | ||
<for-each> | ||
<authenticode-verify /> | ||
</for-each> | ||
</pe-file-set> | ||
|
||
<pe-file-set> | ||
<include path="Serilog.dll" product-name="Serilog" min-matches="0" /> | ||
<include path="Serilog.AspNetCore.dll" product-name="Serilog" product-version="7.0.0" min-matches="0" /> | ||
</pe-file-set> | ||
|
||
<pe-file-set> | ||
<include path="DemoExample.dll" /> | ||
<include path="DemoExample.exe" /> | ||
<for-each> | ||
<authenticode-sign /> | ||
</for-each> | ||
</pe-file-set> | ||
|
||
</directory> | ||
<authenticode-sign /> | ||
</msi-file> | ||
|
||
<xml-file path="bom.xml" root-element-namespace="http://cyclonedx.org/schema/bom/1.5" root-element-name="bom"> | ||
<xml-sign/> | ||
</xml-file> | ||
Fortunately we don't have to work this out from scratch. By manually uploading an installer to sign, SignPath will | ||
also generate a sample artifact-configuration, which we can then edit as needed. | ||
Because we are only signing a single installer, our configuration is actually very simple. | ||
--> | ||
<pe-file> | ||
<!-- | ||
This means do the signing with Microsoft Authenticode, which is "the primary signing method on the Windows | ||
platform". This is equivalent to using Microsoft’s SignTool.exe. | ||
--> | ||
<authenticode-sign hash-algorithm="sha256" | ||
description="Brewtarget Windows Installer" | ||
description-url="https://www.brewtarget.beer" /> | ||
</pe-file> | ||
</zip-file> | ||
</artifact-configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/*╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ | ||
* database/DbTransaction.cpp is part of Brewtarget, and is copyright the following authors 2021-2022: | ||
* database/DbTransaction.cpp is part of Brewtarget, and is copyright the following authors 2021-2024: | ||
* • Matt Young <[email protected]> | ||
* | ||
* Brewtarget is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License | ||
|
@@ -19,11 +19,15 @@ | |
#include <QSqlError> | ||
|
||
#include "database/Database.h" | ||
#include "Logging.h" | ||
|
||
|
||
DbTransaction::DbTransaction(Database & database, QSqlDatabase & connection, DbTransaction::SpecialBehaviours specialBehaviours) : | ||
DbTransaction::DbTransaction(Database & database, | ||
QSqlDatabase & connection, | ||
QString const nameForLogging, | ||
DbTransaction::SpecialBehaviours specialBehaviours) : | ||
database{database}, | ||
connection{connection}, | ||
nameForLogging{nameForLogging}, | ||
committed{false}, | ||
specialBehaviours{specialBehaviours} { | ||
// Note that, on SQLite at least, turning foreign keys on and off has to happen outside a transaction, so we have to | ||
|
@@ -33,9 +37,12 @@ DbTransaction::DbTransaction(Database & database, QSqlDatabase & connection, DbT | |
} | ||
|
||
bool succeeded = this->connection.transaction(); | ||
qDebug() << Q_FUNC_INFO << "Database transaction begin: " << (succeeded ? "succeeded" : "failed"); | ||
qDebug() << | ||
Q_FUNC_INFO << "Database transaction" << this->nameForLogging << "begin: " << (succeeded ? "succeeded" : "failed"); | ||
if (!succeeded) { | ||
qCritical() << Q_FUNC_INFO << "Unable to start database transaction:" << connection.lastError().text(); | ||
qCritical() << | ||
Q_FUNC_INFO << "Unable to start database transaction" << this->nameForLogging << ":" << connection.lastError().text(); | ||
qCritical().noquote() << Q_FUNC_INFO << Logging::getStackTrace(); | ||
} | ||
return; | ||
} | ||
|
@@ -44,9 +51,11 @@ DbTransaction::~DbTransaction() { | |
qDebug() << Q_FUNC_INFO; | ||
if (!committed) { | ||
bool succeeded = this->connection.rollback(); | ||
qDebug() << Q_FUNC_INFO << "Database transaction rollback: " << (succeeded ? "succeeded" : "failed"); | ||
qDebug() << | ||
Q_FUNC_INFO << "Database transaction" << this->nameForLogging << "rollback: " << (succeeded ? "succeeded" : "failed"); | ||
if (!succeeded) { | ||
qCritical() << Q_FUNC_INFO << "Unable to rollback database transaction:" << connection.lastError().text(); | ||
qCritical() << | ||
Q_FUNC_INFO << "Unable to rollback database transaction" << this->nameForLogging << ":" << connection.lastError().text(); | ||
} | ||
} | ||
|
||
|
@@ -59,9 +68,11 @@ DbTransaction::~DbTransaction() { | |
|
||
bool DbTransaction::commit() { | ||
this->committed = connection.commit(); | ||
qDebug() << Q_FUNC_INFO << "Database transaction commit: " << (this->committed ? "succeeded" : "failed"); | ||
qDebug() << | ||
Q_FUNC_INFO << "Database transaction" << this->nameForLogging << "commit: " << (this->committed ? "succeeded" : "failed"); | ||
if (!this->committed) { | ||
qCritical() << Q_FUNC_INFO << "Unable to commit database transaction:" << connection.lastError().text(); | ||
qCritical() << | ||
Q_FUNC_INFO << "Unable to commit database transaction" << this->nameForLogging << ":" << connection.lastError().text(); | ||
} | ||
return this->committed; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/*╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ | ||
* database/DbTransaction.h is part of Brewtarget, and is copyright the following authors 2021: | ||
* database/DbTransaction.h is part of Brewtarget, and is copyright the following authors 2021-2024: | ||
* • Matt Young <[email protected]> | ||
* | ||
* Brewtarget is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License | ||
|
@@ -34,7 +34,10 @@ class DbTransaction { | |
/** | ||
* \brief Constructing a \c DbTransaction will start a DB transaction | ||
*/ | ||
DbTransaction(Database & database, QSqlDatabase & connection, SpecialBehaviours specialBehaviours = NONE); | ||
DbTransaction(Database & database, | ||
QSqlDatabase & connection, | ||
QString const nameForLogging = "???", | ||
SpecialBehaviours specialBehaviours = NONE); | ||
|
||
/** | ||
* \brief When a \c DbTransaction goes out of scope and its destructor is called, the transaction started in the | ||
|
@@ -53,6 +56,9 @@ class DbTransaction { | |
Database & database; | ||
// This is intended to be a short-lived object, so it's OK to store a reference to a QSqlDatabase object | ||
QSqlDatabase & connection; | ||
// This is useful for diagnosing problems such as | ||
// 'Unable to start database transaction: "cannot start a transaction within a transaction Unable to begin transaction"' | ||
QString const nameForLogging; | ||
bool committed; | ||
int specialBehaviours; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.