forked from bartvdbraak/blender
BLI_args: disallow zero to be used as a pass value
Introduced recently in 09139e41ed4ea. While this worked in the cases it was used, '--threads' for example was failing to parse the number when it's pass was set to 0. Increase the enum values to start at 1 & add asserts so this wont happen again.
This commit is contained in:
parent
c518cd73cd
commit
6445caa9b5
@ -120,6 +120,9 @@ bArgs *BLI_argsInit(int argc, const char **argv)
|
|||||||
ba->argc = argc;
|
ba->argc = argc;
|
||||||
ba->argv = argv;
|
ba->argv = argv;
|
||||||
|
|
||||||
|
/* Must be initialized by #BLI_argsPassSet. */
|
||||||
|
ba->current_pass = 0;
|
||||||
|
|
||||||
return ba;
|
return ba;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,6 +136,7 @@ void BLI_argsFree(struct bArgs *ba)
|
|||||||
|
|
||||||
void BLI_argsPassSet(struct bArgs *ba, int current_pass)
|
void BLI_argsPassSet(struct bArgs *ba, int current_pass)
|
||||||
{
|
{
|
||||||
|
BLI_assert((current_pass != 0) && (current_pass >= -1));
|
||||||
ba->current_pass = current_pass;
|
ba->current_pass = current_pass;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,6 +282,7 @@ void BLI_argsPrintOtherDoc(struct bArgs *ba)
|
|||||||
|
|
||||||
void BLI_argsParse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *default_data)
|
void BLI_argsParse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *default_data)
|
||||||
{
|
{
|
||||||
|
BLI_assert((pass != 0) && (pass >= -1));
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (i = 1; i < ba->argc; i++) { /* skip argv[0] */
|
for (i = 1; i < ba->argc; i++) { /* skip argv[0] */
|
||||||
|
@ -57,14 +57,14 @@ extern struct ApplicationState app_state; /* creator.c */
|
|||||||
* Keep in order of execution.
|
* Keep in order of execution.
|
||||||
*/
|
*/
|
||||||
enum {
|
enum {
|
||||||
ARG_PASS_ENVIRONMENT = 0,
|
ARG_PASS_ENVIRONMENT = 1,
|
||||||
ARG_PASS_SETTINGS = 1,
|
ARG_PASS_SETTINGS = 2,
|
||||||
/** Windowing & graphical settings, ignored in background mode. */
|
/** Windowing & graphical settings, ignored in background mode. */
|
||||||
ARG_PASS_SETTINGS_GUI = 2,
|
ARG_PASS_SETTINGS_GUI = 3,
|
||||||
ARG_PASS_SETTINGS_FORCE = 3,
|
ARG_PASS_SETTINGS_FORCE = 4,
|
||||||
|
|
||||||
/** Actions & fall back to loading blend file. */
|
/** Actions & fall back to loading blend file. */
|
||||||
ARG_PASS_FINAL = 4,
|
ARG_PASS_FINAL = 5,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* for the callbacks: */
|
/* for the callbacks: */
|
||||||
|
Loading…
Reference in New Issue
Block a user