From bae5bae79d976025f623882b4c95703a0da5a9f8 Mon Sep 17 00:00:00 2001 From: Adrian Likins Date: Sun, 1 Feb 1998 01:58:47 +0000 Subject: [PATCH] *plug-ins/ edge.c added a check so it woudlnt segfault when passed a *plug-ins/ edge.c added a check so it woudlnt segfault when passed a non-existend drawable threshold_alpha added a non-interactive mode *app/brightness_contrast.c app/color_balance.c app/colormaps.c app/curves.c app/hue_saturation.c app/posterize.c app/threshold.c -added a check so it wouldnt except a indexed drawable. This was previosly possible via the pdb. -adrian --- ChangeLog | 18 ++++++++++++++++++ app/base/color-balance.c | 4 ++++ app/base/curves.c | 9 +++++++++ app/base/hue-saturation.c | 4 ++++ app/base/threshold.c | 4 ++++ app/brightness_contrast.c | 4 ++++ app/color_balance.c | 4 ++++ app/colormaps.c | 1 + app/curves.c | 9 +++++++++ app/hue_saturation.c | 4 ++++ app/levels.c | 4 ++++ app/posterize.c | 4 ++++ app/threshold.c | 4 ++++ app/tools/brightness_contrast.c | 4 ++++ app/tools/color_balance.c | 4 ++++ app/tools/curves.c | 9 +++++++++ app/tools/gimpbrightnesscontrasttool.c | 4 ++++ app/tools/gimpcolorbalancetool.c | 4 ++++ app/tools/gimpcurvestool.c | 9 +++++++++ app/tools/gimphuesaturationtool.c | 4 ++++ app/tools/gimplevelstool.c | 4 ++++ app/tools/gimpposterizetool.c | 4 ++++ app/tools/gimpthresholdtool.c | 4 ++++ app/tools/hue_saturation.c | 4 ++++ app/tools/levels.c | 4 ++++ app/tools/posterize.c | 4 ++++ app/tools/threshold.c | 4 ++++ plug-ins/common/edge.c | 8 +++++++- plug-ins/common/threshold_alpha.c | 8 +++++++- plug-ins/edge/edge.c | 8 +++++++- plug-ins/threshold_alpha/threshold_alpha.c | 8 +++++++- 31 files changed, 167 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index c3b5e093e7..ef440d6542 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +Sat Jan 31 20:49:11 EST 1998 Adrian Likins + + *plug-ins/ edge.c + added a check so it woudlnt segfault when + passed a non-existend drawable + + threshold_alpha added a non-interactive mode + + *app/brightness_contrast.c + app/color_balance.c + app/colormaps.c + app/curves.c + app/hue_saturation.c + app/posterize.c + app/threshold.c + -added an additioanl check so it wouldnt except + a indexed drawable. This was previosly possible via the pdb. + Sat Jan 31 00:16:22 PST 1998 Manish Singh * plug-ins/xpm/xpm.c: Changed to use g_strcasecmp diff --git a/app/base/color-balance.c b/app/base/color-balance.c index 553be508ab..5046f0d3e8 100644 --- a/app/base/color-balance.c +++ b/app/base/color-balance.c @@ -954,6 +954,10 @@ color_balance_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* transfer_mode */ if (success) { diff --git a/app/base/curves.c b/app/base/curves.c index 50cf81e316..cb62b26616 100644 --- a/app/base/curves.c +++ b/app/base/curves.c @@ -1350,6 +1350,11 @@ curves_spline_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + + /* channel */ if (success) { @@ -1498,6 +1503,10 @@ curves_explicit_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* channel */ if (success) { diff --git a/app/base/hue-saturation.c b/app/base/hue-saturation.c index 129b54fe23..4237f1987a 100644 --- a/app/base/hue-saturation.c +++ b/app/base/hue-saturation.c @@ -1099,6 +1099,10 @@ hue_saturation_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* hue_range */ if (success) { diff --git a/app/base/threshold.c b/app/base/threshold.c index 8658864aa8..849f780e37 100644 --- a/app/base/threshold.c +++ b/app/base/threshold.c @@ -676,6 +676,10 @@ threshold_invoker (args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* low threhsold */ if (success) { diff --git a/app/brightness_contrast.c b/app/brightness_contrast.c index 8624faa4e1..ef92f7f591 100644 --- a/app/brightness_contrast.c +++ b/app/brightness_contrast.c @@ -702,6 +702,10 @@ brightness_contrast_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* brightness */ if (success) { diff --git a/app/color_balance.c b/app/color_balance.c index 553be508ab..5046f0d3e8 100644 --- a/app/color_balance.c +++ b/app/color_balance.c @@ -954,6 +954,10 @@ color_balance_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* transfer_mode */ if (success) { diff --git a/app/colormaps.c b/app/colormaps.c index 0927438020..187aad58e7 100644 --- a/app/colormaps.c +++ b/app/colormaps.c @@ -205,6 +205,7 @@ get_standard_colormaps () if (g_visual->depth == 8 && info->reserved_pixels == NULL) { g_print("GIMP cannot get enough colormaps to boot.\n"); g_print("Try exiting other color intensive applications.\n"); + g_print("Also try enabling the (install-colormap) option in gimprc.\n"); swapping_free (); brushes_free (); patterns_free (); diff --git a/app/curves.c b/app/curves.c index 50cf81e316..cb62b26616 100644 --- a/app/curves.c +++ b/app/curves.c @@ -1350,6 +1350,11 @@ curves_spline_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + + /* channel */ if (success) { @@ -1498,6 +1503,10 @@ curves_explicit_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* channel */ if (success) { diff --git a/app/hue_saturation.c b/app/hue_saturation.c index 129b54fe23..4237f1987a 100644 --- a/app/hue_saturation.c +++ b/app/hue_saturation.c @@ -1099,6 +1099,10 @@ hue_saturation_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* hue_range */ if (success) { diff --git a/app/levels.c b/app/levels.c index 50f8001a50..ceb182c7fa 100644 --- a/app/levels.c +++ b/app/levels.c @@ -1523,6 +1523,10 @@ levels_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* channel */ if (success) { diff --git a/app/posterize.c b/app/posterize.c index 22555f16ad..816427f2a0 100644 --- a/app/posterize.c +++ b/app/posterize.c @@ -507,6 +507,10 @@ posterize_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* levels */ if (success) { diff --git a/app/threshold.c b/app/threshold.c index 8658864aa8..849f780e37 100644 --- a/app/threshold.c +++ b/app/threshold.c @@ -676,6 +676,10 @@ threshold_invoker (args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* low threhsold */ if (success) { diff --git a/app/tools/brightness_contrast.c b/app/tools/brightness_contrast.c index 8624faa4e1..ef92f7f591 100644 --- a/app/tools/brightness_contrast.c +++ b/app/tools/brightness_contrast.c @@ -702,6 +702,10 @@ brightness_contrast_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* brightness */ if (success) { diff --git a/app/tools/color_balance.c b/app/tools/color_balance.c index 553be508ab..5046f0d3e8 100644 --- a/app/tools/color_balance.c +++ b/app/tools/color_balance.c @@ -954,6 +954,10 @@ color_balance_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* transfer_mode */ if (success) { diff --git a/app/tools/curves.c b/app/tools/curves.c index 50cf81e316..cb62b26616 100644 --- a/app/tools/curves.c +++ b/app/tools/curves.c @@ -1350,6 +1350,11 @@ curves_spline_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + + /* channel */ if (success) { @@ -1498,6 +1503,10 @@ curves_explicit_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* channel */ if (success) { diff --git a/app/tools/gimpbrightnesscontrasttool.c b/app/tools/gimpbrightnesscontrasttool.c index 8624faa4e1..ef92f7f591 100644 --- a/app/tools/gimpbrightnesscontrasttool.c +++ b/app/tools/gimpbrightnesscontrasttool.c @@ -702,6 +702,10 @@ brightness_contrast_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* brightness */ if (success) { diff --git a/app/tools/gimpcolorbalancetool.c b/app/tools/gimpcolorbalancetool.c index 553be508ab..5046f0d3e8 100644 --- a/app/tools/gimpcolorbalancetool.c +++ b/app/tools/gimpcolorbalancetool.c @@ -954,6 +954,10 @@ color_balance_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* transfer_mode */ if (success) { diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c index 50cf81e316..cb62b26616 100644 --- a/app/tools/gimpcurvestool.c +++ b/app/tools/gimpcurvestool.c @@ -1350,6 +1350,11 @@ curves_spline_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + + /* channel */ if (success) { @@ -1498,6 +1503,10 @@ curves_explicit_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* channel */ if (success) { diff --git a/app/tools/gimphuesaturationtool.c b/app/tools/gimphuesaturationtool.c index 129b54fe23..4237f1987a 100644 --- a/app/tools/gimphuesaturationtool.c +++ b/app/tools/gimphuesaturationtool.c @@ -1099,6 +1099,10 @@ hue_saturation_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* hue_range */ if (success) { diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c index 50f8001a50..ceb182c7fa 100644 --- a/app/tools/gimplevelstool.c +++ b/app/tools/gimplevelstool.c @@ -1523,6 +1523,10 @@ levels_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* channel */ if (success) { diff --git a/app/tools/gimpposterizetool.c b/app/tools/gimpposterizetool.c index 22555f16ad..816427f2a0 100644 --- a/app/tools/gimpposterizetool.c +++ b/app/tools/gimpposterizetool.c @@ -507,6 +507,10 @@ posterize_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* levels */ if (success) { diff --git a/app/tools/gimpthresholdtool.c b/app/tools/gimpthresholdtool.c index 8658864aa8..849f780e37 100644 --- a/app/tools/gimpthresholdtool.c +++ b/app/tools/gimpthresholdtool.c @@ -676,6 +676,10 @@ threshold_invoker (args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* low threhsold */ if (success) { diff --git a/app/tools/hue_saturation.c b/app/tools/hue_saturation.c index 129b54fe23..4237f1987a 100644 --- a/app/tools/hue_saturation.c +++ b/app/tools/hue_saturation.c @@ -1099,6 +1099,10 @@ hue_saturation_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* hue_range */ if (success) { diff --git a/app/tools/levels.c b/app/tools/levels.c index 50f8001a50..ceb182c7fa 100644 --- a/app/tools/levels.c +++ b/app/tools/levels.c @@ -1523,6 +1523,10 @@ levels_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* channel */ if (success) { diff --git a/app/tools/posterize.c b/app/tools/posterize.c index 22555f16ad..816427f2a0 100644 --- a/app/tools/posterize.c +++ b/app/tools/posterize.c @@ -507,6 +507,10 @@ posterize_invoker (Argument *args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* levels */ if (success) { diff --git a/app/tools/threshold.c b/app/tools/threshold.c index 8658864aa8..849f780e37 100644 --- a/app/tools/threshold.c +++ b/app/tools/threshold.c @@ -676,6 +676,10 @@ threshold_invoker (args) if (drawable == NULL || gimage != drawable_gimage (drawable)) success = FALSE; } + /* make sure the drawable is not indexed color */ + if (success) + success = ! drawable_indexed (drawable); + /* low threhsold */ if (success) { diff --git a/plug-ins/common/edge.c b/plug-ins/common/edge.c index 56bc3bdd5f..8d09484a65 100644 --- a/plug-ins/common/edge.c +++ b/plug-ins/common/edge.c @@ -225,7 +225,8 @@ run (gchar *name, break; } - if (status == STATUS_SUCCESS) + /* make sure the drawable exist and is not indexed */ + if (gimp_drawable_color (drawable->id) || gimp_drawable_gray (drawable->id)) { gimp_progress_init ("Edge detection..."); @@ -242,6 +243,11 @@ run (gchar *name, if (run_mode == RUN_INTERACTIVE) gimp_set_data ("plug_in_edge", &evals, sizeof (EdgeVals)); } + else + { + /* gimp_message ("edge: cannot operate on indexed color images"); */ + status = STATUS_EXECUTION_ERROR; + } values[0].data.d_status = status; diff --git a/plug-ins/common/threshold_alpha.c b/plug-ins/common/threshold_alpha.c index e1300282d5..07ab487d40 100644 --- a/plug-ins/common/threshold_alpha.c +++ b/plug-ins/common/threshold_alpha.c @@ -178,6 +178,7 @@ query () { PARAM_INT32, "run_mode", "Interactive, non-interactive"}, { PARAM_IMAGE, "image", "Input image (not used)"}, { PARAM_DRAWABLE, "drawable", "Input drawable" }, + { PARAM_INT32, "threshold", "Threshold" }, }; static GParamDef *return_vals = NULL; static int nargs = sizeof (args) / sizeof (args[0]); @@ -236,7 +237,12 @@ run (char *name, return; break; case RUN_NONINTERACTIVE: - /* You must copy the values of parameters to VALS or dialog variables. */ + if (nparams != 4) + status = STATUS_CALLING_ERROR; + if (status == STATUS_SUCCESS) + { + VALS.threshold = param[3].data.d_int32; + } break; case RUN_WITH_LAST_VALS: gimp_get_data (PLUG_IN_NAME, &VALS); diff --git a/plug-ins/edge/edge.c b/plug-ins/edge/edge.c index 56bc3bdd5f..8d09484a65 100644 --- a/plug-ins/edge/edge.c +++ b/plug-ins/edge/edge.c @@ -225,7 +225,8 @@ run (gchar *name, break; } - if (status == STATUS_SUCCESS) + /* make sure the drawable exist and is not indexed */ + if (gimp_drawable_color (drawable->id) || gimp_drawable_gray (drawable->id)) { gimp_progress_init ("Edge detection..."); @@ -242,6 +243,11 @@ run (gchar *name, if (run_mode == RUN_INTERACTIVE) gimp_set_data ("plug_in_edge", &evals, sizeof (EdgeVals)); } + else + { + /* gimp_message ("edge: cannot operate on indexed color images"); */ + status = STATUS_EXECUTION_ERROR; + } values[0].data.d_status = status; diff --git a/plug-ins/threshold_alpha/threshold_alpha.c b/plug-ins/threshold_alpha/threshold_alpha.c index e1300282d5..07ab487d40 100644 --- a/plug-ins/threshold_alpha/threshold_alpha.c +++ b/plug-ins/threshold_alpha/threshold_alpha.c @@ -178,6 +178,7 @@ query () { PARAM_INT32, "run_mode", "Interactive, non-interactive"}, { PARAM_IMAGE, "image", "Input image (not used)"}, { PARAM_DRAWABLE, "drawable", "Input drawable" }, + { PARAM_INT32, "threshold", "Threshold" }, }; static GParamDef *return_vals = NULL; static int nargs = sizeof (args) / sizeof (args[0]); @@ -236,7 +237,12 @@ run (char *name, return; break; case RUN_NONINTERACTIVE: - /* You must copy the values of parameters to VALS or dialog variables. */ + if (nparams != 4) + status = STATUS_CALLING_ERROR; + if (status == STATUS_SUCCESS) + { + VALS.threshold = param[3].data.d_int32; + } break; case RUN_WITH_LAST_VALS: gimp_get_data (PLUG_IN_NAME, &VALS);