fix context menu: kill target session, not active one
Right-click now stores the target session ID in a root-level property (killTargetSessionId) before popping the menu, avoiding unreliable QML parent chain traversal that could resolve to the wrong delegate.
This commit is contained in:
parent
0706a052f4
commit
ada6dc1feb
11
gui/main.qml
11
gui/main.qml
|
|
@ -90,6 +90,9 @@ ApplicationWindow {
|
|||
onTriggered: chatView.positionViewAtEnd()
|
||||
}
|
||||
|
||||
// Session ID to kill — set on right-click, consumed by context menu
|
||||
property string killTargetSessionId: ""
|
||||
|
||||
// Session tree model — flat list with level info
|
||||
ListModel {
|
||||
id: sessionTreeModel
|
||||
|
|
@ -538,6 +541,9 @@ ApplicationWindow {
|
|||
onClicked: function(mouse) {
|
||||
if (mouse.button === Qt.RightButton) {
|
||||
if (type === "session") {
|
||||
var item = sessionTreeModel.get(parent.modelIndex)
|
||||
if (item)
|
||||
root.killTargetSessionId = item.id
|
||||
sessionCtxMenu.popup()
|
||||
}
|
||||
return
|
||||
|
|
@ -561,9 +567,8 @@ ApplicationWindow {
|
|||
text: "Kill"
|
||||
icon.color: "#f44336"
|
||||
onClicked: {
|
||||
var item = sessionTreeModel.get(parent.parent.parent.modelIndex)
|
||||
if (item && item.type === "session")
|
||||
ollie.killSession(item.id)
|
||||
if (root.killTargetSessionId)
|
||||
ollie.killSession(root.killTargetSessionId)
|
||||
ollie.refreshSessions()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in New Issue