deleting line of a field causes crashes

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

deleting line of a field causes crashes

tbodine
Hi LiveCoders.

I'm writing an "Open Recent Files" feature that stores paths to the last 10 files opened in a field in a separate stack ("AppPrefs"). I consistently get crashes (LC 6.1.1 commercial) when I attempt to delete certain lines of that field, which is stored in a stack in the user's AppData area.

-- delete the last line after adding new one to top
if the number of lines in field "Recent" of stack "AppPrefs" > 10 then
  delete the last line of field "Recent" of stack "AppPrefs" -- CRASHES!
end if

--similarly, this crashes when I loop through the same field's lines and try to delete prior listings of the same filepath:

delete line n of field "Recent" of stack "AppPrefs" -- CRASHES

Am I missing s/g obvious or is there a bug at work?

Thanks,
Tom Bodine
Reply | Threaded
Open this post in threaded view
|

Re: deleting line of a field causes crashes

J. Landman Gay
On 10/5/13 5:16 PM, tbodine wrote:

> Hi LiveCoders.
>
> I'm writing an "Open Recent Files" feature that stores paths to the last 10
> files opened in a field in a separate stack ("AppPrefs"). I consistently get
> crashes (LC 6.1.1 commercial) when I attempt to delete certain lines of that
> field, which is stored in a stack in the user's AppData area.
>
> -- delete the last line after adding new one to top
> if the number of lines in field "Recent" of stack "AppPrefs" > 10 then
>    delete the last line of field "Recent" of stack "AppPrefs" -- CRASHES!
> end if
>
> --similarly, this crashes when I loop through the same field's lines and try
> to delete prior listings of the same filepath:
>
> delete line n of field "Recent" of stack "AppPrefs" -- CRASHES
>
> Am I missing s/g obvious or is there a bug at work?

Sounds like a bug to me. But at any rate, the engine should never crash
even if you really are doing something wrong. I'd say send a report.

--
Jacqueline Landman Gay         |     [hidden email]
HyperActive Software           |     http://www.hyperactivesw.com

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: deleting line of a field causes crashes

Kay C Lan
In reply to this post by tbodine
Agree with Jacque that something is wrong.

In the meantime, as a work around, and possibly help pinpoint the culprit;
do you really need to store the data in a field? If no one is ever going to
look at the raw full file path a custom property would be faster:

set the prefRecentFiles of stack "AppPrefs" to lFileList --last 10 files.

You could also remove the necessity of looping through the list to remove
duplicates by using an Array with the Key being the full path and the Data
being 'the seconds', that way any use of a previous full file path would
simply update it's 'seconds' which could then be used to sort your list to
most recent at the top.

If your custom property is a simple list and you can delete lines from that
list, or your custom property is an array and you can remove a key using
'delete variable' then your current problem could be with your field or
with delete line when referring to a field. If you problem persists, then
it could be with delete itself or something peculiar with your "AppPrefs"
stack

HTH


On Sun, Oct 6, 2013 at 6:16 AM, tbodine <[hidden email]> wrote:

> Hi LiveCoders.
>
> I'm writing an "Open Recent Files" feature that stores paths to the last 10
> files opened in a field in a separate stack ("AppPrefs").
>


> --similarly, this crashes when I loop through the same field's lines and
> try
> to delete prior listings of the same filepath:
>
> delete line n of field "Recent" of stack "AppPrefs" -- CRASHES
>
> Am I missing s/g obvious or is there a bug at work?
>
> Thanks,
> Tom Bodine
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: deleting line of a field causes crashes

tbodine
Thanks Kay and Jacque. I will definitely try the alternative approach suggested by Kay.
-- Tom Bodine
Reply | Threaded
Open this post in threaded view
|

Re: deleting line of a field causes crashes

pmbrig
In reply to this post by Kay C Lan
On Oct 5, 2013, at 10:06 PM, Kay C Lan wrote:

> Agree with Jacque that something is wrong.
>
> In the meantime, as a work around, and possibly help pinpoint the culprit;
> do you really need to store the data in a field? If no one is ever going to
> look at the raw full file path a custom property would be faster:
>
> set the prefRecentFiles of stack "AppPrefs" to lFileList --last 10 files.
>
> You could also remove the necessity of looping through the list to remove
> duplicates by using an Array with the Key being the full path and the Data
> being 'the seconds', that way any use of a previous full file path would
> simply update it's 'seconds' which could then be used to sort your list to
> most recent at the top.

Or the reverse, where the keys are the seconds and the values are the filepaths. Then:
   put the prefRecentFiles of stack "AppPrefs" into pFileList
   put the keys of pFileList into keyList
   sort lines of keyList numeric descending
   delete line 11 to -1 of keyList
   set the keys of pFileList to keyList
   set the prefRecentFiles of stack "AppPrefs" to pFileList

So many ways to skin the cat...

-- Peter

Peter M. Brigham
[hidden email]
http://home.comcast.net/~pmbrig



_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode