added GIMP_MAX_MEMSIZE, an arbitrary upper limit for memory sizes. It must

2003-11-25  Sven Neumann  <sven@gimp.org>

	* libgimpbase/gimplimits.h: added GIMP_MAX_MEMSIZE, an arbitrary
	upper limit for memory sizes. It must be smaller than G_MAXDOUBLE
	since our memsize entry doesn't handle anything larger.

	* app/widgets/gimppropwidgets.c (gimp_prop_memsize_entry_new):
	check against GIMP_MAX_MEMSIZE, not G_MAXDOUBLE.

	* app/config/gimpbaseconfig.c
	* app/config/gimpcoreconfig.c
	* app/config/gimpguiconfig.c: use GIMP_MAX_MEMSIZE instead of
	G_MAXULONG. The latter is larger than G_MAXDOUBLE on 64bit
	machines and caused bug #127908.

	* libgimpwidgets/gimpmemsizeentry.c: added casts to guint64.
This commit is contained in:
Sven Neumann 2003-11-25 19:45:01 +00:00 committed by Sven Neumann
parent 348a785e4b
commit 0aec8c079e
11 changed files with 53 additions and 25 deletions

View File

@ -1,3 +1,20 @@
2003-11-25 Sven Neumann <sven@gimp.org>
* libgimpbase/gimplimits.h: added GIMP_MAX_MEMSIZE, an arbitrary
upper limit for memory sizes. It must be smaller than G_MAXDOUBLE
since our memsize entry doesn't handle anything larger.
* app/widgets/gimppropwidgets.c (gimp_prop_memsize_entry_new):
check against GIMP_MAX_MEMSIZE, not G_MAXDOUBLE.
* app/config/gimpbaseconfig.c
* app/config/gimpcoreconfig.c
* app/config/gimpguiconfig.c: use GIMP_MAX_MEMSIZE instead of
G_MAXULONG. The latter is larger than G_MAXDOUBLE on 64bit
machines and caused bug #127908.
* libgimpwidgets/gimpmemsizeentry.c: added casts to guint64.
2003-11-25 Sven Neumann <sven@gimp.org>
* plug-ins/script-fu/interp_md5.[ch]: removed these unused files

View File

@ -122,7 +122,7 @@ gimp_base_config_class_init (GimpBaseConfigClass *klass)
0);
GIMP_CONFIG_INSTALL_PROP_MEMSIZE (object_class, PROP_TILE_CACHE_SIZE,
"tile-cache-size", TILE_CACHE_SIZE_BLURB,
0, G_MAXULONG, 1 << 26,
0, GIMP_MAX_MEMSIZE, 1 << 26,
GIMP_PARAM_CONFIRM);
}

View File

@ -221,7 +221,7 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
GIMP_PARAM_CONFIRM);
GIMP_CONFIG_INSTALL_PROP_MEMSIZE (object_class, PROP_UNDO_SIZE,
"undo-size", UNDO_SIZE_BLURB,
0, G_MAXULONG, 1 << 22,
0, GIMP_MAX_MEMSIZE, 1 << 22,
GIMP_PARAM_CONFIRM);
GIMP_CONFIG_INSTALL_PROP_PATH (object_class,
PROP_PLUGINRC_PATH,

View File

@ -198,7 +198,7 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
GIMP_CONFIG_INSTALL_PROP_MEMSIZE (object_class, PROP_MAX_NEW_IMAGE_SIZE,
"max-new-image-size",
MAX_NEW_IMAGE_SIZE_BLURB,
0, (guint64) 1 << 40, 1 << 26,
0, GIMP_MAX_MEMSIZE, 1 << 26,
0);
GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_THEME_PATH,
"theme-path", THEME_PATH_BLURB,

View File

@ -998,14 +998,8 @@ gimp_prop_memsize_entry_new (GObject *config,
uint64_spec = G_PARAM_SPEC_UINT64 (param_spec);
#ifndef _MSC_VER
/* avoid getting gimppropwidgets.c(999) : warning C4056:
* overflow in floating-point constant arithmetic
* and runtime failing (the check seems not useful to me anyway)
*/
g_return_val_if_fail (uint64_spec->minimum <= (guint64) G_MAXDOUBLE, NULL);
g_return_val_if_fail (uint64_spec->maximum <= (guint64) G_MAXDOUBLE, NULL);
#endif
g_return_val_if_fail (uint64_spec->minimum <= GIMP_MAX_MEMSIZE, NULL);
g_return_val_if_fail (uint64_spec->maximum <= GIMP_MAX_MEMSIZE, NULL);
entry = gimp_memsize_entry_new (value,
uint64_spec->minimum,

View File

@ -1,3 +1,8 @@
2003-11-25 Sven Neumann <sven@gimp.org>
* libgimpbase/libgimpbase-sections.txt
* libgimpbase/tmpl/gimplimits.sgml: added GIMP_MAX_MEMSIZE.
2003-11-23 Michael Natterer <mitch@gimp.org>
* app/app-docs.sgml

View File

@ -29,6 +29,7 @@ GIMP_MIN_IMAGE_SIZE
GIMP_MAX_IMAGE_SIZE
GIMP_MIN_RESOLUTION
GIMP_MAX_RESOLUTION
GIMP_MAX_MEMSIZE
GIMP_CHECK_SIZE
GIMP_CHECK_SIZE_SM
GIMP_CHECK_DARK

View File

@ -43,6 +43,13 @@ Boundaries of some GIMP data types and some global constants.
<!-- ##### MACRO GIMP_MAX_MEMSIZE ##### -->
<para>
</para>
<!-- ##### MACRO GIMP_CHECK_SIZE ##### -->
<para>

View File

@ -34,15 +34,23 @@
#define GIMP_MIN_RESOLUTION 5e-3 /* shouldn't display as 0.000 */
#define GIMP_MAX_RESOLUTION 65536.0
/* memory sizes
*/
#define GIMP_MAX_MEMSIZE ((guint64) 1 << 42) /* 4 terabyte;
* needs a 64bit variable
* and must be < G_MAXDOUBLE
*/
/* the size of the checks which indicate transparency...
*/
#define GIMP_CHECK_SIZE 8
#define GIMP_CHECK_SIZE_SM 4
#define GIMP_CHECK_SIZE 8
#define GIMP_CHECK_SIZE_SM 4
/* ...and their colors
*/
#define GIMP_CHECK_DARK 0.4 /* corresponds to GRAY_CHECKS as */
#define GIMP_CHECK_LIGHT 0.6 /* defined in app/image_render.c */
#define GIMP_CHECK_DARK 0.4
#define GIMP_CHECK_LIGHT 0.6
#endif /* __GIMP_LIMITS_H__ */

View File

@ -199,7 +199,8 @@ gimp_memsize_entry_new (guint64 value,
for (shift = 30; shift > 10; shift -= 10)
{
if (value > (1 << shift) && value % (1 << shift) == 0)
if (value > ((guint64) 1 << shift) &&
value % ((guint64) 1 << shift) == 0)
break;
}
@ -260,7 +261,8 @@ gimp_memsize_entry_set_value (GimpMemsizeEntry *entry,
for (shift = 30; shift > 10; shift -= 10)
{
if (value > (1 << shift) && value % (1 << shift) == 0)
if (value > ((guint64) 1 << shift) &&
value % ((guint64) 1 << shift) == 0)
break;
}

View File

@ -998,14 +998,8 @@ gimp_prop_memsize_entry_new (GObject *config,
uint64_spec = G_PARAM_SPEC_UINT64 (param_spec);
#ifndef _MSC_VER
/* avoid getting gimppropwidgets.c(999) : warning C4056:
* overflow in floating-point constant arithmetic
* and runtime failing (the check seems not useful to me anyway)
*/
g_return_val_if_fail (uint64_spec->minimum <= (guint64) G_MAXDOUBLE, NULL);
g_return_val_if_fail (uint64_spec->maximum <= (guint64) G_MAXDOUBLE, NULL);
#endif
g_return_val_if_fail (uint64_spec->minimum <= GIMP_MAX_MEMSIZE, NULL);
g_return_val_if_fail (uint64_spec->maximum <= GIMP_MAX_MEMSIZE, NULL);
entry = gimp_memsize_entry_new (value,
uint64_spec->minimum,