diff options
author | flow <flowlnlnln@gmail.com> | 2022-07-26 16:08:05 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-26 16:08:05 -0300 |
commit | 336f1f4f5067cf45bc34031f376baafef9934e45 (patch) | |
tree | 3803df79a37f12842e33d571f7ef18b7c86b95a8 | |
parent | 1c256d8876b216c41815bf60691b75769694bddd (diff) | |
parent | 6fe55a79f18ac03c919c1ecbadde19fb2c82681b (diff) | |
download | PrismLauncher-336f1f4f5067cf45bc34031f376baafef9934e45.tar.gz PrismLauncher-336f1f4f5067cf45bc34031f376baafef9934e45.tar.bz2 PrismLauncher-336f1f4f5067cf45bc34031f376baafef9934e45.zip |
Merge pull request #974 from flowln/accounts_qt6
Fix adding multiple accounts in Qt6
-rw-r--r-- | launcher/QObjectPtr.h | 6 | ||||
-rw-r--r-- | launcher/minecraft/auth/AccountList.cpp | 11 |
2 files changed, 13 insertions, 4 deletions
diff --git a/launcher/QObjectPtr.h b/launcher/QObjectPtr.h index 57974939..173dc5e7 100644 --- a/launcher/QObjectPtr.h +++ b/launcher/QObjectPtr.h @@ -77,10 +77,12 @@ public: { 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; } - 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; } diff --git a/launcher/minecraft/auth/AccountList.cpp b/launcher/minecraft/auth/AccountList.cpp index 2b851e18..b3b57c74 100644 --- a/launcher/minecraft/auth/AccountList.cpp +++ b/launcher/minecraft/auth/AccountList.cpp @@ -109,8 +109,10 @@ QStringList AccountList::profileNames() const { void AccountList::addAccount(const MinecraftAccountPtr account) { - // NOTE: Do not allow adding something that's already there - if(m_accounts.contains(account)) { + // 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)) { + qDebug() << "Tried to add account that's already on the accounts list!"; return; } @@ -123,6 +125,8 @@ void AccountList::addAccount(const MinecraftAccountPtr account) if(profileId.size()) { auto existingAccount = findAccountByProfileId(profileId); if(existingAccount != -1) { + qDebug() << "Replacing old account with a new one with the same profile ID!"; + MinecraftAccountPtr existingAccountPtr = m_accounts[existingAccount]; m_accounts[existingAccount] = account; 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 int row = m_accounts.count(); + qDebug() << "Inserting account at index" << row; + beginInsertRows(QModelIndex(), row, row); m_accounts.append(account); endInsertRows(); + onListChanged(); } |