Don't leak dialogs

It seems that you need to manually destroy created objects... Great...

fixes #898
This commit is contained in:
Nicolas Werner 2022-02-21 05:01:01 +01:00
parent 609cd82dc0
commit ff4334d59e
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
10 changed files with 52 additions and 5 deletions

View file

@ -54,6 +54,7 @@ Rectangle {
} else {
var dialog = placeCallDialog.createObject(timelineRoot);
dialog.open();
timelineRoot.destroyOnClose(dialog);
}
}
}

View file

@ -226,6 +226,7 @@ Item {
forwardMess.setMessageEventId(chat.model.reply);
forwardMess.open();
chat.model.reply = null;
timelineRoot.destroyOnClose(forwardMess);
}
}
}
@ -653,6 +654,7 @@ Item {
var forwardMess = forwardCompleterComponent.createObject(timelineRoot);
forwardMess.setMessageEventId(messageContextMenu.eventId);
forwardMess.open();
timelineRoot.destroyOnClose(forwardMess);
}
}

View file

@ -394,6 +394,7 @@ Page {
"profile": Nheko.currentUser
});
userProfile.show();
timelineRoot.destroyOnClose(userProfile);
}
@ -670,6 +671,7 @@ Page {
onClicked: {
var win = roomDirectoryComponent.createObject(timelineRoot);
win.show();
timelineRoot.destroyOnClose(win);
}
}
@ -688,6 +690,7 @@ Page {
onClicked: {
var quickSwitch = quickSwitcherComponent.createObject(timelineRoot);
quickSwitch.open();
timelineRoot.destroyOnClose(quickSwitch);
}
}

View file

@ -29,6 +29,13 @@ Pane {
id: fontMetrics
}
//Timer {
// onTriggered: gc()
// interval: 1000
// running: true
// repeat: true
//}
EmojiPicker {
id: emojiPopup
@ -166,6 +173,7 @@ Pane {
onActivated: {
var quickSwitch = quickSwitcherComponent.createObject(timelineRoot);
quickSwitch.open();
destroyOnClose(quickSwitch);
}
}
@ -189,11 +197,13 @@ Pane {
function onOpenLogoutDialog() {
var dialog = logoutDialog.createObject(timelineRoot);
dialog.open();
destroyOnClose(dialog);
}
function onOpenJoinRoomDialog() {
var dialog = joinRoomDialog.createObject(timelineRoot);
dialog.show();
destroyOnClose(dialog);
}
target: Nheko
@ -205,17 +215,23 @@ Pane {
"flow": flow
});
dialog.show();
destroyOnClose(dialog);
}
target: VerificationManager
}
function destroyOnClose(obj) {
obj.closing.connect(() => obj.destroy());
}
Connections {
function onOpenProfile(profile) {
var userProfile = userProfileComponent.createObject(timelineRoot, {
"profile": profile
});
userProfile.show();
destroyOnClose(userProfile);
}
function onShowImagePackSettings(room, packlist) {
@ -224,6 +240,7 @@ Pane {
"packlist": packlist
});
packSet.show();
destroyOnClose(packSet);
}
function onOpenRoomMembersDialog(members, room) {
@ -232,6 +249,7 @@ Pane {
"room": room
});
membersDialog.show();
destroyOnClose(membersDialog);
}
function onOpenRoomSettingsDialog(settings) {
@ -239,6 +257,7 @@ Pane {
"roomSettings": settings
});
roomSettings.show();
destroyOnClose(roomSettings);
}
function onOpenInviteUsersDialog(invitees) {
@ -248,6 +267,7 @@ Pane {
"invitees": invitees
});
dialog.show();
destroyOnClose(dialog);
}
function onOpenLeaveRoomDialog(roomid) {
@ -255,6 +275,7 @@ Pane {
"roomId": roomid
});
dialog.open();
destroyOnClose(dialog);
}
function onShowImageOverlay(room, eventId, url, proportionalHeight, originalWidth) {
@ -264,6 +285,7 @@ Pane {
"url": url
});
dialog.showFullScreen();
destroyOnClose(dialog);
}
target: TimelineManager
@ -274,6 +296,7 @@ Pane {
if (CallManager.haveCallInvite && Settings.mobileMode) {
var dialog = mobileCallInviteDialog.createObject(msgView);
dialog.open();
destroyOnClose(dialog);
}
}

View file

@ -261,6 +261,7 @@ Item {
"room": room
});
dialog.show();
timelineRoot.destroyOnClose(dialog);
}
function onShowRawMessageDialog(rawMessage) {
@ -268,6 +269,7 @@ Item {
"rawMessage": rawMessage
});
dialog.show();
timelineRoot.destroyOnClose(dialog);
}
target: room

View file

@ -71,6 +71,7 @@ ApplicationWindow {
"imagePack": packlist.newPack(false)
});
dialog.show();
timelineRoot.destroyOnClose(dialog);
}
width: packlistC.width
visible: !packlist.containsAccountPack
@ -84,6 +85,7 @@ ApplicationWindow {
"imagePack": packlist.newPack(true)
});
dialog.show();
timelineRoot.destroyOnClose(dialog);
}
width: packlistC.width
visible: room.permissions.canChange(MtxEvent.ImagePackInRoom)
@ -199,6 +201,7 @@ ApplicationWindow {
"imagePack": currentPack
});
dialog.show();
timelineRoot.destroyOnClose(dialog);
}
}

View file

@ -136,6 +136,7 @@ Popup {
"image": ":/icons/icons/ui/place-call.svg"
});
dialog.open();
timelineRoot.destroyOnClose(dialog);
return false;
}
return true;

View file

@ -83,6 +83,7 @@ Rectangle {
onClicked: {
var dialog = devicesDialog.createObject(timelineRoot);
dialog.open();
timelineRoot.destroyOnClose(dialog);
}
}
@ -98,6 +99,7 @@ Rectangle {
"image": ":/icons/icons/ui/place-call.svg"
});
dialog.open();
timelineRoot.destroyOnClose(dialog);
return ;
} else if (!CallManager.mics.includes(Settings.microphone)) {
var dialog = deviceError.createObject(timelineRoot, {
@ -105,6 +107,7 @@ Rectangle {
"image": ":/icons/icons/ui/place-call.svg"
});
dialog.open();
timelineRoot.destroyOnClose(dialog);
return ;
}
if (CallManager.callType == CallType.VIDEO && CallManager.cameras.length > 0 && !CallManager.cameras.includes(Settings.camera)) {
@ -113,6 +116,7 @@ Rectangle {
"image": ":/icons/icons/ui/video.svg"
});
dialog.open();
timelineRoot.destroyOnClose(dialog);
return ;
}
CallManager.acceptInvite();

View file

@ -66,6 +66,7 @@ Popup {
"image": ":/icons/icons/ui/place-call.svg"
});
dialog.open();
timelineRoot.destroyOnClose(dialog);
return false;
}
return true;
@ -118,6 +119,7 @@ Popup {
var dialog = screenShareDialog.createObject(timelineRoot);
dialog.open();
close();
timelineRoot.destroyOnClose(dialog);
}
}

View file

@ -183,28 +183,31 @@ TimelineViewManager::openRoomMembers(TimelineModel *room)
{
if (!room)
return;
MemberList *memberList = new MemberList(room->roomId(), this);
MemberList *memberList = new MemberList(room->roomId());
QQmlEngine::setObjectOwnership(memberList, QQmlEngine::JavaScriptOwnership);
emit openRoomMembersDialog(memberList, room);
}
void
TimelineViewManager::openRoomSettings(QString room_id)
{
RoomSettings *settings = new RoomSettings(room_id, this);
RoomSettings *settings = new RoomSettings(room_id);
connect(rooms_->getRoomById(room_id).data(),
&TimelineModel::roomAvatarUrlChanged,
settings,
&RoomSettings::avatarChanged);
QQmlEngine::setObjectOwnership(settings, QQmlEngine::JavaScriptOwnership);
emit openRoomSettingsDialog(settings);
}
void
TimelineViewManager::openInviteUsers(QString roomId)
{
InviteesModel *model = new InviteesModel{this};
InviteesModel *model = new InviteesModel{};
connect(model, &InviteesModel::accept, this, [this, model, roomId]() {
emit inviteUsers(roomId, model->mxids());
});
QQmlEngine::setObjectOwnership(model, QQmlEngine::JavaScriptOwnership);
emit openInviteUsersDialog(model);
}
@ -212,6 +215,7 @@ void
TimelineViewManager::openGlobalUserProfile(QString userId)
{
UserProfile *profile = new UserProfile{QString{}, userId, this};
QQmlEngine::setObjectOwnership(profile, QQmlEngine::JavaScriptOwnership);
emit openProfile(profile);
}
@ -269,8 +273,10 @@ TimelineViewManager::openImageOverlay(TimelineModel *room, QString mxcUrl, QStri
void
TimelineViewManager::openImagePackSettings(QString roomid)
{
auto room = rooms_->getRoomById(roomid).get();
emit showImagePackSettings(room, new ImagePackListModel(roomid.toStdString(), this));
auto room = rooms_->getRoomById(roomid).get();
auto model = new ImagePackListModel(roomid.toStdString());
QQmlEngine::setObjectOwnership(model, QQmlEngine::JavaScriptOwnership);
emit showImagePackSettings(room, model);
}
void