<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=koi8-r">
<style type="text/css">
<!--
p, li
        {white-space:pre-wrap}
-->
</style><style id="owaParaStyle" type="text/css">P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1" style="font-family:'DejaVu Serif'; font-size:10pt; font-weight:400; font-style:normal">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Hi Oleg.<br>
<br>
I'm sorry, the PageStack simply does not support this model.  It can only work like a stack, where pages are added and removed from one end of the list, and the existing pages on the stack are unmodifiable while there are other pages above them in the stack.<br>
<br>
In this case, 'above' actually means 'having greater depth value', indicating pages added to the stack more recently.  So, if you have 5 pages on the stack and replace above the page that has (_depth == 4) only the single page with (_depth > 4) will be removed. 
 There is no API to remove pages lower in the stack, as this is not how a stack works.<br>
<br>
I think your application may work better by ignoring the stack entirely.  You can use replace to transition to a new page without increasing the page stack depth, and the content of your page can be dynamically loaded, so you can maintain the logical state
 of the pages in an external array that you control.  Perhaps what you need is an array of instantiated Items, which can be loaded into your actual Page as required, or dropped from the array when no longer wanted.<br>
<br>
Thanks,<br>
Matt<br>
<br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF910874"><font face="Tahoma" color="#000000" size="2"><b>From:</b> Devel [devel-bounces@lists.sailfishos.org] on behalf of Oleg Linkin [maledictusdemagog@gmail.com]<br>
<b>Sent:</b> Saturday, September 10, 2016 2:42 PM<br>
<b>To:</b> devel@lists.sailfishos.org<br>
<b>Subject:</b> [SailfishDevel] Remove all pages from stack before specified page<br>
</font><br>
</div>
<div></div>
<div>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
Hello, developers</p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
 </p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
To prevent infinite page stack depth I want to cut some first pages from stack. </p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
I have 5 pages in stack and when I click on item and begin pushing 6 page to stack I want to remove first 4 pages and as result I want to have only 5 and 6 page in stack.</p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
But I can't do this.</p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
 </p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
I tried the next:</p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
<span style="color:#c0c0c0"></span><span style="color:#ffff55">if</span><span style="color:#c0c0c0">
</span>(pageStack.depth<span style="color:#c0c0c0"> </span>===<span style="color:#c0c0c0">
</span>5)<span style="color:#c0c0c0"> </span>{</p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
<span style="font-family:'Courier New,courier'; color:#c0c0c0"></span><span style="font-family:'Courier New,courier'">pageStack.replaceAbove(null,</span><span style="font-family:'Courier New,courier'; color:#c0c0c0">
</span><span style="font-family:'Courier New,courier'">pageStack.find(</span><span style="font-family:'Courier New,courier'; color:#ffff55">function</span><span style="font-family:'Courier New,courier'">(page)</span></p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
<span style="font-family:'Courier New,courier'; color:#c0c0c0"></span><span style="font-family:'Courier New,courier'">{</span><span style="font-family:'Courier New,courier'; color:#c0c0c0">
</span><span style="font-family:'Courier New,courier'; color:#ffff55">return</span><span style="font-family:'Courier New,courier'; color:#c0c0c0">
</span><span style="font-family:'Courier New,courier'; font-style:italic; color:#8888ff">page</span><span style="font-family:'Courier New,courier'">._depth</span><span style="font-family:'Courier New,courier'; color:#c0c0c0">
</span><span style="font-family:'Courier New,courier'">===</span><span style="font-family:'Courier New,courier'; color:#c0c0c0">
</span><span style="font-family:'Courier New,courier'">4</span><span style="font-family:'Courier New,courier'; color:#c0c0c0">
</span><span style="font-family:'Courier New,courier'">}),</span><span style="font-family:'Courier New,courier'; color:#c0c0c0">
</span><span style="font-family:'Courier New,courier'">{},</span></p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
<span style="font-family:'Courier New,courier'; color:#c0c0c0"></span><span style="font-family:'Courier New,courier'; color:#55ff55">PageStackAction</span><span style="font-family:'Courier New,courier'">.Immediate)</span></p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
<span style="font-family:'Courier New,courier'; color:#c0c0c0"></span><span style="font-family:'Courier New,courier'">}</span></p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
 </p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
But in this case I got empty page which I found in find function</p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
 </p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
and the next:</p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
<span style="color:#c0c0c0"></span><span style="color:#ffff55">if</span><span style="color:#c0c0c0">
</span>(pageStack.depth<span style="color:#c0c0c0"> </span>===<span style="color:#c0c0c0">
</span>5)<span style="color:#c0c0c0"> </span>{</p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
<span style="font-family:'Courier New,courier'; color:#c0c0c0"></span><span style="font-family:'Courier New,courier'">pageStack.pop(pageStack.find(</span><span style="font-family:'Courier New,courier'; color:#ffff55">function</span><span style="font-family:'Courier New,courier'">(page)</span></p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
<span style="font-family:'Courier New,courier'; color:#c0c0c0"></span><span style="font-family:'Courier New,courier'">{</span><span style="font-family:'Courier New,courier'; color:#c0c0c0">
</span><span style="font-family:'Courier New,courier'; color:#ffff55">return</span><span style="font-family:'Courier New,courier'; color:#c0c0c0">
</span><span style="font-family:'Courier New,courier'; font-style:italic; color:#8888ff">page</span><span style="font-family:'Courier New,courier'">._depth</span><span style="font-family:'Courier New,courier'; color:#c0c0c0">
</span><span style="font-family:'Courier New,courier'">===</span><span style="font-family:'Courier New,courier'; color:#c0c0c0">
</span><span style="font-family:'Courier New,courier'">4</span><span style="font-family:'Courier New,courier'; color:#c0c0c0">
</span><span style="font-family:'Courier New,courier'">}),</span></p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
<span style="font-family:'Courier New,courier'; color:#c0c0c0"></span><span style="font-family:'Courier New,courier'; color:#55ff55">PageStackAction</span><span style="font-family:'Courier New,courier'">.Immediate)</span></p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
<span style="font-family:'Courier New,courier'; color:#c0c0c0"></span><span style="font-family:'Courier New,courier'">}</span></p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
Documentation says: "<span style="font-family:'sans-serif'; font-size:medium; color:#000000; background-color:#ffffff">If a </span><span style="font-family:'sans-serif'; font-size:medium; font-style:italic; color:#000000; background-color:#ffffff">page</span><span style="font-family:'sans-serif'; font-size:medium; color:#000000; background-color:#ffffff"> object
 is specified, all pages above the specified page are removed;</span>" but in result it remove only page which found in pageStack.find function</p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
 </p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
How I can do this? Thx!</p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
 </p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
-- </p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
*Sincerely, Oleg Linkin.*</p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
 </p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
 </p>
<p style="margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; text-indent:0px">
*Jabber: magog@gentoo.ru <magog@gentoo.ru> Skype: lord_baskervil τΕΜ.: +375-(29)-5539994*</p>
</div>
</div>
</div>
</body>
</html>