<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Brilliant, thanks very much. Feel a bit silly now as should have
seen that!<br>
<br>
Checked for the property on formdestroy only at first, which worked.
Then realised I had a massive memory leak so checked for the
property in the formcreate as well and everything works, no leaks.<br>
<br>
Thank you for writing that component Luiz, really helpful ;-)<br>
<br>
Best regards,<br>
<br>
Martin Collins<br>
<br>
<div class="moz-cite-prefix">On 23/05/15 11:27, luiz americo pereira
camara wrote:<br>
</div>
<blockquote
cite="mid:CAMa0j622mDrGDncewTspfV9Rhv0EE3nqNOvFGLNFB_Ykjr298A@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>Check for the property PriorInstanceRunning in FormDestroy<br>
<br>
</div>
Luiz<br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">2015-05-23 7:12 GMT-03:00 Martin <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:mailinglists@collins-email.co.uk"
target="_blank">mailinglists@collins-email.co.uk</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Just need a little advice on placement of code please,
thanks in advance.<br>
<br>
I wanted my app to have only one instance, so found
uniqueinstance - <a moz-do-not-send="true"
href="http://wiki.lazarus.freepascal.org/UniqueInstance"
target="_blank">http://wiki.lazarus.freepascal.org/UniqueInstance</a>
(it has the ability to pass the command line parameters from
the second to the first instance which is something I want
but haven't got round to testing yet!)<br>
<br>
There's no problem with uniqueinstance, from reading the
source I think that it's terminating the second instance
before the onshow event of the main form so I'm guessing
that the formcreate and formdestroy events of the main form
from the second instance still occur and that's where I
think my problem is.<br>
<br>
I am using the formcreate event to parse the command line
arguments to the constructor of my main class, which amongst
other things unzips files to the /tmp directory. I then use
the formdestroy to clean up, deleting the files in the /tmp
directory.<br>
<br>
If I start a second instance with the same command line
parameters as the first, uniqueinstance terminates the
second instance and no second form is seen on screen.
However, all the files are deleted from /tmp (formdestroy)
so they are no longer available to the first instance so it
fails. (I know in a real life situation it would be unlikely
that the second instance would be trying to open the same
files as the first, but not impossible.)<br>
<br>
So either I use some form of file locking or keep
uniqueinstance and move my code. I just wanted some advice
please, as to where people on the list would suggest I put
the code to parse the command line parameters to the
constructor of my main class and/or clean up code. I was
looking at some of the application events in the myapp.lpr
file but I am not sure if that is the right place? Any help
gratefully received.<br>
<br>
Thanks,<br>
<br>
Martin Collins<br>
<br>
--<br>
_______________________________________________<br>
Lazarus mailing list<br>
<a moz-do-not-send="true"
href="mailto:Lazarus@lists.lazarus.freepascal.org"
target="_blank">Lazarus@lists.lazarus.freepascal.org</a><br>
<a moz-do-not-send="true"
href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus"
target="_blank">http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus</a><br>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">--
_______________________________________________
Lazarus mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Lazarus@lists.lazarus.freepascal.org">Lazarus@lists.lazarus.freepascal.org</a>
<a class="moz-txt-link-freetext" href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus">http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus</a>
</pre>
</blockquote>
<br>
</body>
</html>