From a368426d260bd8243eb657cb5a7046e4cc9d9795 Mon Sep 17 00:00:00 2001
From: Willian Padovani Germano <wpgermano@gmail.com>
Date: Sun, 5 Dec 2004 04:01:57 +0000
Subject: [PATCH] BPython, two bug fixes: - #1911:
 http://projects.blender.org/tracker/?func=detail&atid=125&aid=1911&group_id=9
     BOOL properties were returning True always, small mistake in logic.c's
 getData method. - #1944:
 http://projects.blender.org/tracker/?func=detail&atid=125&aid=1944&group_id=9
     G.vd was not being checked against NULL in Window.ViewLayer, causing a
 crash when this function was called from a command line script.  Now it
 returns an error in such cases. - small doc updates, tiny minor change in
 Object.c.

---
 source/blender/python/api2_2x/Object.c          |  5 +++--
 source/blender/python/api2_2x/Window.c          | 11 ++++++++---
 source/blender/python/api2_2x/doc/API_intro.py  |  9 +++++++--
 source/blender/python/api2_2x/doc/epy_docgen.sh |  2 +-
 source/blender/python/api2_2x/logic.c           |  2 +-
 5 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c
index ec352061268..afc093a6965 100644
--- a/source/blender/python/api2_2x/Object.c
+++ b/source/blender/python/api2_2x/Object.c
@@ -1799,15 +1799,16 @@ static PyObject *Object_addProperty( BPy_Object * self, PyObject * args )
 	char *prop_type = NULL;
 	short type = -1;
 	BPy_Property *py_prop = NULL;
+	int argslen = PyObject_Length( args );
 
-	if( PyObject_Length( args ) == 3 || PyObject_Length( args ) == 2 ) {
+	if( argslen == 3 || argslen == 2 ) {
 		if( !PyArg_ParseTuple
 		    ( args, "sO|s", &prop_name, &prop_data, &prop_type ) ) {
 			return ( EXPP_ReturnPyObjError
 				 ( PyExc_AttributeError,
 				   "unable to get string, data, and optional string" ) );
 		}
-	} else if( PyObject_Length( args ) == 1 ) {
+	} else if( argslen == 1 ) {
 		if( !PyArg_ParseTuple( args, "O!", &property_Type, &py_prop ) ) {
 			return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
 							"unable to get Property" ) );
diff --git a/source/blender/python/api2_2x/Window.c b/source/blender/python/api2_2x/Window.c
index 1053c29e930..28a17d08936 100644
--- a/source/blender/python/api2_2x/Window.c
+++ b/source/blender/python/api2_2x/Window.c
@@ -798,7 +798,7 @@ static PyObject *M_Window_GetViewMatrix( PyObject * self )
 static PyObject *M_Window_GetPerspMatrix( PyObject * self )
 {
 	PyObject *perspmat;
-	
+
 	if( !G.vd ) {
 		Py_INCREF( Py_None );
 		return Py_None;
@@ -847,9 +847,14 @@ static PyObject *M_Window_ViewLayer( PyObject * self, PyObject * args )
 	PyObject *list = NULL, *resl = NULL;
 	int val, i, bit = 0, layer = 0;
 
+	if( !G.vd ) {
+		return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+			"this function can only be used after a 3d View has been initialized" );
+	}
+
 	if( !PyArg_ParseTuple( args, "|O!", &PyList_Type, &list ) )
 		return EXPP_ReturnPyObjError( PyExc_TypeError,
-					      "expected nothing or a list of ints as argument" );
+		  "expected nothing or a list of ints as argument" );
 
 	if( list ) {
 		for( i = 0; i < PyList_Size( list ); i++ ) {
@@ -911,7 +916,7 @@ static PyObject *M_Window_CameraView( PyObject * self, PyObject * args )
 
 	if( !G.vd )
 		return EXPP_ReturnPyObjError( PyExc_RuntimeError,
-					      "View3d not available!" );
+			"this function can only be used after a 3d View has been initialized" );
 
 	if( !G.vd->camera ) {
 		if( BASACT && OBACT->type == OB_CAMERA )
diff --git a/source/blender/python/api2_2x/doc/API_intro.py b/source/blender/python/api2_2x/doc/API_intro.py
index b8506fd87e0..fb8df69a5eb 100644
--- a/source/blender/python/api2_2x/doc/API_intro.py
+++ b/source/blender/python/api2_2x/doc/API_intro.py
@@ -164,7 +164,12 @@ Command line mode:
  "-b" background mode and additions like the "-P" command line switch,
  L{Blender.Save}, L{Blender.Load}, L{Blender.Quit} and the L{Library} module,
  for many tasks it's possible to control Blender via some automated process
- using scripts.
+ using scripts.  Note that command line scripts are run before Blender
+ initializes its windows, so many functions that get or set window related
+ attributes (like most in L{Window}) don't work here.  If you need those, use
+ an ONLOAD script link (see L{Scene.Scene.addScriptLink}) instead -- it's
+ also possible to use a command line script to write or set an ONLOAD script
+ link.
 
 Demo mode:
 ----------
@@ -294,7 +299,7 @@ A note to newbie script writers:
 
 @author: The Blender Python Team
 @requires: Blender 2.35 or newer.
-@version: 2.35
+@version: 2.35 - 2.36
 @see: U{www.blender3d.org<http://www.blender3d.org>}: main site
 @see: U{www.blender.org<http://www.blender.org>}: documentation and forum
 @see: U{www.elysiun.com<http://www.elysiun.com>}: user forum
diff --git a/source/blender/python/api2_2x/doc/epy_docgen.sh b/source/blender/python/api2_2x/doc/epy_docgen.sh
index 27d82c9d373..8939a0db000 100644
--- a/source/blender/python/api2_2x/doc/epy_docgen.sh
+++ b/source/blender/python/api2_2x/doc/epy_docgen.sh
@@ -4,6 +4,6 @@
 # run from the doc directory containing the .py files
 # usage:  sh epy_docgen.sh
 
-epydoc -o BPY_API_234 --url "http://www.blender.org" -t API_intro.py \
+epydoc -o BPY_API_236 --url "http://www.blender.org" -t API_intro.py \
  -n "Blender" --no-private --no-frames \
 $( ls [A-Z]*.py )
diff --git a/source/blender/python/api2_2x/logic.c b/source/blender/python/api2_2x/logic.c
index d3631a00ba9..2dc74a8b479 100644
--- a/source/blender/python/api2_2x/logic.c
+++ b/source/blender/python/api2_2x/logic.c
@@ -429,7 +429,7 @@ static PyObject *Property_getData( BPy_Property * self )
 		attr = EXPP_incr_ret( self->data );
 	} else {
 		if( self->property->type == PROP_BOOL ) {
-			if( *( ( int * ) &self->property->poin ) )
+			if( self->property->data )
 				attr = EXPP_incr_ret( Py_True );
 			else
 				attr = EXPP_incr_ret( Py_False );
-- 
GitLab