BPython:
- some fixes for menu and error reporting code.
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
#include <BIF_interface.h> /* for pupmenu */
|
||||
#include <BIF_space.h>
|
||||
#include <BIF_screen.h>
|
||||
#include <BIF_toolbox.h>
|
||||
#include <BKE_global.h>
|
||||
#include <BKE_library.h>
|
||||
#include <BKE_main.h>
|
||||
@@ -566,6 +567,7 @@ int BPY_menu_do_python(short menutype, int event)
|
||||
free_libblock(&G.main->script, script);
|
||||
// BPY_end_python();
|
||||
// BPY_start_python();
|
||||
error ("Python script error: check console");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ char *BPyMenu_CreatePupmenuStr(BPyMenu *pym, short menugroup)
|
||||
strcat(str, str2);
|
||||
|
||||
while (pysm) {
|
||||
snprintf(str2, sizeof(str2), "|%s%%x%d", pysm->name, i);
|
||||
PyOS_snprintf(str2, sizeof(str2), "|%s%%x%d", pysm->name, i);
|
||||
rlen = sizeof(str) - strlen(str);
|
||||
strncat(str, str2, rlen);
|
||||
i++;
|
||||
@@ -308,6 +308,7 @@ static void bpymenu_CreateFromFile (void)
|
||||
pymenu = bpymenu_AddEntry(group, w1, w2, tip);
|
||||
if (!pymenu) {
|
||||
puts("BpyMenus error: couldn't create bpymenu entry.\n");
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -318,6 +319,8 @@ static void bpymenu_CreateFromFile (void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -360,6 +363,9 @@ static void bpymenu_WriteDataFile(void)
|
||||
}
|
||||
fprintf(fp, "}\n");
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
/* BPyMenu_PrintAllEntries:
|
||||
@@ -478,7 +484,6 @@ static void bpymenu_CreateFromDir (void)
|
||||
res = fscanf(fp, "%[^']'%[^'\r\n]'\n", w, name);
|
||||
if ((res != 2) || (w[0] != 'n' && w[0] != 'N')) {
|
||||
printf("BPyMenus error: wrong 'name' line in %s.\n", str);
|
||||
printf("%s | %s\n", w, name);
|
||||
goto discard;
|
||||
}
|
||||
|
||||
@@ -488,7 +493,6 @@ static void bpymenu_CreateFromDir (void)
|
||||
res = fscanf(fp, "%[^']'%[^'\r\n]'\n", w, line);
|
||||
if ((res != 2) || (w[0] != 'g' && w[0] != 'G')) {
|
||||
printf("BPyMenus error: wrong 'group' line in %s.\n", str);
|
||||
printf("'%s' | '%s'\n", w, name);
|
||||
goto discard;
|
||||
}
|
||||
|
||||
@@ -544,20 +548,16 @@ void BPyMenu_Init(void)
|
||||
result = stat(U.pythondir, &st);
|
||||
|
||||
if (result == -1) {
|
||||
/*
|
||||
printf ("\nScripts dir: %s\nError: %s\n", U.pythondir, strerror(errno));
|
||||
printf ("Please go to 'Info window -> File Paths tab' and set a valid "
|
||||
"path for\nthe Blender Python scripts dir.\n");
|
||||
*/
|
||||
printf ("\n# Scripts dir: %s\nError: %s\n", U.pythondir, strerror(errno));
|
||||
printf ("# Please go to 'Info window -> File Paths tab' and set a valid "
|
||||
"# path for\nthe Blender Python scripts dir.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!S_ISDIR(st.st_mode)) {
|
||||
/*
|
||||
printf ("\nScripts dir: %s is not a directory!", U.pythondir);
|
||||
printf ("Please go to 'Info window -> File Paths tab' and set a valid "
|
||||
"path for\nthe Blender Python scripts dir.\n");
|
||||
*/
|
||||
printf ("\n# Scripts dir: %s is not a directory!", U.pythondir);
|
||||
printf ("# Please go to 'Info window -> File Paths tab' and set a valid "
|
||||
"# path for\nthe Blender Python scripts dir.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -586,5 +586,3 @@ void BPyMenu_Init(void)
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
* implementation. Non-trivial original comments are marked with an
|
||||
* @ symbol at their beginning. */
|
||||
|
||||
#include "BIF_toolbox.h"
|
||||
|
||||
#include "Draw.h"
|
||||
|
||||
/* declared in ../BPY_extern.h,
|
||||
@@ -103,7 +105,7 @@ static Button *newbutton (void)
|
||||
|
||||
/* GUI interface routines */
|
||||
|
||||
static void exit_pydraw(SpaceScript *sc, short error)
|
||||
static void exit_pydraw(SpaceScript *sc, short err)
|
||||
{
|
||||
Script *script = NULL;
|
||||
|
||||
@@ -111,8 +113,10 @@ static void exit_pydraw(SpaceScript *sc, short error)
|
||||
|
||||
script = sc->script;
|
||||
|
||||
if (error) {
|
||||
if (err) {
|
||||
PyErr_Print();
|
||||
script->flags = 0; /* mark script struct for deletion */
|
||||
error("Python script error: check console");
|
||||
scrarea_queue_redraw(sc->area);
|
||||
}
|
||||
|
||||
|
||||
@@ -99,8 +99,6 @@ static PyObject *M_Registry_SetKey (PyObject *self, PyObject *args)
|
||||
return EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected a string and a dictionary");
|
||||
|
||||
printf("dict size: %d", sizeof(*pydict)); /* debug XXX */
|
||||
|
||||
if (PyDict_SetItem (bpy_registryDict, pystr, pydict)) /* 0 on success */
|
||||
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"Registry_SetKey: couldn't update the Registry dict");
|
||||
@@ -145,4 +143,3 @@ PyObject *Registry_Init (void)
|
||||
|
||||
return submodule;
|
||||
}
|
||||
|
||||
|
||||
@@ -687,7 +687,7 @@ static uiBlock *info_file_importmenu(void *arg_unused)
|
||||
uiDefBut(block, BUTM, 1, pym->name, 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, i, pym->tooltip?pym->tooltip:pym->filename);
|
||||
}
|
||||
|
||||
//uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
uiBlockSetDirection(block, UI_RIGHT);
|
||||
uiTextBoundsBlock(block, 60);
|
||||
|
||||
Reference in New Issue
Block a user