Fix deadlocks and qml errors.

This commit is contained in:
Julien Wadel 2024-03-14 17:08:25 +01:00
parent 6cfb26ba1b
commit 6176f1971c
9 changed files with 62 additions and 44 deletions

View file

@ -85,16 +85,18 @@ ConferenceInfoCore::ConferenceInfoCore(std::shared_ptr<linphone::ConferenceInfo>
}
mConferenceInfoState = LinphoneEnums::fromLinphone(conferenceInfo->getState());
} else {
auto defaultAccount = CoreModel::getInstance()->getCore()->getDefaultAccount();
if (defaultAccount) {
auto accountAddress = defaultAccount->getContactAddress();
if (accountAddress) {
auto cleanedClonedAddress = accountAddress->clone();
cleanedClonedAddress->clean();
mOrganizerAddress = Utils::coreStringToAppString(cleanedClonedAddress->asStringUriOnly());
qDebug() << "set organizer address" << mOrganizerAddress;
App::postModelSync([this]() {
auto defaultAccount = CoreModel::getInstance()->getCore()->getDefaultAccount();
if (defaultAccount) {
auto accountAddress = defaultAccount->getContactAddress();
if (accountAddress) {
auto cleanedClonedAddress = accountAddress->clone();
cleanedClonedAddress->clean();
mOrganizerAddress = Utils::coreStringToAppString(cleanedClonedAddress->asStringUriOnly());
qDebug() << "set organizer address" << mOrganizerAddress;
}
}
}
});
}
connect(this, &ConferenceInfoCore::endDateTimeChanged,
@ -146,7 +148,7 @@ void ConferenceInfoCore::setSelf(SafeSharedPointer<ConferenceInfoCore> me) {
void ConferenceInfoCore::setSelf(QSharedPointer<ConferenceInfoCore> me) {
if (me) {
if (mConferenceInfoModel) {
mCoreModelConnection = nullptr;
mConfInfoModelConnection = nullptr;
mConfInfoModelConnection = QSharedPointer<SafeConnection<ConferenceInfoCore, ConferenceInfoModel>>(
new SafeConnection<ConferenceInfoCore, ConferenceInfoModel>(me, mConferenceInfoModel),
&QObject::deleteLater);
@ -175,9 +177,10 @@ void ConferenceInfoCore::setSelf(QSharedPointer<ConferenceInfoCore> me) {
mConfInfoModelConnection->makeConnectToModel(&ConferenceInfoModel::conferenceInfoDeleted,
&ConferenceInfoCore::removed);
mConfInfoModelConnection->makeConnectToModel(
&ConferenceInfoModel::stateChanged,
[this](linphone::ConferenceScheduler::State state) { qDebug() << "conf state changed"; });
mConfInfoModelConnection->makeConnectToModel(&ConferenceInfoModel::stateChanged,
[this](linphone::ConferenceScheduler::State state) {
qDebug() << "conf state changed:" << (int)state;
});
mConfInfoModelConnection->makeConnectToModel(
&ConferenceInfoModel::invitationsSent,
[this](const std::list<std::shared_ptr<linphone::Address>> &failedInvitations) {
@ -332,7 +335,7 @@ void ConferenceInfoCore::addParticipant(const QString &address) {
}
QVariantMap participant;
auto displayNameObj = Utils::getDisplayName(address);
if (displayNameObj) participant["displayName"] = displayNameObj->getValue();
participant["displayName"] = displayNameObj ? displayNameObj->getValue() : "";
participant["address"] = address;
participant["role"] = (int)LinphoneEnums::ParticipantRole::Listener;
mParticipants.append(participant);
@ -515,8 +518,11 @@ void ConferenceInfoCore::save() {
}
thisCopy->writeIntoModel(mConferenceInfoModel);
thisCopy->deleteLater();
confSchedulerModel->setInfo(linphoneConf);
mCoreModelConnection->invokeToCore([this]() { setSelf(mCoreModelConnection->mCore); });
mCoreModelConnection->invokeToCore([this, confSchedulerModel, linphoneConf]() {
setSelf(mCoreModelConnection->mCore);
mCoreModelConnection->invokeToModel(
[this, confSchedulerModel, linphoneConf]() { confSchedulerModel->setInfo(linphoneConf); });
});
});
}
}

View file

@ -105,6 +105,7 @@ std::shared_ptr<CoreModel> CoreModel::getInstance() {
}
std::shared_ptr<linphone::Core> CoreModel::getCore() {
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
return mCore;
}

View file

@ -281,12 +281,17 @@ QString Utils::generateLinphoneSipAddress(const QString &uri) {
}
QString Utils::findAvatarByAddress(const QString &address) {
auto defaultFriendList = CoreModel::getInstance()->getCore()->getDefaultFriendList();
if (!defaultFriendList) return QString();
auto linphoneAddr = ToolModel::interpretUrl(address);
auto linFriend = CoreModel::getInstance()->getCore()->findFriend(linphoneAddr);
if (linFriend) return Utils::coreStringToAppString(linFriend->getPhoto());
return QString();
QString avatar;
App::postModelSync([address, avatar]() mutable {
auto defaultFriendList = CoreModel::getInstance()->getCore()->getDefaultFriendList();
if (!defaultFriendList) return;
auto linphoneAddr = ToolModel::interpretUrl(address);
auto linFriend = CoreModel::getInstance()->getCore()->findFriend(linphoneAddr);
if (linFriend) avatar = Utils::coreStringToAppString(linFriend->getPhoto());
});
return avatar;
}
QString Utils::generateSavedFilename(const QString &from, const QString &to) {

View file

@ -39,13 +39,17 @@ bool Thread::isInLinphoneThread() {
bool Thread::mustBeInLinphoneThread(const QString &context) {
bool isLinphoneThread = isInLinphoneThread();
if (!isLinphoneThread) qCritical() << "[Thread] Not processing in Linphone thread from " << context;
if (!isLinphoneThread) { // Bracket to easier debugging.
qCritical() << "[Thread] Not processing in Linphone thread from " << context;
}
return isLinphoneThread;
}
bool Thread::mustBeInMainThread(const QString &context) {
if (!qApp) return true;
bool isMainThread = QThread::currentThread() == qApp->thread();
if (!isMainThread) qCritical() << "[Thread] Not processing in Main thread from " << context;
if (!isMainThread) {
qCritical() << "[Thread] Not processing in Main thread from " << context;
}
return isMainThread;
}

View file

@ -232,9 +232,6 @@ Item {
model: MagicSearchProxy {
searchText: searchBarText.length === 0 ? "*" : searchBarText
}
onContactSelected: (contact) => {
if (contact.core.allAddresses.length > 1) {
startCallPopup.contact = contact
onSelectedContactChanged: {
if (selectedContact) {
if (selectedContact.core.allAddresses.length > 1) {

View file

@ -129,7 +129,7 @@ Control.ComboBox {
visible: source != ""
width: visible ? 20 * DefaultStyle.dp : 0
sourceSize.width: 20 * DefaultStyle.dp
source: modelData.img ? modelData.img : ""
source: modelData && modelData.img ? modelData.img : ""
fillMode: Image.PreserveAspectFit
anchors.left: parent.left
anchors.leftMargin: visible ? 10 * DefaultStyle.dp : 0
@ -137,11 +137,11 @@ Control.ComboBox {
}
Text {
text: modelData.text
? modelData.text
: modelData
? modelData
: ""
text: modelData
? modelData.text
? modelData.text
: modelData
: ""
elide: Text.ElideRight
maximumLineCount: 1
wrapMode: Text.WrapAnywhere

View file

@ -34,7 +34,7 @@ ListView {
property int delegateLeftMargin: 0
currentIndex: -1
property var delegateButtons
property var delegateButtons: []
property FriendGui selectedContact: model.getAt(currentIndex) || null
@ -120,20 +120,25 @@ ListView {
}
RowLayout {
id: actionsRow
z: 1
height: parent.height
anchors.right: parent.right
anchors.fill: parent
anchors.rightMargin: 5 * DefaultStyle.dp
anchors.verticalCenter: parent.verticalCenter
children: mainItem.delegateButtons || []
RowLayout{
Layout.fillWidth: true
Layout.fillHeight: true
children: mainItem.delegateButtons
}
PopupButton {
id: friendPopup
z: 1
hoverEnabled: mainItem.hoverEnabled
visible: mainItem.contactMenuVisible && (contactArea.containsMouse || hovered || popup.opened) && (!delegateButtons || delegateButtons.children.length === 0)
Layout.rightMargin: 5 * DefaultStyle.dp
Layout.alignment: Qt.AlignVCenter
popup.x: 0
popup.padding: 10 * DefaultStyle.dp
Layout.rightMargin: 5 * DefaultStyle.dp
hoverEnabled: mainItem.hoverEnabled
visible: mainItem.contactMenuVisible && (contactArea.containsMouse || hovered || popup.opened) && (!mainItem.delegateButtons || mainItem.delegateButtons.length === 0)
popup.contentItem: ColumnLayout {
Button {
background: Item{}

View file

@ -334,7 +334,7 @@ ColumnLayout {
model: mainItem.conferenceInfoGui.core.participants
delegate: Item {
height: 56 * DefaultStyle.dp
width: parent.width
width: participantList.width
RowLayout {
anchors.fill: parent
Avatar {
@ -374,4 +374,4 @@ ColumnLayout {
Item {
Layout.fillHeight: true
}
}
}

@ -1 +1 @@
Subproject commit 98c2b724e1a045eb46ccba23a912ba6e1ac0647d
Subproject commit 0dda330ac9ccd7f5b495ac147e88ff7dbb620762