Skip to content

Commit

Permalink
Fix for crash on create new recipe. Plus more on Windows signing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Young committed Sep 24, 2024
1 parent 449b9b1 commit 62c04e5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 43 deletions.
57 changes: 26 additions & 31 deletions .signpath/artifact-configurations/default.xml
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>
35 changes: 23 additions & 12 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2506,15 +2506,11 @@ void MainWindow::editYeastOfSelectedYeastAddition() {
return;
}

void MainWindow::newRecipe()
{
QString name = QInputDialog::getText(this, tr("Recipe name"),
tr("Recipe name:"));
QVariant defEquipKey = PersistentSettings::value(PersistentSettings::Names::defaultEquipmentKey, -1);
QObject* selection = sender();

if( name.isEmpty() )
void MainWindow::newRecipe() {
QString const name = QInputDialog::getText(this, tr("Recipe name"), tr("Recipe name:"));
if (name.isEmpty()) {
return;
}

std::shared_ptr<Recipe> newRec = std::make_shared<Recipe>(name);

Expand All @@ -2526,17 +2522,31 @@ void MainWindow::newRecipe()
return;
}
ObjectStoreWrapper::insert(newRec);
std::shared_ptr<Boil> newBoil = std::make_shared<Boil>(QString("Boil for %1").arg(name));

//
// .:TODO:. For the moment, we still assume that every Recipe has a Boil and a Fermentation. Also, for the moment,
// we also create a new boil and fermentation for every Recipe. In time, I'd like to extend the UI so that, when you
// input the name for your new Recipe, you also select Mash, Boil, Fermentation (all either from "List of existing"
// or "Make new").
//
std::shared_ptr<Boil> newBoil = std::make_shared<Boil>(tr("Automatically-created Boil for %1").arg(name));
// NB: Recipe::setBoil will ensure Boil is stored in the database
newRec->setBoil(newBoil);
ObjectStoreWrapper::insert(newBoil);
// Since we're auto-creating a Boil, it might as well start out with the "standard" profile
newBoil->ensureStandardProfile();

std::shared_ptr<Fermentation> newFermentation = std::make_shared<Fermentation>(tr("Automatically-created Fermentation for %1").arg(name));
// NB: Recipe::setFermentation will ensure Fermentation is stored in the database
newRec->setFermentation(newFermentation);

// Set the following stuff so everything appears nice
// and the calculations don't divide by zero... things like that.
newRec->setBatchSize_l(18.93); // 5 gallons
newBoil->setPreBoilSize_l(23.47); // 6.2 gallons
newRec->setEfficiency_pct(70.0);

// we need a valid key, so insert the recipe before we add equipment
// We need a valid key, so insert the recipe before we add equipment
QVariant const defEquipKey = PersistentSettings::value(PersistentSettings::Names::defaultEquipmentKey, -1);
if (defEquipKey != -1) {
auto equipment = ObjectStoreWrapper::getById<Equipment>(defEquipKey.toInt());
// I really want to do this before we've written the object to the
Expand All @@ -2549,8 +2559,9 @@ void MainWindow::newRecipe()
}
}

// a new recipe will be put in a folder if you right click on a recipe or
// A new recipe will be put in a folder if you right click on a recipe or
// folder. Otherwise, it goes into the main window?
QObject* selection = this->sender();
if (selection) {
TreeView* sent = qobject_cast<TreeView*>(tabWidget_Trees->currentWidget()->focusWidget());
if (sent) {
Expand Down

0 comments on commit 62c04e5

Please sign in to comment.