PRZYGWOŹDZIŁEM BUGA SKURWYSYNA!
Chwalić Swaroga, że aplikacja w kompilacji Debug też się wywalała. W takim wypadku wiadomo było co robić, attach Qt Creatora do procesu, i przeszukanie stosu - tym razem było pokazane gdzie w moim kodzie się posypało. Oto co się okazało - miałem sobie taką klasę:
class CostCalculator
{
public:
CostCalculator(unsigned int baseCost);
~CostCalculator() = default;
unsigned int calculateCost() const;
void equipmentCostChange(int itemCostDelta);
void armorCostChange(int armorAmountDelta);
void operator=(const CostCalculator &other);
private:
static unsigned int adjustmentThreshold;
static unsigned int armorCostPerPoint;
unsigned int baseCost = 0;
unsigned int totalEquipmentCost = 0;
unsigned int totalArmor = 0;
};
//i .cpp
#include "costcalculator.h"
unsigned int CostCalculator::adjustmentThreshold = SettingsFileDatabase::getInstance().getCostAlignmentThreshold();
unsigned int CostCalculator::armorCostPerPoint = GameConstantsDatabase::getInstance().getArmorCostPerPoint();
CostCalculator::CostCalculator(unsigned int baseCost)
:baseCost(baseCost)
{
}
void CostCalculator::operator=(const CostCalculator &other)
{
baseCost = other.baseCost;
totalArmor = other.totalArmor;
totalEquipmentCost = other.totalEquipmentCost;
}
unsigned int CostCalculator::calculateCost() const
{
uint cost = baseCost + totalEquipmentCost;
cost += totalArmor * armorCostPerPoint;
//adjust the cost up to nearest threshold
cost = ceil((double)cost / (double)adjustmentThreshold) * adjustmentThreshold;
return cost;
}
void CostCalculator::equipmentCostChange(int itemCostDelta)
{
totalEquipmentCost += itemCostDelta;
}
void CostCalculator::armorCostChange(int armorAmountDelta)
{
totalArmor += armorAmountDelta;
}
Owe Database to leniwe singletony, tworzone kiedy po raz pierwszy wywoła się getInstance():
SettingsFileDatabase& SettingsFileDatabase::getInstance()
{
static SettingsFileDatabase manager;
return manager;
}
i to owe zmienne adjustmentThreshold oraz armorCostPerPoint przy zdefiniowaniu jako static powodują wywrotkę aplikacji. Jak dałem je jako zwykłe pola klasy, inicjowane w konstruktorze to problem ustąpił.
Co jeszcze - flaga kompilacji jakiej używam w .pro
Release: QMAKE_CXXFLAGS += -O3 -mpreferred-stack-boundary=2 -finline-small-functions -momit-leaf-frame-pointer