ActionSelectionPopover's CPO click_action_button fails if we destroy the popover as result of an action

Bug #1504189 reported by Ugo Riboni
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
ubuntu-ui-toolkit (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

When using the click_action_button of the Custom Proxy Object for ActionSelectionPopover in an autopilot test, we get an exception in case the action that gets clicked has the result of destroying the popover.

The bug is caused by the fact that, once the action item has been clicked, the CPO method tries to access the autoClose property of the popover. However at this point the popover might have been already destroyed, causing an exception.
A simple fix is to cache the value just before the click and refer to the value after, as autoClose is unlikely to change as a result of the click.

For a real life example of this problem, imagine a ListView we pop up a menu with an action that allows the user to delete the delegate pointed at by the popup. This is very common case. The example below is the simplest version of a test case that implements this. You can easily create an AP test from this that reproduces the issue:

import QtQuick 2.4
import Ubuntu.Components 1.3
import Ubuntu.Components.Popups 1.3

ListView {
    id: list
    width: 800
    height: 600

    model: ["A", "B", "C"]
    delegate: ListItem {
        Button {
            id: button
            text: modelData
            onTriggered: PopupUtils.open(popupComponent, button, {i: index})
        }
    }

    Component {
        id: popupComponent
        ActionSelectionPopover {
            id: popup
            property int i
            actions: ActionList {
                Action {
                    text: "Delete"
                    onTriggered: {
                        var m = list.model
                        m.splice(popup.i, 1)
                        list.model = m
                    }
                }
            }
        }
    }
}

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in ubuntu-ui-toolkit (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.