Added lockfile feature, to prevent multiple launches within 30 seconds
(due to over-clicking, for example).
This commit is contained in:
parent
6752deb266
commit
00c5d44b96
5 changed files with 144 additions and 11 deletions
|
|
@ -7,7 +7,15 @@ bill@newbreedsoftware.com
|
||||||
http://www.newbreedsoftware.com/tuxpaint/
|
http://www.newbreedsoftware.com/tuxpaint/
|
||||||
|
|
||||||
|
|
||||||
2004.September.04 (0.9.14) [cvs]
|
2004.September.13 (0.9.14) [cvs]
|
||||||
|
* Added lockfile support, to prevent Tux Paint from being launched more
|
||||||
|
than once every 30 seconds. (Disable with "--nolockfile" command-line
|
||||||
|
argument.) Thanks to Darci Lindgren for suggestion the feature, and
|
||||||
|
Mark K. Kim for suggesting it be time-based.
|
||||||
|
|
||||||
|
(Lockfile is "lockfile.dat" in "~/.tuxpaint/" on Linux/Unix, and
|
||||||
|
"userdata\" on Windows.)
|
||||||
|
|
||||||
* Updated Catalan translation.
|
* Updated Catalan translation.
|
||||||
Pere Pujal Carabantes <ppujal@airtel.net>
|
Pere Pujal Carabantes <ppujal@airtel.net>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
[2]bill@newbreedsoftware.com
|
[2]bill@newbreedsoftware.com
|
||||||
[3]http://www.newbreedsoftware.com/tuxpaint/
|
[3]http://www.newbreedsoftware.com/tuxpaint/
|
||||||
|
|
||||||
June 14, 2002 - June 20, 2004
|
June 14, 2002 - September 13, 2004
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -384,6 +384,8 @@ Options
|
||||||
|----------------------+--------------------+-----------|
|
|----------------------+--------------------+-----------|
|
||||||
|british-english |british | |
|
|british-english |british | |
|
||||||
|----------------------+--------------------+-----------|
|
|----------------------+--------------------+-----------|
|
||||||
|
|bulgarian | | |
|
||||||
|
|----------------------+--------------------+-----------|
|
||||||
|catalan |catala | |
|
|catalan |catala | |
|
||||||
|----------------------+--------------------+-----------|
|
|----------------------+--------------------+-----------|
|
||||||
|chinese |simplified-chinese | |
|
|chinese |simplified-chinese | |
|
||||||
|
|
@ -553,6 +555,23 @@ Options
|
||||||
Only your own configuration file, "~/.tuxpaintrc", if it
|
Only your own configuration file, "~/.tuxpaintrc", if it
|
||||||
exists, will be used.
|
exists, will be used.
|
||||||
|
|
||||||
|
--nolockfile
|
||||||
|
|
||||||
|
By default, Tux Paint uses what's known as a 'lockfile' to
|
||||||
|
prevent it from being launched more than once in
|
||||||
|
30 seconds. (This is to avoid accidentally running
|
||||||
|
multiple copies; for example, by double-clicking a
|
||||||
|
single-click launcher, or simply impatiently clicking the
|
||||||
|
icon multiple times.)
|
||||||
|
|
||||||
|
To make Tux Paint ignore the lockfile, allowing it to run
|
||||||
|
again, even if it was just launched less than 30 seconds
|
||||||
|
ago, run Tux Paint with the '--nolockfile' option on the
|
||||||
|
command-line.
|
||||||
|
|
||||||
|
By default, the lockfile is stored in "~/.tuxpaint/" under
|
||||||
|
Linux and Unix, and "userdata\" under Windows.
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Command-Line Informational Options
|
Command-Line Informational Options
|
||||||
|
|
@ -606,6 +625,8 @@ Options
|
||||||
|---------------+-------------------+---------------------|
|
|---------------+-------------------+---------------------|
|
||||||
|be_BY |Bielaruskaja |Belarusian |
|
|be_BY |Bielaruskaja |Belarusian |
|
||||||
|---------------+-------------------+---------------------|
|
|---------------+-------------------+---------------------|
|
||||||
|
|bg_BG | |Bulgarian |
|
||||||
|
|---------------+-------------------+---------------------|
|
||||||
|br_FR |Brezhoneg |Breton |
|
|br_FR |Brezhoneg |Breton |
|
||||||
|---------------+-------------------+---------------------|
|
|---------------+-------------------+---------------------|
|
||||||
|ca_ES |Catal`a |Catalan |
|
|ca_ES |Catal`a |Catalan |
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ New Breed Software</p>
|
||||||
<p><a href="mailto:bill@newbreedsoftware.com">bill@newbreedsoftware.com</a><br>
|
<p><a href="mailto:bill@newbreedsoftware.com">bill@newbreedsoftware.com</a><br>
|
||||||
<a href="http://www.newbreedsoftware.com/tuxpaint/">http://www.newbreedsoftware.com/tuxpaint/</a></p>
|
<a href="http://www.newbreedsoftware.com/tuxpaint/">http://www.newbreedsoftware.com/tuxpaint/</a></p>
|
||||||
|
|
||||||
<p>June 14, 2002 - August 19, 2004</p>
|
<p>June 14, 2002 - September 13, 2004</p>
|
||||||
</center>
|
</center>
|
||||||
|
|
||||||
<hr size=2 noshade>
|
<hr size=2 noshade>
|
||||||
|
|
@ -820,6 +820,24 @@ New Breed Software</p>
|
||||||
<p>Only your own configuration file, "<code>~/.tuxpaintrc</code>",
|
<p>Only your own configuration file, "<code>~/.tuxpaintrc</code>",
|
||||||
if it exists, will be used.</p>
|
if it exists, will be used.</p>
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
|
<dt><code><b>--nolockfile</b></code></dt>
|
||||||
|
<dd>
|
||||||
|
<p>By default, Tux Paint uses what's known as a 'lockfile'
|
||||||
|
to prevent it from being launched more than once in 30 seconds.
|
||||||
|
(This is to avoid accidentally running multiple copies; for example,
|
||||||
|
by double-clicking a single-click launcher, or simply
|
||||||
|
impatiently clicking the icon multiple times.)</p>
|
||||||
|
|
||||||
|
<p>To make Tux Paint ignore the lockfile, allowing it to
|
||||||
|
run again, even if it was just launched less than 30 seconds
|
||||||
|
ago, run Tux Paint with the '<code>--nolockfile</code>' option
|
||||||
|
on the command-line.</p>
|
||||||
|
|
||||||
|
<p>By default, the lockfile is stored in
|
||||||
|
"<code>~/.tuxpaint/</code>" under Linux and Unix,
|
||||||
|
and "<code>userdata\</code>" under Windows.</p>
|
||||||
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
.\" tuxpaint.1 - 2004.08.19
|
.\" tuxpaint.1 - 2004.09.13
|
||||||
.TH TUXPAINT 1 "19 Aug 2004" "0.9.14" "Tux Paint"
|
.TH TUXPAINT 1 "13 Sep 2004" "0.9.14" "Tux Paint"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
tuxpaint -- A drawing program for young children.
|
tuxpaint -- A drawing program for young children.
|
||||||
|
|
||||||
|
|
@ -65,7 +65,7 @@ tuxpaint -- A drawing program for young children.
|
||||||
|
|
||||||
.TP 9
|
.TP 9
|
||||||
.B tuxpaint
|
.B tuxpaint
|
||||||
[\-\-nosysconfig]
|
[\-\-nosysconfig] [\-\-nolockfile]
|
||||||
|
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.PP
|
.PP
|
||||||
|
|
@ -403,6 +403,14 @@ Display a lists of all supported languages.
|
||||||
With this option, \fITux Paint\fP will not attempt to read the
|
With this option, \fITux Paint\fP will not attempt to read the
|
||||||
system-wide configuration file (typically \fI/etc/tuxpaint/tuxpaint.conf\fP).
|
system-wide configuration file (typically \fI/etc/tuxpaint/tuxpaint.conf\fP).
|
||||||
|
|
||||||
|
.TP 8
|
||||||
|
.B \-\-nolockfile
|
||||||
|
By default, \fITux Paint\fP uses a lockfile (stored in the user's
|
||||||
|
local Tux Paint directory) which prevents it from being launched more than
|
||||||
|
once in 30 seconds. (Sometimes children get too eager, or user interfaces
|
||||||
|
only require one click, but users think they need to double-click.)
|
||||||
|
This option makes \fITux Paint\fP ignore the current lockfile.
|
||||||
|
|
||||||
.SH ENVIRONMENT
|
.SH ENVIRONMENT
|
||||||
.l
|
.l
|
||||||
While \fITux Paint\fP may refer to a number of environment variables indirectly
|
While \fITux Paint\fP may refer to a number of environment variables indirectly
|
||||||
|
|
@ -435,7 +443,8 @@ User's configuration file. It can be used to set default options
|
||||||
override any settings in the system-wide configuration file.
|
override any settings in the system-wide configuration file.
|
||||||
.RS
|
.RS
|
||||||
.PP
|
.PP
|
||||||
(Not created or edited automatically; must be created manually.)
|
(Not created or edited automatically; must be created manually.
|
||||||
|
You can do this by hand, or use '\fITux Paint Config.\fP.')
|
||||||
.RE
|
.RE
|
||||||
.TP 8
|
.TP 8
|
||||||
.B $HOME/.tuxpaint/saved/
|
.B $HOME/.tuxpaint/saved/
|
||||||
|
|
@ -455,6 +464,16 @@ is re-run.)
|
||||||
.PP
|
.PP
|
||||||
(Created when \fITux Paint\fP is \fIQuit\fP.)
|
(Created when \fITux Paint\fP is \fIQuit\fP.)
|
||||||
.RE
|
.RE
|
||||||
|
.TP 8
|
||||||
|
.B $HOME/.tuxpaint/lockfile.dat
|
||||||
|
A lockfile that prevents \fITux Paint\fP from being launched more than once
|
||||||
|
every 30 seconds. Disable checking the lockfile by using the
|
||||||
|
'\-\-nolockfile' command-line argument.
|
||||||
|
.RS
|
||||||
|
.PP
|
||||||
|
(There's no reason to delete the lockfile, as it contains a timestamp
|
||||||
|
inside which causes it to expire after 30 seconds.)
|
||||||
|
.RE
|
||||||
|
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,12 @@
|
||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
June 14, 2002 - September 4, 2004
|
June 14, 2002 - September 13, 2004
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#define VER_VERSION "0.9.14"
|
#define VER_VERSION "0.9.14"
|
||||||
#define VER_DATE "2004-09-04"
|
#define VER_DATE "2004-09-13"
|
||||||
|
|
||||||
|
|
||||||
/* #define DEBUG */
|
/* #define DEBUG */
|
||||||
|
|
@ -3746,7 +3746,7 @@ void show_usage(FILE * f, char * prg)
|
||||||
#endif
|
#endif
|
||||||
" %s [--printdelay=SECONDS]\n"
|
" %s [--printdelay=SECONDS]\n"
|
||||||
" %s [--lang LANGUAGE | --locale LOCALE | --lang help]\n"
|
" %s [--lang LANGUAGE | --locale LOCALE | --lang help]\n"
|
||||||
" %s [--nosysconfig]\n"
|
" %s [--nosysconfig] [--nolockfile]\n"
|
||||||
/* " %s [--record FILE | --playback FILE]\n" */
|
/* " %s [--record FILE | --playback FILE]\n" */
|
||||||
"\n",
|
"\n",
|
||||||
prg, prg,
|
prg, prg,
|
||||||
|
|
@ -3903,7 +3903,7 @@ const char *getfilename(const char* path)
|
||||||
|
|
||||||
void setup(int argc, char * argv[])
|
void setup(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
int i, ok_to_use_sysconfig;
|
int i, ok_to_use_sysconfig, ok_to_use_lockfile;
|
||||||
char str[128];
|
char str[128];
|
||||||
char * upstr;
|
char * upstr;
|
||||||
SDL_Color black = {0, 0, 0, 0};
|
SDL_Color black = {0, 0, 0, 0};
|
||||||
|
|
@ -3961,6 +3961,7 @@ void setup(int argc, char * argv[])
|
||||||
playfile = NULL;
|
playfile = NULL;
|
||||||
recording = 0;
|
recording = 0;
|
||||||
playing = 0;
|
playing = 0;
|
||||||
|
ok_to_use_lockfile = 1;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __BEOS__
|
#ifdef __BEOS__
|
||||||
|
|
@ -3979,6 +3980,7 @@ void setup(int argc, char * argv[])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Load options from global config file: */
|
/* Load options from global config file: */
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
|
@ -4370,6 +4372,11 @@ void setup(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
debug("Not using system config.");
|
debug("Not using system config.");
|
||||||
}
|
}
|
||||||
|
else if (strcmp(argv[i], "--nolockfile") == 0)
|
||||||
|
{
|
||||||
|
debug("Not using lockfile");
|
||||||
|
ok_to_use_lockfile = 0;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
show_usage(stderr, (char *) getfilename(argv[0]));
|
show_usage(stderr, (char *) getfilename(argv[0]));
|
||||||
|
|
@ -4691,6 +4698,66 @@ void setup(int argc, char * argv[])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Test for lockfile, if we're using one: */
|
||||||
|
|
||||||
|
if (ok_to_use_lockfile)
|
||||||
|
{
|
||||||
|
char * lock_fname;
|
||||||
|
FILE * fi;
|
||||||
|
time_t time_lock, time_now;
|
||||||
|
|
||||||
|
|
||||||
|
/* Get the current time: */
|
||||||
|
|
||||||
|
time_now = time(NULL);
|
||||||
|
|
||||||
|
|
||||||
|
/* Look for the lockfile... */
|
||||||
|
|
||||||
|
lock_fname = get_fname("lockfile.dat");
|
||||||
|
|
||||||
|
fi = fopen(lock_fname, "r");
|
||||||
|
if (fi != NULL)
|
||||||
|
{
|
||||||
|
/* If it exists, read its contents: */
|
||||||
|
|
||||||
|
if (fread(&time_lock, sizeof(time_t), 1, fi) > 0)
|
||||||
|
{
|
||||||
|
/* Has it not been 30 seconds yet? */
|
||||||
|
|
||||||
|
if (time_now < time_lock + 30)
|
||||||
|
{
|
||||||
|
/* FIXME: Wrap in gettext() */
|
||||||
|
printf("\nYou're already running a copy of Tux Paint!\n\n");
|
||||||
|
|
||||||
|
fclose(fi);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fi);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Okay to run; create/update the lockfile */
|
||||||
|
|
||||||
|
fi = fopen(lock_fname, "w");
|
||||||
|
if (fi != NULL)
|
||||||
|
{
|
||||||
|
/* If we can write to it, do so! */
|
||||||
|
|
||||||
|
fwrite(&time_now, sizeof(time_t), 1, fi);
|
||||||
|
fclose(fi);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"\nWarning: I couldn't create the lockfile (%s)\n"
|
||||||
|
"The error that occurred was:\n"
|
||||||
|
"%s\n\n", lock_fname, strerror(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Init SDL Video: */
|
/* Init SDL Video: */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue