We have moved to a new Sailfish OS Forum. Please start new discussions there.

dialog.connect function loses its parent [not relevant]

asked 2014-05-26 14:20:29 +0300

kimmoli gravatar image

updated 2014-06-02 12:36:42 +0300

I have two pages and one dialog in my application. First page uses pageStac.push to open 2nd page. Both pages uses the dialog, which is pushed also to pageStack from MenuItem - onClicked.

On the first page, in the dialog.connect function() if i do console.log(parent), i get a valid parent, same as from onClicked.

On the second page, in the dialog.connect function() if i do console.log(parent), i get "undefine", altough onClicked shows a valid parent.

Is this a bug somewhere?

As a workaround, in the 2nd page MenuItem-onClicked, i call function which is not inside the MenuItem. If i push to dialog from this function, everything works fine.

(askbot code render failed, so see here for Code snip )

The same code for page 1 and 2.

EDIT: add diagram; The green functions work, orange does not work. image description

edit retag flag offensive reopen delete

The question has been closed for the following reason "question is not relevant or outdated" by kimmoli
close date 2014-10-11 21:40:50.907446

1 Answer

Sort by » oldest newest most voted

answered 2014-06-01 18:59:15 +0300

Dickson gravatar image

On the second page, the parent is the ContextMenu. Since the ContextMenu is inside a component, I guess that you are dynamically create and destroy that ContextMenu when opening and closing. So when the dialog is accepted, the ContextMenu is already closed and destroyed and therefore the parent is undefined.

But, why you using parent? The parent inside the dialog.accept signal is not the parent of the dialog, but is the parent of the current context (which is the parent of the MenuItem, the ContextMenu). If you want to get the parent of the dialog, you should use editDialog.parent.

edit flag offensive delete publish link more


I had some functionality inside the dialog accept function, to modify the current ListItem which for the contextmenu was.

I used the parent as i did console.log()-debug it down to that.

But i still don't understand why that function works on first page but not on the second page, what is the difference, it is just hierarchically down in pageStack (?) On the first page, the ContextMenu should also be already destroyed?

kimmoli ( 2014-06-01 21:38:35 +0300 )edit

On the first page, the function is inside the ListItem, so the parent is the parent of ListItem. On the second page, the function is inside the MenuItem, so the parent is the parent of MenuItem, ie ContextMenu. The parent value is highly depend on where you use it.

Dickson ( 2014-06-02 07:36:29 +0300 )edit

added picture... as i don't yet believe we are talking about same thing here.

On both of my pages, the function doThatThing() is inside the ListItem, and also on both of the pages, the editDialog.connect(function())) is inside the MenuItem/ContextMenu. The struture of QML is almost identical for both of these pages, they do the same things but just to different models.

The code snippet tries to show source of two separate QML file.

i agree that parent of function doThatThing() is different from parent of editDialog.connect(function()).

IMO the parent of editDialog.connect(function()) should be same on both pages?

kimmoli ( 2014-06-02 12:37:33 +0300 )edit

Question tools



Asked: 2014-05-26 14:20:29 +0300

Seen: 310 times

Last updated: Jun 02 '14