Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2018-01-10 15:22:03 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-01-10 15:22:03 +0300
commit5d38c141168fcc4dc6aa61ee62a28d59dedf889a (patch)
tree06a301cb2f837b4da0ca461e333c156bfe91ec0a /source/blender/makesrna/intern/rna_userdef.c
parentf59303bead2ae4a25132edadf217a64cdd581dc5 (diff)
parent2737837b09d7b9434c33acf98421967193b7c9df (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/makesrna/intern/rna_userdef.c')
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index bff6cdcf1bd..25ce04229ed 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -24,6 +24,7 @@
* \ingroup RNA
*/
+#include <limits.h>
#include <stdlib.h>
#include "DNA_curve_types.h"
@@ -34,6 +35,7 @@
#include "DNA_scene_types.h"
#include "BLI_utildefines.h"
+#include "BLI_math_base.h"
#include "BKE_appdir.h"
#include "BKE_DerivedMesh.h"
@@ -638,6 +640,27 @@ static StructRNA *rna_AddonPref_refine(PointerRNA *ptr)
#else
+/* TODO(sergey): This technically belongs to blenlib, but we don't link
+ * makesrna against it.
+ */
+
+/* Get maximum addressable memory in megabytes, */
+static size_t max_memory_in_megabytes(void)
+{
+ /* Maximum addressable bytes on this platform. */
+ const size_t limit_bytes = (((size_t)1) << ((sizeof(size_t) * 8) - 1));
+ /* Convert it to megabytes and return. */
+ return (limit_bytes >> 20);
+}
+
+/* Same as above, but clipped to int capacity. */
+static int max_memory_in_megabytes_int(void)
+{
+ const size_t limit_megabytes = max_memory_in_megabytes();
+ /* NOTE: The result will fit into integer. */
+ return (int)min_zz(limit_megabytes, (size_t)INT_MAX);
+}
+
static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna)
{
StructRNA *srna;
@@ -3648,7 +3671,7 @@ static void rna_def_userdef_edit(BlenderRNA *brna)
prop = RNA_def_property(srna, "undo_memory_limit", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "undomemory");
- RNA_def_property_range(prop, 0, 32767);
+ RNA_def_property_range(prop, 0, max_memory_in_megabytes_int());
RNA_def_property_ui_text(prop, "Undo Memory Size", "Maximum memory usage in megabytes (0 means unlimited)");
prop = RNA_def_property(srna, "use_global_undo", PROP_BOOLEAN, PROP_NONE);
@@ -4058,7 +4081,7 @@ static void rna_def_userdef_system(BlenderRNA *brna)
prop = RNA_def_property(srna, "memory_cache_limit", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "memcachelimit");
- RNA_def_property_range(prop, 0, (sizeof(void *) == 8) ? 1024 * 32 : 1024); /* 32 bit 2 GB, 64 bit 32 GB */
+ RNA_def_property_range(prop, 0, max_memory_in_megabytes_int());
RNA_def_property_ui_text(prop, "Memory Cache Limit", "Memory cache limit (in megabytes)");
RNA_def_property_update(prop, 0, "rna_Userdef_memcache_update");