Commit 20e629fc authored by Thomas Baumgart's avatar Thomas Baumgart
Browse files

Don't crash when editing the base currency

Using Tools/Currencies on the selected base currency and hitting Enter
caused a crash. This patch avoids the crash.

BUG: 390658
FIXED-IN: 5.0.1
parent 887c69c4
......@@ -19,6 +19,7 @@
// QT Includes
#include <QMenu>
#include <QDebug>
// ----------------------------------------------------------------------------
// KDE Includes
......@@ -221,7 +222,6 @@ void EquitiesModel::load()
/**
* Notify the model that an object has been added. An action is performed only if the object is an account.
*
*/
void EquitiesModel::slotObjectAdded(eMyMoney::File::Object objType, const MyMoneyObject * const obj)
{
......@@ -255,7 +255,6 @@ void EquitiesModel::slotObjectAdded(eMyMoney::File::Object objType, const MyMone
/**
* Notify the model that an object has been modified. An action is performed only if the object is an account.
*
*/
void EquitiesModel::slotObjectModified(eMyMoney::File::Object objType, const MyMoneyObject * const obj)
{
......@@ -274,6 +273,10 @@ void EquitiesModel::slotObjectModified(eMyMoney::File::Object objType, const MyM
case eMyMoney::File::Object::Security:
{
auto sec = dynamic_cast<const MyMoneySecurity * const>(obj);
// in case we hit a currency, we simply bail out here
// as there is nothing to do for us
if(sec->isCurrency())
return;
itAcc = d->itemFromId(this, sec->id(), Role::SecurityID);
if (!itAcc)
return;
......@@ -286,6 +289,11 @@ void EquitiesModel::slotObjectModified(eMyMoney::File::Object objType, const MyM
}
auto itParentAcc = d->itemFromId(this, acc.parentAccountId(), Role::InvestmentID);
// in case something went wrong, we bail out
if(itParentAcc == nullptr) {
qWarning() << "EquitiesModel::slotObjectModified: itParentAcc == 0";
return;
}
auto modelID = itParentAcc->data(Role::InvestmentID).toString(); // get parent account from model
if (modelID == acc.parentAccountId()) { // and if it matches with those from file then modify only
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment