1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-09-10 12:03:18 +02:00

mainview: fix crash when deleting account

Fix the deletion crash issue and remove redundant account changed
signals.

Gitlab: #17
Change-Id: I1858fa051fd5171e1261dbc35d361631dc3ea01d
This commit is contained in:
Ming Rui Zhang 2020-08-27 16:46:22 -04:00
parent 968088785d
commit b07f7afe92
12 changed files with 15 additions and 50 deletions

View file

@ -335,10 +335,10 @@ AccountAdapter::setSelectedAccount(const QString &accountId)
{
LRCInstance::setSelectedAccountId(accountId);
backToWelcomePage();
connectAccount(accountId);
emit accountSignalsReconnect(accountId);
backToWelcomePage();
}
void

View file

@ -44,6 +44,13 @@ ConversationsAdapter::initQmlObject()
[this](const QString &accountId, lrc::api::conversation::Info convInfo) {
emit showChatView(accountId, convInfo.uid);
});
connect(&LRCInstance::instance(), &LRCInstance::currentAccountChanged,
[this]() {
accountChangedSetUp(LRCInstance::getCurrAccId());
});
connectConversationModel();
}
void
@ -124,9 +131,12 @@ void
ConversationsAdapter::accountChangedSetUp(const QString &accountId)
{
// Should be called when current account is changed.
auto &accountInfo = LRCInstance::accountModel().getAccountInfo(accountId);
conversationSmartListModel_->setAccount(accountId);
auto& accountInfo = LRCInstance::accountModel().getAccountInfo(accountId);
currentTypeFilter_ = accountInfo.profileInfo.type;
LRCInstance::getCurrentConversationModel()->setFilter(accountInfo.profileInfo.type);
updateConversationsFilterWidget();
connectConversationModel();
}

View file

@ -270,12 +270,13 @@ public:
setSelectedAccountId(const QString &accountId = {})
{
instance().selectedAccountId_ = accountId;
emit instance().currentAccountChanged();
QSettings settings("jami.net", "Jami");
settings.setValue(SettingsKey::selectedAccount, accountId);
// Last selected account should be set as preferred.
accountModel().setTopAccount(accountId);
emit instance().currentAccountChanged();
};
static const QString &

View file

@ -299,12 +299,6 @@ Window {
Connections {
target: ClientWrapper.accountAdaptor
function onAccountSignalsReconnect(accountId) {
CallAdapter.connectCallModel(accountId)
mainViewWindowSidePanel.accountSignalsReconnect(accountId)
ConversationsAdapter.accountChangedSetUp(accountId)
}
function onUpdateConversationForAddedContact() {
mainViewWindowSidePanel.needToUpdateConversationForAddedContact()
}
@ -334,10 +328,6 @@ Window {
}
}
onNeedToUpdateSmartList: {
mainViewWindowSidePanel.updateSmartList(accountId)
}
onNeedToBackToWelcomePage: {
if (!inSettingsView)
mainViewWindowSidePanel.accountComboBoxNeedToShowWelcomePage()
@ -525,10 +515,6 @@ Window {
qrDialog.updateQrDialog()
}
onAccountSignalsReconnect: {
MessagesAdapter.accountChangedSetUp(accountId)
}
onNeedToUpdateConversationForAddedContact: {
MessagesAdapter.updateConversationForAddedContact()
mainViewWindowSidePanel.clearContactSearchBar()

View file

@ -28,7 +28,6 @@ ComboBox {
signal accountChanged(int index)
signal needToBackToWelcomePage()
signal needToUpdateSmartList(string accountId)
signal newAccountButtonClicked
signal settingBtnClicked
@ -38,10 +37,6 @@ ComboBox {
needToBackToWelcomePage()
}
function updateSmartList(accountId) {
needToUpdateSmartList(accountId)
}
// Refresh every item in accountListModel.
function updateAccountListModel() {
accountListModel.dataChanged(accountListModel.index(0, 0),

View file

@ -74,14 +74,6 @@ ListView {
conversationSmartListView.needToBackToWelcomePage()
}
/*
* Update smartlist to accountId.
*/
function updateSmartList(accountId) {
conversationSmartListView.model.setAccount(accountId)
}
ConversationSmartListContextMenu {
id: smartListContextMenu
}

View file

@ -34,7 +34,6 @@ Rectangle {
signal conversationSmartListNeedToAccessMessageWebView(string currentUserDisplayName, string currentUserAlias, string currentUID, bool callStackViewShouldShow, bool isAudioOnly, string callStateStr)
signal accountComboBoxNeedToShowWelcomePage()
signal conversationSmartListViewNeedToShowWelcomePage
signal accountSignalsReconnect(string accountId)
signal needToUpdateConversationForAddedContact
signal needToAddNewAccount
@ -115,11 +114,6 @@ Rectangle {
conversationSmartListView.updateConversationSmartListView()
}
function updateSmartList(accountId) {
conversationSmartListView.currentIndex = -1
conversationSmartListView.updateSmartList(accountId)
}
/*
* Intended -> since strange behavior will happen without this for stackview.
*/

View file

@ -146,14 +146,6 @@ MessagesAdapter::sendContactRequest()
}
}
void
MessagesAdapter::accountChangedSetUp(const QString &accountId)
{
Q_UNUSED(accountId)
connectConversationModel();
}
void
MessagesAdapter::updateConversationForAddedContact()
{

View file

@ -35,7 +35,6 @@ public:
Q_INVOKABLE void setupChatView(const QString &uid);
Q_INVOKABLE void connectConversationModel();
Q_INVOKABLE void sendContactRequest();
Q_INVOKABLE void accountChangedSetUp(const QString &accountId);
Q_INVOKABLE void updateConversationForAddedContact();
/*

View file

@ -333,7 +333,6 @@ Rectangle {
y: (parent.height - height) / 2
onAccepted: {
ClientWrapper.accountAdaptor.setSelectedAccountId()
ClientWrapper.accountAdaptor.setSelectedConvId()
if(ClientWrapper.utilsAdaptor.getAccountListSize() > 0){

View file

@ -82,7 +82,6 @@ Rectangle {
y: (parent.height - height) / 2
onAccepted: {
ClientWrapper.accountAdaptor.setSelectedAccountId()
ClientWrapper.accountAdaptor.setSelectedConvId()
if(ClientWrapper.utilsAdaptor.getAccountListSize() > 0){

View file

@ -410,7 +410,5 @@ SmartListModel::flags(const QModelIndex &index) const
void
SmartListModel::setAccount(const QString &accountId)
{
beginResetModel();
accountId_ = accountId;
endResetModel();
}