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 for crash when editing fermentation ages #786

Merged
merged 12 commits into from
Jan 19, 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
16 changes: 9 additions & 7 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# .github/workflows/windows.yml is part of Brewtarget, and is copyright the following authors 2021-2023:
# .github/workflows/windows.yml is part of Brewtarget, and is copyright the following authors 2021-2024:
# • Artem Martynov <[email protected]>
# • Chris Speck <[email protected]>
# • Mattias Måhl <[email protected]>
Expand Down Expand Up @@ -41,9 +41,14 @@ jobs:
fail-fast: false
matrix:
include: [
# Current installer NSIS with required plugins don't support x64 package
#{ msystem: MINGW64, arch: x86_64 },
{ msystem: MINGW32, arch: i686 }
# In the past, we built only 32-bit packages (i686 architecture) on Windows because of problems getting 64-bit
# versions of NSIS plugins to work. However, we now invoke NSIS without plugins, so the 64-bit build seems to
# be working.
#
# As of January 2024, some of the 32-bit MSYS2 packages/groups we were previously relying on previously are no
# longer available. So now, we only build 64-bit packages (x86_64 architecture) on Windows.
{ msystem: MINGW64, arch: x86_64 },
#{ msystem: MINGW32, arch: i686 }
]
steps:

Expand Down Expand Up @@ -159,9 +164,6 @@ jobs:
./configure
cd build
rm CMakeCache.txt
cp ./nsis/Locate/Include/Locate.nsh /mingw32/share/nsis/Include/
cp ./nsis/Locate/Plugin/locate.dll /mingw32/share/nsis/Plugins/ansi/
cp ./nsis/Nsislog/plugin/nsislog.dll /mingw32/share/nsis/Plugins/ansi
cmake .. -DCMAKE_RC_COMPILER:FILEPATH=windres.exe -G "MinGW Makefiles"

# The pwd and find ../third-party commands below are just diagnostics, but it's generally useful to have too
Expand Down
717 changes: 8 additions & 709 deletions CMakeLists.txt

Large diffs are not rendered by default.

101 changes: 83 additions & 18 deletions bt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
# bt is part of Brewtarget, and is copyright the following authors 2022-2023:
# bt is part of Brewtarget, and is copyright the following authors 2022-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
Expand All @@ -16,7 +16,11 @@
#

#-----------------------------------------------------------------------------------------------------------------------
# This build tool (bt) script helps with Git setup, meson build configuration and packaging. Usage is:
# This build tool (bt) script helps with Git setup, meson build configuration and packaging. You need to have Python
# 3.10 or newer installed first. On Windows you also need to have Pip installed and to do some extra manual stuff noted
# below.
#
# Usage is:
#
# ./bt setup Sets up Git options and configures the 'mbuild' meson build directory
#
Expand All @@ -27,7 +31,8 @@
# need to be for a local install). Then creates a distributable package, making use
# of various build variables passed back from Meson.
#
#
# NOTE: This tool, used in conjunction with Meson, is now the official way to build and package the software. We
# continue to support CMake for local compiles and installs, but not for packaging.
#
# .:TODO:. At some point we should be able to retire:
# configure
Expand All @@ -42,6 +47,42 @@
# double quotes avoids having to escape a single quote.
#-----------------------------------------------------------------------------------------------------------------------

#-----------------------------------------------------------------------------------------------------------------------
# **********************************************************************************************************************
# *
# * WINDOWS USERS PLEASE NOTE that, on Windows, we assume you are running in the MSYS2 MINGW32 environment. This is one
# * of, typically, four different environments available to you after installing MSYS2. You must run this script from
# * the "MSYS2 MinGW 64-bit" shell, and not one of the other ones. (As of 2024-01, we no longer support 32-bit builds
# * because some libraries we rely on are no longer available as 32-bit MSYS2 packages.)
# *
# * Additionally on Windows, there are also a couple of extra things you need to do before running this bt script:
# *
# * - For historical reasons, Linux and other platforms need to run both Python v2 (still used by some bits of
# * system) and Python v3 (eg that you installed yourself) so there are usually two corresponding Python
# * executables, python2 and python3. On Windows there is only whatever Python you installed and it's called
# * python.exe. To keep the shebang in the bt script working, we just make a softlink to python called python3:
# *
# * if [[ ! -f $(dirname $(which python))/python3 ]]; then ln -s $(which python) $(dirname $(which python))/python3; fi
# *
# * - Getting Unicode input/output to work is fun. We should already have a Unicode locale, but it seems we also
# * need to set PYTHONIOENCODING (see https://docs.python.org/3/using/cmdline.html#envvar-PYTHONIOENCODING, even
# * though it seems to imply you don't need to set it on recent versions of Python).
# *
# * export PYTHONIOENCODING=utf8
# *
# * - The version of Pip we install above does not put it in the "right" place. Specifically it will not be in the
# * PATH when we run bt. The following seems to be the least hacky way around this:
# *
# * curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
# * python get-pip.py
# * python -m pip install -U --force-reinstall pip
# * rm get-pip.py
# *
# * See https://stackoverflow.com/questions/48087004/installing-pip-on-msys for more discussion on this.
# *
# **********************************************************************************************************************
#-----------------------------------------------------------------------------------------------------------------------

#-----------------------------------------------------------------------------------------------------------------------
# Python built-in modules we use
#-----------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -670,12 +711,17 @@ def installDependencies():
# We just need the bit before the first underscore, eg
# MINGW64
terminalVersion = unameResult.split(sep='_', maxsplit=1)[0]
if (terminalVersion != 'MINGW32'):
# One day we'll try to get the 64-bit build working on Windows. I think it's just the packaging step that's
# the problem. For now, it's easier to insist on 32-bit at set-up. (Obviously 32-bit apps run just fine on
# 64-bit Windows. I don't think there would be any noticeable difference to the end user in having a 64-bit
# version of the app.)
log.critical('Running in ' + terminalVersion + ' but need to run in MINGW32 (ie 32-bit build environment)')
## if (terminalVersion != 'MINGW32'):
## # One day we'll try to get the 64-bit build working on Windows. I think it's just the packaging step that's
## # the problem. For now, it's easier to insist on 32-bit at set-up. (Obviously 32-bit apps run just fine on
## # 64-bit Windows. I don't think there would be any noticeable difference to the end user in having a 64-bit
## # version of the app.)
## log.critical('Running in ' + terminalVersion + ' but need to run in MINGW32 (ie 32-bit build environment)')
## exit(1)
if (terminalVersion != 'MINGW64'):
# Support for 32-bit packages in MSYS2 is getting patchy, so we finally had to bite the bullet and get the
# 64-bit build working. This means we are stopping support of the 32-bit build.
log.critical('Running in ' + terminalVersion + ' but need to run in MINGW64 (ie 64-bit build environment)')
exit(1)

log.info('Ensuring required libraries and frameworks are installed')
Expand All @@ -697,7 +743,11 @@ def installDependencies():
# debugging a bit harder when there is a pacman problem, because it doesn't always give the most explanatory
# error messages. So we loop round and install one thing at a time.
#
arch = 'i686'
# Note that the --disable-download-timeout option on Pacman proved often necessary because of slow mirror
# sites, so we now specify it routinely.
#
## arch = 'i686'
arch = 'x86_64'
installList = ['base-devel',
'cmake',
'coreutils',
Expand All @@ -709,6 +759,8 @@ def installDependencies():
'mingw-w64-' + arch + '-libbacktrace',
'mingw-w64-' + arch + '-meson',
'mingw-w64-' + arch + '-nsis',
'mingw-w64-' + arch + '-qt5-base',
'mingw-w64-' + arch + '-qt5-static',
'mingw-w64-' + arch + '-qt5',
'mingw-w64-' + arch + '-toolchain',
'mingw-w64-' + arch + '-xalan-c',
Expand All @@ -717,7 +769,7 @@ def installDependencies():
log.debug('Installing ' + packageToInstall)
abortOnRunFail(
subprocess.run(
['pacman', '-S', '--needed', '--noconfirm', packageToInstall]
['pacman', '-S', '--needed', '--noconfirm', '--disable-download-timeout', packageToInstall]
)
)

Expand Down Expand Up @@ -1018,9 +1070,9 @@ def doPackage():
# designed etc.)
#
# At first, this seemed disappointing, but I've rather come around to thinking a different way about it. Although
# CPack has lots of features it is also very painful to use. Some of the things you can do are undocumented; some of
# the things you want to be able to do seem nigh on impossible. So perhaps taking a completely different approach,
# eg using a scripting language rather than a build tool to do packaging, is ultimately a good thing.
# CPack has lots of features, it is also very painful to use. Some of the things you can do are undocumented; some
# of the things you want to be able to do seem nigh on impossible. So perhaps taking a completely different
# approach, eg using a scripting language rather than a build tool to do packaging, is ultimately a good thing.
#
# I spent some time looking at and trying to use the Qt-Installer-Framework (QtIFW). Upsides are:
# - In principle we could write one set of install config that would then create install packages for Windows, Mac
Expand Down Expand Up @@ -1054,8 +1106,8 @@ def doPackage():
# https://blog.devgenius.io/how-to-build-debian-packages-from-meson-ninja-d1c28b60e709 gives some sketchy
# starting info on how to build deb packages. Maybe we could find the equivalent for creating RPMs. Also look
# at https://openbuildservice.org/.
# - For Windows, we could probably use NSIS (Nullsoft Scriptable Install System -- see
# https://nsis.sourceforge.io/) -- or similar to create a Windows installer.
# - For Windows, we use NSIS (Nullsoft Scriptable Install System -- see https://nsis.sourceforge.io/) -- to create
# a Windows installer.
#
# Although a lot of packaging is platform-specific, the initial set-up is generic.
#
Expand Down Expand Up @@ -1217,7 +1269,7 @@ def doPackage():
#
# Debian and RPM both want the debugging information stripped from the executable.
#
# .:TBD:. One day perhaps we could be friendlyi and still ship the debugging info, just in a separate .dbg
# .:TBD:. One day perhaps we could be friendly and still ship the debugging info, just in a separate .dbg
# file. The procedure to do this is described in the 'only-keep-debug' section of `man objcopy`. However, we
# need to work out where to put the .dbg file so that it remains usable but lintian does not complain about it.
#
Expand Down Expand Up @@ -1686,6 +1738,13 @@ def doPackage():
#
# For the moment, we're sticking with NSIS, which is the devil we know, aka what we've historically used.
#
# In the past, we built only 32-bit packages (i686 architecture) on Windows because of problems getting 64-bit
# versions of NSIS plugins to work. However, we now invoke NSIS without plugins, so the 64-bit build seems to
# be working.
#
# As of January 2024, some of the 32-bit MSYS2 packages/groups we were previously relying on previously are no
# longer available. So now, we only build 64-bit packages (x86_64 architecture) on Windows.
#

#
# As mentioned above, not all information about what Meson does is readily exportable. In particular, I can
Expand Down Expand Up @@ -1780,7 +1839,13 @@ def doPackage():
'libbz2', # BZip2 compression -- see https://en.wikipedia.org/wiki/Bzip2
'libdouble-conversion', # See https://github.com/google/double-conversion
'libfreetype', # See https://freetype.org/
'libgcc_s_dw2',
#
# 32-bit and 64-bit MinGW use different exception handling (see
# https://sourceforge.net/p/mingw-w64/wiki2/Exception%20Handling/) hence the different naming of libgcc in
# the 32-bit and 64-bit environments.
#
# 'libgcc_s_dw2', # 32-bit GCC library
'libgcc_s_seh', # 64-bit GCC library
'libglib-2.0',
'libgraphite',
'libharfbuzz', # HarfBuzz text shaping engine -- see https://github.com/harfbuzz/harfbuzz
Expand Down
12 changes: 7 additions & 5 deletions src/RecipeExtrasWidget.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* RecipeExtrasWidget.cpp is part of Brewtarget, and is Copyright the following
* authors 2009-2023
* authors 2009-2024
* - Matt Young <[email protected]>
* - Mik Firestone <[email protected]>
* - Peter Buelow <[email protected]>
Expand Down Expand Up @@ -117,7 +117,9 @@ void RecipeExtrasWidget::updateTasteRating() {

void RecipeExtrasWidget::updatePrimaryAge() {
if (!this->recipe) { return;}
MainWindow::instance().doOrRedoUpdate(*recipe, PropertyNames::Recipe::primaryAge_days, lineEdit_primaryAge->toCanonical().quantity(), tr("Change Primary Age"));
// See comment in model/Recipe.cpp for why age_days, primaryAge_days, secondaryAge_days, tertiaryAge_days properties
// are dimensionless
MainWindow::instance().doOrRedoUpdate(*recipe, PropertyNames::Recipe::primaryAge_days, lineEdit_primaryAge->getNonOptValueAs<double>(), tr("Change Primary Age"));
}

void RecipeExtrasWidget::updatePrimaryTemp() {
Expand All @@ -127,7 +129,7 @@ void RecipeExtrasWidget::updatePrimaryTemp() {

void RecipeExtrasWidget::updateSecondaryAge() {
if (!this->recipe) { return;}
MainWindow::instance().doOrRedoUpdate(*recipe, PropertyNames::Recipe::secondaryAge_days, lineEdit_secAge->toCanonical().quantity(), tr("Change Secondary Age"));
MainWindow::instance().doOrRedoUpdate(*recipe, PropertyNames::Recipe::secondaryAge_days, lineEdit_secAge->getNonOptValueAs<double>(), tr("Change Secondary Age"));
}

void RecipeExtrasWidget::updateSecondaryTemp() {
Expand All @@ -137,7 +139,7 @@ void RecipeExtrasWidget::updateSecondaryTemp() {

void RecipeExtrasWidget::updateTertiaryAge() {
if (!this->recipe) { return;}
MainWindow::instance().doOrRedoUpdate(*recipe, PropertyNames::Recipe::tertiaryAge_days, lineEdit_tertAge->toCanonical().quantity(), tr("Change Tertiary Age"));
MainWindow::instance().doOrRedoUpdate(*recipe, PropertyNames::Recipe::tertiaryAge_days, lineEdit_tertAge->getNonOptValueAs<double>(), tr("Change Tertiary Age"));
}

void RecipeExtrasWidget::updateTertiaryTemp() {
Expand All @@ -147,7 +149,7 @@ void RecipeExtrasWidget::updateTertiaryTemp() {

void RecipeExtrasWidget::updateAge() {
if (!this->recipe) { return;}
MainWindow::instance().doOrRedoUpdate(*recipe, PropertyNames::Recipe::age_days, lineEdit_age->toCanonical().quantity(), tr("Change Age"));
MainWindow::instance().doOrRedoUpdate(*recipe, PropertyNames::Recipe::age_days, lineEdit_age->getNonOptValueAs<double>(), tr("Change Age"));
}

void RecipeExtrasWidget::updateAgeTemp() {
Expand Down
3 changes: 1 addition & 2 deletions src/database/ObjectStore.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* database/ObjectStore.cpp is part of Brewtarget, and is copyright the following
* authors 2021-2023:
* authors 2021-2024:
* • Matt Young <[email protected]>
*
* Brewtarget is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -747,7 +747,6 @@ class ObjectStore::impl {
/// qCritical().noquote() << Q_FUNC_INFO << "Call stack is:" << Logging::getStackTrace();
/// Q_ASSERT(false);
}

}
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/widgets/SmartField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ class SmartField::impl {
Measurement::Amount toCanonical(QString const & enteredText, SmartAmounts::ScaleInfo previousScaleInfo) {
Q_ASSERT(this->m_initialised);

// It's a coding error to call this for a NonPhysicalQuantity
// It's a coding error to call this for a NonPhysicalQuantity. (Instead call getNonOptValueAs<double> or
// similar.)
Q_ASSERT(!std::holds_alternative<NonPhysicalQuantity>(*this->m_typeInfo->fieldType));
Q_ASSERT(this->m_currentPhysicalQuantity);

Expand Down Expand Up @@ -401,6 +402,12 @@ SmartAmounts::ScaleInfo SmartField::getScaleInfo() const {
return SmartAmounts::ScaleInfo{this->pimpl->m_fixedDisplayUnit->getUnitSystem().systemOfMeasurement, std::nullopt};
}

// Only need next bit for debugging!
// if (std::holds_alternative<NonPhysicalQuantity>(*this->pimpl->m_typeInfo->fieldType)) {
// qCritical() << Q_FUNC_INFO << this->pimpl->m_typeInfo;
// qCritical().noquote() << Q_FUNC_INFO << "Stack trace:" << Logging::getStackTrace();
// }

Q_ASSERT(!std::holds_alternative<NonPhysicalQuantity>(*this->pimpl->m_typeInfo->fieldType));
return SmartAmounts::getScaleInfo(this->pimpl->m_editorName,
this->pimpl->m_fieldName,
Expand Down
6 changes: 2 additions & 4 deletions src/widgets/SmartField.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* widgets/SmartField.h is part of Brewtarget, and is copyright the following authors 2009-2023:
* widgets/SmartField.h is part of Brewtarget, and is copyright the following authors 2009-2024:
* • Brian Rower <[email protected]>
* • Mark de Wever <[email protected]>
* • Matt Young <[email protected]>
Expand Down Expand Up @@ -38,8 +38,6 @@
#include "utils/TypeLookup.h"
#include "widgets/SmartAmounts.h"

class QWidget;

class SmartLabel;
class TypeInfo;

Expand All @@ -62,7 +60,7 @@ class TypeInfo;
* / SmartField \
* QLabel / \ \
* / \ / \ \
* SmartLabel SmartDigitWidget SmartField
* SmartLabel SmartDigitWidget SmartLineEdit
*
* A number of helper functions exist in the \c SmartAmounts namespace.
*
Expand Down
29 changes: 0 additions & 29 deletions translations/bt_ca.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2705,35 +2705,6 @@ Log file may contain more details.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QApplication</name>
<message>
<source>Brewtarget is already running!</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Another instance of Brewtarget is already running.

Running two copies of the program at once may lead to data loss.

Press OK to quit.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Application terminates</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The application encountered a fatal error.
Error message:
%1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The application encountered a fatal error.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
Expand Down
Loading