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

Deal with API changes due to subaddresses, with no visible change #908

Closed
wants to merge 1 commit into from

Conversation

kenshi84
Copy link
Contributor

No description provided.


Monero::SubaddressRow * Subaddress::getRow(int index) const
{
return m_rows.at(index);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need a range test ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Range check was already done in the caller's side, but added a range test anyway.

explicit Subaddress(Monero::Subaddress * subaddressImpl, QObject *parent);
friend class Wallet;
Monero::Subaddress * m_subaddressImpl;
mutable QList<Monero::SubaddressRow*> m_rows;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this mutable ? If it's because addRow/setLabel/refresh is const, then why are those const ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed mutable, and made those member functions non-const.

{
m_subaddressAccountImpl->setLabel(accountIndex, label.toStdString());
getAll(true);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That code looks a lot like code above. Can it be factored ? Especially the getAll functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how they can be refactored. Personally I also don't find them too redundant.

explicit SubaddressAccount(Monero::SubaddressAccount * subaddressAccountImpl, QObject *parent);
friend class Wallet;
Monero::SubaddressAccount * m_subaddressAccountImpl;
mutable QList<Monero::SubaddressAccountRow*> m_rows;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment about mutable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

}

SubaddressModel *Wallet::subaddressModel() const
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this does not return a const SuaddressModel, and it const casts this below, should this const be removed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this member function was made const and the m_subaddressAccountModel member data mutable because m_subaddressAccountModel gets assigned a newly instantiated object when it's pointed to nullptr (i.e., NOT because it returns a non-const SubaddressModel* -- it's perfectly OK for a const member function to return a (copy of ) member data which is a pointer to a non-const object). But anyway I made those functions (subaddress(), subaddressModel(), subaddressAccount(), subaddressAccountModel()) non-const and removed mutable, as I don't see any problem in doing so.

Subaddress * m_subaddress;
mutable SubaddressModel * m_subaddressModel;
SubaddressAccount * m_subaddressAccount;
mutable SubaddressAccountModel * m_subaddressAccountModel;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These mutable qualifiers would like go with the const on the getter above removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed


public:
enum SubaddressAccountRowRole {
SubaddressAccountRole = Qt::UserRole + 1, // for the SubaddressAccountRow object;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is not handled in roleNames and data. Is it a placeholder only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, removed

@Jaqueeee
Copy link
Contributor

Looks good to me. Can be merged once @moneromooo-monero's remarks are addressed/fixed.
@kenshi84 @luigi1111

@Jaqueeee
Copy link
Contributor

@kenshi84 This PR becomes obsolete when monero-project/monero#2703 is merged right?

@kenshi84
Copy link
Contributor Author

@Jaqueeee Correct, so closing this. Comments from @moneromooo-monero will be reflected in #793 .

@kenshi84 kenshi84 closed this Oct 31, 2017
@kenshi84 kenshi84 deleted the subaddr-api branch December 18, 2017 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants