Merge pull request #974 from flowln/accounts_qt6
Fix adding multiple accounts in Qt6
This commit is contained in:
commit
336f1f4f50
@ -77,10 +77,12 @@ public:
|
|||||||
{
|
{
|
||||||
return m_ptr;
|
return m_ptr;
|
||||||
}
|
}
|
||||||
bool operator==(const shared_qobject_ptr<T>& other) {
|
template<typename U>
|
||||||
|
bool operator==(const shared_qobject_ptr<U>& other) const {
|
||||||
return m_ptr == other.m_ptr;
|
return m_ptr == other.m_ptr;
|
||||||
}
|
}
|
||||||
bool operator!=(const shared_qobject_ptr<T>& other) {
|
template<typename U>
|
||||||
|
bool operator!=(const shared_qobject_ptr<U>& other) const {
|
||||||
return m_ptr != other.m_ptr;
|
return m_ptr != other.m_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,8 +109,10 @@ QStringList AccountList::profileNames() const {
|
|||||||
|
|
||||||
void AccountList::addAccount(const MinecraftAccountPtr account)
|
void AccountList::addAccount(const MinecraftAccountPtr account)
|
||||||
{
|
{
|
||||||
// NOTE: Do not allow adding something that's already there
|
// NOTE: Do not allow adding something that's already there. We shouldn't let it continue
|
||||||
|
// because of the signal / slot connections after this.
|
||||||
if (m_accounts.contains(account)) {
|
if (m_accounts.contains(account)) {
|
||||||
|
qDebug() << "Tried to add account that's already on the accounts list!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,6 +125,8 @@ void AccountList::addAccount(const MinecraftAccountPtr account)
|
|||||||
if(profileId.size()) {
|
if(profileId.size()) {
|
||||||
auto existingAccount = findAccountByProfileId(profileId);
|
auto existingAccount = findAccountByProfileId(profileId);
|
||||||
if(existingAccount != -1) {
|
if(existingAccount != -1) {
|
||||||
|
qDebug() << "Replacing old account with a new one with the same profile ID!";
|
||||||
|
|
||||||
MinecraftAccountPtr existingAccountPtr = m_accounts[existingAccount];
|
MinecraftAccountPtr existingAccountPtr = m_accounts[existingAccount];
|
||||||
m_accounts[existingAccount] = account;
|
m_accounts[existingAccount] = account;
|
||||||
if(m_defaultAccount == existingAccountPtr) {
|
if(m_defaultAccount == existingAccountPtr) {
|
||||||
@ -138,9 +142,12 @@ void AccountList::addAccount(const MinecraftAccountPtr account)
|
|||||||
|
|
||||||
// if we don't have this profileId yet, add the account to the end
|
// if we don't have this profileId yet, add the account to the end
|
||||||
int row = m_accounts.count();
|
int row = m_accounts.count();
|
||||||
|
qDebug() << "Inserting account at index" << row;
|
||||||
|
|
||||||
beginInsertRows(QModelIndex(), row, row);
|
beginInsertRows(QModelIndex(), row, row);
|
||||||
m_accounts.append(account);
|
m_accounts.append(account);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
|
|
||||||
onListChanged();
|
onListChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user