Commit 81a758dd authored by Sven Neumann's avatar Sven Neumann

applied patches to GAP provided by Wolfgang Hofer


--Sven
parent 86b0bd74
2000-12-03 Sven Neumann <sven@gimp.org>
* PLUGIN_MAINTAINERS: changed email address of Wolfgang Hofer
* plug-ins/gap/README
* plug-ins/gap/gap_decode_mpeg_main.c
* plug-ins/gap/gap_decode_xanim.c
* plug-ins/gap/gap_filter_codegen.c
* plug-ins/gap/gap_filter_foreach.c
* plug-ins/gap/gap_filter_main.c
* plug-ins/gap/gap_frontends_main.c
* plug-ins/gap/gap_lib.c
* plug-ins/gap/gap_lib.h
* plug-ins/gap/gap_main.c
* plug-ins/gap/gap_match.c
* plug-ins/gap/gap_mod_layer.c
* plug-ins/gap/gap_mov_dialog.c
* plug-ins/gap/gap_mov_dialog.h
* plug-ins/gap/gap_mov_exec.c
* plug-ins/gap/gap_mov_exec.h
* plug-ins/gap/gap_navigator_dialog.c
* plug-ins/gap/resize.c
* plug-ins/gap/sel-to-anim-img.scm:
applied patches provided by Wolfgang Hofer <hof@gimp.org>
- Bugfix: replaced MovePath's intern Algorithm for calculating
Values between controlpoints (the old Algorithm fails sometimes
especially if only 1 controlpoint is used, or if you have n
frames and n-1 controlpoints)
- new e-mail adress
- replaced sprintf (used g_strdup_printf g_snprintf)
- procedures for gap locks, check for locking processes pid
- NONINTERACTIVE PDB Interface(s) for MovePath
plug_in_gap_get_animinfo, plug_in_gap_set_framerate
- FRAME based Stepmodes for MovePath
- increased controlpoint limit GAP_MOV_MAX_POINT (256 -> 1024)
2000-12-02 Michael Natterer <mitch@gimp.org>
* plug-ins/print/README
......
......@@ -195,8 +195,8 @@ SIZE : 19.6 kB in 1 file (only C files counted)
COMMENT :
-----------
NAME : curve_bend
AUTHOR : Wolfgang Hofer <hof@hotbot.com>
MAINTAINER : Wolfgang Hofer <hof@hotbot.com>
AUTHOR : Wolfgang Hofer <hof@gimp.org>
MAINTAINER : Wolfgang Hofer <hof@gimp.org>
SIZE : 105.0 kB in 1 file (only C files counted)
COMMENT :
-----------
......@@ -315,8 +315,8 @@ SIZE : 21.5 kB in 1 file (only C files counted)
COMMENT :
-----------
NAME : gap
AUTHOR : Wolfgang Hofer <hof@hotbot.com>
MAINTAINER : Wolfgang Hofer <hof@hotbot.com>
AUTHOR : Wolfgang Hofer <hof@gimp.org>
MAINTAINER : Wolfgang Hofer <hof@gimp.org>
SIZE : 813.5 kB in 25 files (only C files counted)
COMMENT :
-----------
......@@ -724,7 +724,7 @@ COMMENT :
-----------
NAME : sample_colorize
AUTHOR : Wolfgang Hofer
MAINTAINER : Wolfgang Hofer <hof@hotbot.com>
MAINTAINER : Wolfgang Hofer <hof@gimp.org>
SIZE : 92.6 kB in 1 file (only C files counted)
COMMENT :
-----------
......@@ -976,7 +976,7 @@ COMMENT :
-----------
NAME : xjt
AUTHOR : Wolfgang Hofer
MAINTAINER : Wolfgang Hofer <hof@hotbot.com>
MAINTAINER : Wolfgang Hofer <hof@gimp.org>
SIZE : 169.6 kB in 3 files (only C files counted)
COMMENT :
-----------
......
Project gap "Gimp Animation Package" 04. June 2000 release 1.1.23a
Project gap "Gimp Animation Package" 25. Nov 2000 release 1.1.29b
--------------------------------------------------------------------
Introduction
......@@ -130,6 +130,10 @@ Write (encode)
--------------------------------------------------------------------
Change Log
--------------------------------------------------------------------
- 1.1.29b - Frame Based Stepmodes in MovePath
- NONINTERACTIVE interface for Move Path
- Inform about Locks in Dialog Window,
(clear lock if locking process does not exist --UNIX only)
- 1.1.20a - MovePath
- AnimPreview
- Keyframes
......@@ -477,6 +481,24 @@ WebTip: My GIMP-page http://pages.hotbot.com/arts/hof/index.html
the Layers of the SourceImage are stepped through,
and the next handled frame recieves the next
Layer from the Source_images Layerstack.
For the Frame based Stepmodes ("Frame Loop", "Frame PingPong" ...)
the selected Source(Layer) should be a Layer of another AnimFrame.
In the Frame based Stepmodes the Source Object is considered
as AnimFrames and stepping is done from frame to frame
(and not from layer to layer)
The inserted Layer is always a copy of one Frame of the
source object Animation (no matter which Src Layer was selected)
where all the visible source Layers are merged.
The FrameBased Modes can be used to mix Videos with many frames,
because there is no need to convert one of the videos to
a multilayer image.
If you use a normal Image (that is not an AnimFrame) as Source
for the FrameBased Stepmodes it acts like an Animation with
only one frame.
The copies of the SourceLayer(s) were modified by transitions
with varying Parameters.
......
......@@ -58,7 +58,8 @@
/*
* Changelog:
*
* 2000/02/07 v1.1.16a: hof: replaced sprintf by g_strdup_printf
* 2000/11/30 v1.1.29b: hof: new e-mail adress
* 2000/02/07 v1.1.16a: hof: used g_strdup_printf
* 2000/01/06 v1.1.14a: hof: save thumbnails .xvpics p_gimp_file_save_thumbnail
* store framerate in video_info file
* 1999/11/25 v1.1.11.b: Initial release. [hof]
......@@ -172,9 +173,9 @@ query ()
gimp_install_procedure ("plug_in_gap_decode_mpeg",
"Split MPEG1 movies into animframes and load 1st frame",
"Split MPEG1 movies into single frames (image files on disk) and load 1st frame. audio tracks are ignored",
"Wolfgang Hofer (hof@hotbot.com)",
"Wolfgang Hofer (hof@gimp.org)",
"Wolfgang Hofer",
"2000/01/01",
"2000/11/30",
N_("<Image>/Video/Split Video to Frames/MPEG1"),
NULL,
GIMP_PLUGIN,
......@@ -184,9 +185,9 @@ query ()
gimp_install_procedure ("extension_gap_decode_mpeg",
"Split MPEG1 movies into animframes and load 1st frame",
"Split MPEG1 movies into single frames (image files on disk) and load 1st frame. audio tracks are ignored",
"Wolfgang Hofer (hof@hotbot.com)",
"Wolfgang Hofer (hof@gimp.org)",
"Wolfgang Hofer",
"2000/01/01",
"2000/11/30",
N_("<Toolbox>/Xtns/Split Video to Frames/MPEG1"),
NULL,
GIMP_EXTENSION,
......
......@@ -48,6 +48,7 @@
*/
/* revision history
* 1.1.29b; 2000/11/30 hof: used g_snprintf
* 1.1.17b; 2000/02/26 hof: bugfixes
* 1.1.14a; 1999/11/22 hof: fixed gcc warning (too many arguments for format)
* 1.1.13a; 1999/11/22 hof: first release
......@@ -356,18 +357,18 @@ p_overwrite_dialog(char *filename, gint overwrite_mode)
static void
p_build_xanim_framename(char *framename, gint32 frame_nr, char *ext)
p_build_xanim_framename(char *framename, gint32 sizeof_framename, gint32 frame_nr, char *ext)
{
sprintf(framename, "%s/frame%d.%s",
g_snprintf(framename, sizeof_framename, "%s/frame%d.%s",
global_xanim_input_dir,
(int)frame_nr,
ext);
}
static void
p_build_gap_framename(char *framename, gint32 frame_nr, char *basename, char *ext)
p_build_gap_framename(char *framename, gint32 sizeof_framename, gint32 frame_nr, char *basename, char *ext)
{
sprintf(framename, "%s%04d.%s", basename, (int)frame_nr, ext);
g_snprintf(framename, sizeof_framename, "%s%04d.%s", basename, (int)frame_nr, ext);
}
int
......@@ -432,7 +433,7 @@ p_convert_frames(gint32 frame_from, gint32 frame_to, char *basename, char *ext,
char l_first_xa_frame[200];
/* load 1st one of those frames generated by xanim */
p_build_xanim_framename(l_first_xa_frame, frame_from, ext);
p_build_xanim_framename(l_first_xa_frame, sizeof(l_first_xa_frame), frame_from, ext);
l_tmp_image_id = p_load_image(l_first_xa_frame);
/* convert the xanim frames (from ppm) to xcf fileformat
......@@ -485,7 +486,7 @@ p_find_max_xanim_frame(gint32 from_nr, char *ext)
while(1 == 1)
{
p_build_xanim_framename(l_frame, l_nr, ext);
p_build_xanim_framename(l_frame, sizeof(l_frame), l_nr, ext);
if(gap_debug) printf("DEBUG find_MAX :%s\n", l_frame);
......@@ -546,8 +547,8 @@ p_rename_frames(gint32 frame_from, gint32 frame_to, char *basename, char *ext)
while (l_frame_nr <= frame_to)
{
p_build_xanim_framename(l_src_frame, l_frame_nr, ext);
p_build_gap_framename(l_dst_frame, l_frame_nr, basename, ext);
p_build_xanim_framename(l_src_frame, sizeof(l_src_frame), l_frame_nr, ext);
p_build_gap_framename(l_dst_frame, sizeof(l_dst_frame), l_frame_nr, basename, ext);
if(!p_file_exists(l_src_frame))
{
......@@ -622,14 +623,14 @@ p_delete_frames(gint32 max_tries, gint32 frame_from, gint32 frame_to, char *ext)
while ((global_delete_number < frame_from) && (l_tries < max_tries))
{
l_next_number = global_delete_number + 1;
p_build_xanim_framename(l_framename, l_next_number, ext);
p_build_xanim_framename(l_framename, sizeof(l_framename), l_next_number, ext);
if (p_file_exists(l_framename))
{
/* if xanim has already written the next frame
* we can delete the previous (unwanted) frame now
*/
p_build_xanim_framename(l_framename, global_delete_number, ext);
p_build_xanim_framename(l_framename, sizeof(l_framename), global_delete_number, ext);
if(gap_debug) printf("delete frame: %s\n", l_framename);
remove(l_framename);
......@@ -786,7 +787,7 @@ p_start_xanim_process(gint32 first_frame, gint32 last_frame,
l_xanim_pid = -1;
/* allocate and prepare args for the xanim call */
sprintf(l_cmd, "%s +f ", global_xanim_prog); /* programname */
g_snprintf(l_cmd, sizeof(l_cmd), "%s +f ", global_xanim_prog); /* programname */
if (extract_audio)
{
......@@ -803,7 +804,7 @@ p_start_xanim_process(gint32 first_frame, gint32 last_frame,
strcat(l_cmd, "+Ee ");
break;
case XAENC_JPEG:
sprintf(l_buf, "+Eq%d ", (int)jpeg_quality);
g_snprintf(l_buf, sizeof(l_buf), "+Eq%d ", (int)jpeg_quality);
strcat(l_cmd, l_buf);
break;
default:
......@@ -816,7 +817,7 @@ p_start_xanim_process(gint32 first_frame, gint32 last_frame,
*/
if (run_xanim_asynchron)
{
sprintf(l_buf, "+Zp%d ", (int)(last_frame +1));
g_snprintf(l_buf, sizeof(l_buf), "+Zp%d ", (int)(last_frame +1));
strcat(l_cmd, l_buf);
}
......@@ -923,7 +924,7 @@ p_start_xanim_process_exec(gint32 first_frame, gint32 last_frame,
args[l_idx] = g_strdup("+Ee");
break;
case XAENC_JPEG:
sprintf(l_buf, "+Eq%d", (int)jpeg_quality);
g_snprintf(l_buf, sizeof(l_buf), "+Eq%d", (int)jpeg_quality);
args[l_idx] = g_strdup(l_buf);
break;
default:
......@@ -935,7 +936,7 @@ p_start_xanim_process_exec(gint32 first_frame, gint32 last_frame,
* to stop xanim exporting frames beyond the requested limit
*/
l_idx++;
sprintf(l_buf, "+Zp%d", (int)(last_frame +1));
g_snprintf(l_buf, sizeof(l_buf), "+Zp%d", (int)(last_frame +1));
args[l_idx] = g_strdup(l_buf);
}
......@@ -1049,7 +1050,7 @@ gap_xanim_decode(GimpRunModeType run_mode)
break;
}
p_build_xanim_framename(l_one_past_last_frame, last_frame +1 , extension);
p_build_xanim_framename(l_one_past_last_frame, sizeof(l_one_past_last_frame), last_frame +1 , extension);
if (extract_video)
{
......@@ -1059,7 +1060,7 @@ gap_xanim_decode(GimpRunModeType run_mode)
/* the input directory already exists,
* remove frames
*/
sprintf(l_cmd, "rm -f %s/*.%s", global_xanim_input_dir, extension);
g_snprintf(l_cmd, sizeof(l_cmd), "rm -f %s/*.%s", global_xanim_input_dir, extension);
system(l_cmd);
}
else
......@@ -1164,7 +1165,7 @@ gap_xanim_decode(GimpRunModeType run_mode)
if (strcmp(l_dst_dir, global_xanim_input_dir) != 0)
{
/* remove input dir with all files */
sprintf(l_cmd, "rm -rf \"%s\"", global_xanim_input_dir);
g_snprintf(l_cmd, sizeof(l_cmd), "rm -rf \"%s\"", global_xanim_input_dir);
system(l_cmd);
}
}
......@@ -1191,7 +1192,7 @@ gap_xanim_decode(GimpRunModeType run_mode)
if(autoload)
{
/* load first frame and add a display */
p_build_gap_framename(l_first_to_laod, first_frame, basename, &extension2[1]);
p_build_gap_framename(l_first_to_laod, sizeof(l_first_to_laod), first_frame, basename, &extension2[1]);
l_rc = p_load_image(l_first_to_laod);
if(l_rc >= 0) gimp_display_new(l_rc);
......
......@@ -11,6 +11,7 @@
*/
/* revision history:
* 1.1.29b; 2000/11/30 hof: used g_snprintf
* version 0.99.00 1999.03.14 hof: Codegeneration of File ./gen_filter_iter_code.c
* splittet into single Files XX_iter_ALT.inc
* bugfixes in code generation
......@@ -84,14 +85,14 @@ p_type_to_string(GimpPDBArgType t)
}
static void p_get_gendate(char *gendate)
static void p_get_gendate(char *gendate, gint32 sizeof_gendate)
{
struct tm *l_t;
long l_ti;
l_ti = time(0L); /* Get UNIX time */
l_t = localtime(&l_ti); /* konvert time to tm struct */
sprintf(gendate, "%02d.%02d.%02d %02d:%02d"
g_snprintf(gendate, sizeof_gendate, "%02d.%02d.%02d %02d:%02d"
, l_t->tm_mday
, l_t->tm_mon + 1
, l_t->tm_year
......@@ -170,7 +171,7 @@ gint p_gen_code_iter_ALT(char *proc_name)
l_rc = 0;
p_get_gendate(&l_gendate[0]);
p_get_gendate(&l_gendate[0], sizeof(l_gendate));
/* Query the gimp application's procedural database
* regarding a particular procedure.
......@@ -199,7 +200,7 @@ gint p_gen_code_iter_ALT(char *proc_name)
if (l_params[1].type != GIMP_PDB_IMAGE) { l_rc = -1; }
if (l_params[2].type != GIMP_PDB_DRAWABLE) { l_rc = -1; }
sprintf(l_filename, "%s_iter_ALT.inc", l_clean_proc_name);
g_snprintf(l_filename, sizeof(l_filename), "%s_iter_ALT.inc", l_clean_proc_name);
l_fp = fopen(l_filename, "w");
if(l_fp != NULL)
{
......@@ -362,7 +363,7 @@ gint p_gen_code_iter(char *proc_name)
gchar l_clean_par_name[256];
l_rc = 0;
p_get_gendate(&l_gendate[0]);
p_get_gendate(&l_gendate[0], sizeof(l_gendate));
/* Query the gimp application's procedural database
* regarding a particular procedure.
......@@ -391,7 +392,7 @@ gint p_gen_code_iter(char *proc_name)
if (l_params[2].type != GIMP_PDB_DRAWABLE) { l_rc = -1; }
sprintf(l_filename, "%s_iter.c", l_clean_proc_name);
g_snprintf(l_filename, sizeof(l_filename), "%s_iter.c", l_clean_proc_name);
l_fp = fopen(l_filename, "w");
if(l_fp != NULL)
......@@ -659,7 +660,7 @@ gint p_gen_code_iter(char *proc_name)
fprintf(l_fp, " static GimpParamDef *return_vals = NULL;\n");
fprintf(l_fp, " static int nreturn_vals = 0;\n");
fprintf(l_fp, "\n");
fprintf(l_fp, " sprintf(l_blurb_text, \"This extension calculates the modified values for one iterationstep for the call of %s\");\n", l_clean_proc_name);
fprintf(l_fp, " g_snprintf(l_blurb_text, sizeof(l_blurb_text), \"This extension calculates the modified values for one iterationstep for the call of %s\");\n", l_clean_proc_name);
fprintf(l_fp, "\n");
fprintf(l_fp, " gimp_install_procedure(\"%s_Iterator\",\n", l_clean_proc_name);
fprintf(l_fp, " l_blurb_text,\n");
......
......@@ -28,6 +28,7 @@
*/
/* revision history:
* 1.1.29b; 2000/11/30 hof: use g_snprintf
* 1.1.28a; 2000/11/05 hof: check for GIMP_PDB_SUCCESS (not for FALSE)
* version 0.97.00 hof: - modul splitted (2.nd part is now gap_filter_pdb.c)
* version 0.96.03 hof: - pitstop dialog provides optional backup on each step
......@@ -132,7 +133,7 @@ static gint p_pitstop(GimpRunModeType run_mode, char *plugin_name, gint text_fla
l_but_argv[0].but_val = 0;
l_but_argv[1].but_txt = _("Cancel");
l_but_argv[1].but_val = -1;
sprintf(l_skip_txt, "Skip %d", (int)layer_idx);
g_snprintf(l_skip_txt, sizeof(l_skip_txt), "Skip %d", (int)layer_idx);
l_but_argv[2].but_txt = l_skip_txt;
l_but_argv[2].but_val = 1;
......@@ -337,7 +338,7 @@ int p_foreach_multilayer(GimpRunModeType run_mode, gint32 image_id,
l_plugin_data_len = p_get_data(plugin_name);
if(l_plugin_data_len > 0)
{
sprintf(l_key_from, "%s_ITER_FROM", plugin_name);
g_snprintf(l_key_from, sizeof(l_key_from), "%s_ITER_FROM", plugin_name);
p_set_data(l_key_from, l_plugin_data_len);
}
else l_rc = -1;
......@@ -387,7 +388,7 @@ int p_foreach_multilayer(GimpRunModeType run_mode, gint32 image_id,
l_plugin_data_len = p_get_data(plugin_name);
if(l_plugin_data_len > 0)
{
sprintf(l_key_to, "%s_ITER_TO", plugin_name);
g_snprintf(l_key_to, sizeof(l_key_to), "%s_ITER_TO", plugin_name);
p_set_data(l_key_to, l_plugin_data_len);
}
else l_rc = -1;
......
......@@ -46,9 +46,10 @@
/* GAP includes */
#include "gap_filter.h"
static char *gap_filter_version = "0.92.00; 1998/01/16";
static char *gap_filter_version = "0.92.01; 2000/11/30";
/* revision history:
* 2000/11/30 v1.1.29b: hof: new e-mail adress
* version 0.92.00 hof: set gap_debug from environment
* version 0.91.01; Tue Dec 23 hof: 1.st (pre) release
*/
......@@ -99,7 +100,7 @@ query ()
gimp_install_procedure("plug_in_gap_layers_run_animfilter",
"This plugin calls another plugin for each layer of an image, varying its settings (to produce animated effects). The called plugin must work on a single drawable and must be able to GIMP_RUN_WITH_LAST_VALS",
"",
"Wolfgang Hofer (hof@hotbot.com)",
"Wolfgang Hofer (hof@gimp.org)",
"Wolfgang Hofer",
gap_filter_version,
N_("<Image>/Filters/Filter all Layers..."),
......
......@@ -41,9 +41,10 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
static char *gap_main_version = "1.1.11b; 1999/11/20";
static char *gap_main_version = "1.1.29b; 2000/11/25";
/* revision history:
* gimp 1.1.29b; 2000/11/25 hof: use gap lock procedures, update e-mail adress + main version
* gimp 1.1.11b; 1999/11/20 hof: added gap_decode_xanim, fixed typo in mpeg encoder menu path
* based on parts that were found in gap_main.c before.
*/
......@@ -121,7 +122,7 @@ query ()
gimp_install_procedure("plug_in_gap_xanim_decode",
"This plugin calls xanim to split any video to anim frames. (xanim exporting edition must be installed on your system)",
"",
"Wolfgang Hofer (hof@hotbot.com)",
"Wolfgang Hofer (hof@gimp.org)",
"Wolfgang Hofer",
gap_main_version,
N_("<Image>/Video/Split Video to Frames/Any XANIM readable..."),
......@@ -133,7 +134,7 @@ query ()
gimp_install_procedure("extension_gap_xanim_decode",
"This plugin calls xanim to split any video to anim frames. (xanim exporting edition must be installed on your system)",
"",
"Wolfgang Hofer (hof@hotbot.com)",
"Wolfgang Hofer (hof@gimp.org)",
"Wolfgang Hofer",
gap_main_version,
N_("<Toolbox>/Xtns/Split Video to Frames/Any XANIM readable..."),
......@@ -145,7 +146,7 @@ query ()
gimp_install_procedure("plug_in_gap_mpeg_encode",
"This plugin calls mpeg_encode to convert anim frames to MPEG1, or just generates a param file for mpeg_encode. (mpeg_encode must be installed on your system)",
"",
"Wolfgang Hofer (hof@hotbot.com)",
"Wolfgang Hofer (hof@gimp.org)",
"Wolfgang Hofer",
gap_main_version,
N_("<Image>/Video/Encode/MPEG1..."),
......@@ -158,7 +159,7 @@ query ()
gimp_install_procedure("plug_in_gap_mpeg2encode",
"This plugin calls mpeg2encode to convert anim frames to MPEG1 or MPEG2, or just generates a param file for mpeg2encode. (mpeg2encode must be installed on your system)",
"",
"Wolfgang Hofer (hof@hotbot.com)",
"Wolfgang Hofer (hof@gimp.org)",
"Wolfgang Hofer",
gap_main_version,
N_("<Image>/Video/Encode/MPEG2..."),
......@@ -179,15 +180,6 @@ run (char *name,
int *nreturn_vals,
GimpParam **return_vals)
{
typedef struct
{
long lock; /* 0 ... NOT Locked, 1 ... locked */
gint32 image_id;
long timestamp; /* locktime not used for now */
} t_lockdata;
t_lockdata l_lock;
static char l_lockname[50];
char *l_env;
char l_extension[32];
......@@ -195,6 +187,7 @@ run (char *name,
GimpRunModeType run_mode;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
gint32 image_id;
gint32 lock_image_id;
gint32 nr;
gint32 l_rc;
......@@ -213,22 +206,18 @@ run (char *name,
run_mode = param[0].data.d_int32;
image_id = -1;
lock_image_id = image_id;
if(gap_debug) fprintf(stderr, "\n\ngap_main: debug name = %s\n", name);
if (strcmp (name, "extension_gap_xanim_decode") != 0)
{
image_id = param[1].data.d_image;
lock_image_id = image_id;
/* check for locks */
l_lock.lock = 0;
sprintf(l_lockname, "plug_in_gap_plugins_LOCK_%d", (int)image_id);
gimp_get_data (l_lockname, &l_lock);
if((l_lock.lock != 0) && (l_lock.image_id == image_id))
if(p_gap_lock_is_locked(lock_image_id, run_mode))
{
fprintf(stderr, "gap_plugin is LOCKED for Image ID=%s\n", l_lockname);
status = GIMP_PDB_EXECUTION_ERROR;
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = status;
......@@ -237,9 +226,7 @@ run (char *name,
/* set LOCK on current image (for all gap_plugins) */
l_lock.lock = 1;
l_lock.image_id = image_id;
gimp_set_data (l_lockname, &l_lock, sizeof(l_lock));
p_gap_lock_set(lock_image_id);
}
if (run_mode == GIMP_RUN_NONINTERACTIVE) {
......@@ -333,8 +320,6 @@ run (char *name,
if (strcmp (name, "extension_gap_xanim_decode") != 0)
{
/* remove LOCK on this image for all gap_plugins */
l_lock.lock = 0;
l_lock.image_id = -1;
gimp_set_data (l_lockname, &l_lock, sizeof(l_lock));
p_gap_lock_remove(lock_image_id);
}
}
......@@ -28,6 +28,7 @@
*/
/* revision history:
* 1.1.29a; 2000/11/23 hof: gap locking (changed to procedures and placed here)
* 1.1.28a; 2000/11/05 hof: check for GIMP_PDB_SUCCESS (not for FALSE)
* 1.1.20a; 2000/04/25 hof: new: p_get_video_paste_name p_vid_edit_clear
* 1.1.17b; 2000/02/27 hof: bug/style fixes
......@@ -63,6 +64,7 @@
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <signal.h> /* for kill */
#ifdef HAVE_SYS_TIMES_H
#include <sys/times.h>
#endif
......@@ -96,6 +98,10 @@
#define mkdir(path,mode) _mkdir(path)
#endif
#ifdef G_OS_WIN32
#include <process.h> /* For _getpid() */
#endif
/* GAP includes */
#include "gap_layer_copy.h"
#include "gap_lib.h"
......@@ -126,6 +132,7 @@ char *
p_alloc_fname_thumbnail(char *name)
{
int l_len;
int l_len2;
int l_idx;
char *l_str;
......@@ -135,7 +142,8 @@ p_alloc_fname_thumbnail(char *name)
}
l_len = strlen(name);
l_str = g_malloc(l_len+10);
l_len2 = l_len + 10;
l_str = g_malloc(l_len2);
strcpy(l_str, name);
if(l_len > 0)
{
......@@ -147,7 +155,7 @@ p_alloc_fname_thumbnail(char *name)
break;
}
}
sprintf(&l_str[l_idx], ".xvpics%s%s", G_DIR_SEPARATOR_S, &name[l_idx]);
g_snprintf(&l_str[l_idx], l_len2 - l_idx, ".xvpics%s%s", G_DIR_SEPARATOR_S, &name[l_idx]);
}
if(gap_debug) printf("p_alloc_fname_thumbnail: thumbname=%s:\n", l_str );
return(l_str);
......@@ -2847,3 +2855,108 @@ gap_vid_edit_paste(GimpRunModeType run_mode, gint32 image_id, long paste_mode)
return(rc);
} /* end gap_vid_edit_paste */
gint32
p_getpid(void)
{
#ifndef G_OS_WIN32
/* for UNIX */
return ((gint32)getpid());
#else
/* hof: dont know how to getpid on windows */
return 0;
#endif
}
gint
p_pid_is_alive(gint32 pid)
{
#ifndef G_OS_WIN32
/* for UNIX */
/* kill with signal 0 checks only if the process is alive (no signal is sent)
* returns 0 if alive, 1 if no process with given pid found.
*/
if (0 == kill(pid, 0))
{
return(TRUE);
}
return (FALSE);
#else
/* hof: dont know how to check on Windows
* assume that process is always alive
* (therefore on Windows locks will not be cleared
* automatically after crashes of the locking process)
*/
return(TRUE);
#endif
}
static void
p_gap_lock_build_lockkey(t_gap_lockdata *lock, gint32 image_id)
{
g_snprintf(lock->key, sizeof(lock->key), "plug_in_gap_plugins_LOCK_%d", (int)image_id);
}
gint
p_gap_lock_is_locked(gint32 image_id, GimpRunModeType run_mode)
{
gint32 l_pid;
t_gap_lockdata l_lock;
/* check for locks */
l_pid = p_getpid();
l_lock.lock = 0;
p_gap_lock_build_lockkey(&l_lock, image_id);
gimp_get_data (l_lock.key, &l_lock);
if((l_lock.lock != 0) && (l_lock.image_id == image_id))
{
if(p_pid_is_alive(l_lock.pid))
{
if(run_mode == GIMP_RUN_INTERACTIVE)
{
gchar *l_lockmsg;
l_lockmsg = g_strdup_printf(_("Cant execute more than 1 Video Function\n"
"on the same AnimFrame Image at the same time\n"
"LOCK ID:%s\n")
, l_lock.key);
gimp_message(l_lockmsg);
g_free(l_lockmsg);
}
printf("GAP plugin is LOCKED ID:%s PID:%d\n", l_lock.key, (int)l_lock.pid);
return(TRUE);
}
}
return(FALSE);
}
void
p_gap_lock_set(gint32 image_id)
{
t_gap_lockdata l_lock;
p_gap_lock_build_lockkey(&l_lock, image_id);
/* set LOCK on image (for all gap_plugins) */
l_lock.lock = 1;
l_lock.image_id = image_id;
l_lock.pid = p_getpid();
gimp_set_data (l_lock.key, &l_lock, sizeof(l_lock));
}