problem with csv export in master
Jack
ostroffjh at users.sourceforge.net
Mon Aug 7 23:53:11 BST 2023
While trying to debug the problem recently reported on Discord about
the 5.1.3 csv exporter truncating stock prices to 2 decimal places, I
noticed that the master branch csv export always seem to export the
same account, which is NOT the one I selected. In playing with that
further, if I pick an investment account in the account dropdown, and
then change the separator from tab to comma, I get the popup that the
account is invalid because it doesn't have any items. In trying to
figure out why that happens, I put a qDebug at the beginning of
CsvExportDlg::checkData which prints out the selected account. When I
select the account (any account) with the dropdown, the correct account
name is printed. However, if I make or change the separator
selection, a DIFFERENT account name is selected. So - it turns out I
can export the selected account only if I choose the separator first,
and then the account.
Further, looking at CsvExportDlg::CsvExportDlg, I find the last three
connect commads are:
connect(ui->m_accountComboBox,
qOverload<int>(&QComboBox::currentIndexChanged), this, [this](int idx) {
checkData(ui->m_accountComboBox->itemText(idx));
});
connect(ui->m_separatorComboBox,
QOverload<int>::of(&QComboBox::currentIndexChanged), this, [&](int
index) {
m_separator = m_fieldDelimiterCharList[index];
} );
connect(ui->m_separatorComboBox,
qOverload<int>(&QComboBox::currentIndexChanged), this, [this](int idx) {
checkData(ui->m_accountComboBox->itemText(idx));
});
Commenting out the third out seems to fix the problem of the wrong
account. This might make sense as it looks like that call is
connecting a change of the separator combobox to to calling checkData
with an incorrect account name (using the index of the separator
combobox, not of the account combobox. However, I'm not sure how (or
even if) calling checkData with the "wrong" account name can actually
change which account gets exported, although it is perhaps by selecting
the splits to be exported based on the wrong account.
This post
(https://stackoverflow.com/questions/16794695/connecting-overloaded-signals-and-slots-in-qt-5)
related to the connecting of overloaded functions states that with
C++11 you need QOverload<>::of(...) but with C++14 you need
qOverload<>(...). This makes it look like our code has a mixture of
both types of calls, and I wonder what subtle bugs this may have
introduced.
I'll wait for some feedback before I actually try to fix this, while I
continue to track down why the number of decimal places is truncated to
2 for prices and is too large for prices (which seems to be the same in
5.1 and master.)
Jack
More information about the KMyMoney-devel
mailing list