Patch #8344:
Submitted by: Thomas Knight (epat) Parts committed: 1) Fixed a few misspellings in some error strings. 2) Fixed a (theoretical) bug with pyconstraints where a text object could be deleted from python but would remain linked to the constraint it was assigned to - causing slight UI usage discontinuities! Not committed yet: 3) Particle system bugfix in this patch has not been committed. Could jahka or brecht check this.
This commit is contained in:
		@@ -79,6 +79,7 @@ extern "C" {
 | 
			
		||||
	void BPY_pyconstraint_target(struct bPythonConstraint *con, struct bConstraintTarget *ct);
 | 
			
		||||
	void BPY_pyconstraint_update(struct Object *owner, struct bConstraint *con);
 | 
			
		||||
	int BPY_is_pyconstraint(struct Text *text);
 | 
			
		||||
	void BPY_free_pyconstraint_links(struct Text *text);
 | 
			
		||||
	
 | 
			
		||||
	void BPY_start_python( int argc, char **argv );
 | 
			
		||||
	void BPY_end_python( void );
 | 
			
		||||
 
 | 
			
		||||
@@ -1261,6 +1261,45 @@ int BPY_is_pyconstraint(Text *text)
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* This function frees links from pyconstraints to a given text-buffer.
 | 
			
		||||
 * Used when a text-buffer is unlinked!
 | 
			
		||||
 */
 | 
			
		||||
void BPY_free_pyconstraint_links(Text *text)
 | 
			
		||||
{
 | 
			
		||||
	Object *ob;
 | 
			
		||||
	bConstraint *con;
 | 
			
		||||
	short update;
 | 
			
		||||
	
 | 
			
		||||
	/*check all pyconstraints*/
 | 
			
		||||
	for (ob=G.main->object.first; ob; ob=ob->id.next) {
 | 
			
		||||
		update = 0;
 | 
			
		||||
		if(ob->type==OB_ARMATURE && ob->pose) {
 | 
			
		||||
			bPoseChannel *pchan;
 | 
			
		||||
			for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
 | 
			
		||||
				for (con = pchan->constraints.first; con; con=con->next) {
 | 
			
		||||
					if (con->type==CONSTRAINT_TYPE_PYTHON) {
 | 
			
		||||
						bPythonConstraint *data = con->data;
 | 
			
		||||
						if (data->text==text) data->text = NULL;
 | 
			
		||||
						update = 1;
 | 
			
		||||
						
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		for (con = ob->constraints.first; con; con=con->next) {
 | 
			
		||||
			if (con->type==CONSTRAINT_TYPE_PYTHON) {
 | 
			
		||||
				bPythonConstraint *data = con->data;
 | 
			
		||||
				if (data->text==text) data->text = NULL;
 | 
			
		||||
				update = 1;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (update) {
 | 
			
		||||
			DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* This function is called to update PyConstraint data so that it is compatible with the script. 
 | 
			
		||||
 * Some of the allocating/freeing of memory for constraint targets occurs here, espcially
 | 
			
		||||
 * if the number of targets changes.
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
/* 
 | 
			
		||||
 * $Id: Text.c 11123 2007-06-29 08:59:26Z campbellbarton $
 | 
			
		||||
 * $Id$
 | 
			
		||||
 *
 | 
			
		||||
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
 | 
			
		||||
 *
 | 
			
		||||
@@ -289,6 +289,7 @@ static PyObject *M_Text_unlink( PyObject * self, PyObject * args )
 | 
			
		||||
					      "this text was already unlinked!" );
 | 
			
		||||
 | 
			
		||||
	BPY_clear_bad_scriptlinks( text );
 | 
			
		||||
	BPY_free_pyconstraint_links( text );
 | 
			
		||||
	free_text_controllers( text );
 | 
			
		||||
	unlink_text( text );
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -621,7 +621,7 @@ PyObject *LibBlockSeq_unlink(BPy_LibBlockSeq *self, PyObject * value)
 | 
			
		||||
			
 | 
			
		||||
			if (!data)
 | 
			
		||||
				return EXPP_ReturnPyObjError( PyExc_RuntimeError,
 | 
			
		||||
						"This Group has been removed alredy" );
 | 
			
		||||
						"This Group has been removed already" );
 | 
			
		||||
			
 | 
			
		||||
			/* Run the removal code */
 | 
			
		||||
			free_group(data);
 | 
			
		||||
@@ -642,10 +642,11 @@ PyObject *LibBlockSeq_unlink(BPy_LibBlockSeq *self, PyObject * value)
 | 
			
		||||
			
 | 
			
		||||
			if (!data)
 | 
			
		||||
				return EXPP_ReturnPyObjError( PyExc_RuntimeError,
 | 
			
		||||
						"This Group has been removed alredy" );
 | 
			
		||||
						"This Group has been removed already" );
 | 
			
		||||
			
 | 
			
		||||
			/* Run the removal code */
 | 
			
		||||
			BPY_clear_bad_scriptlinks( data );
 | 
			
		||||
			BPY_free_pyconstraint_links( data );
 | 
			
		||||
			free_text_controllers( data );
 | 
			
		||||
			unlink_text( data );
 | 
			
		||||
			free_libblock( &G.main->text, data );
 | 
			
		||||
 
 | 
			
		||||
@@ -140,10 +140,6 @@ void do_text_buttons(unsigned short event)
 | 
			
		||||
		
 | 
			
		||||
	case B_TEXTDELETE:
 | 
			
		||||
		{
 | 
			
		||||
			Object *obt;
 | 
			
		||||
			bConstraint *con;
 | 
			
		||||
			int update;
 | 
			
		||||
			
 | 
			
		||||
			text= st->text;
 | 
			
		||||
			if (!text) return;
 | 
			
		||||
			
 | 
			
		||||
@@ -156,36 +152,8 @@ void do_text_buttons(unsigned short event)
 | 
			
		||||
				pop_space_text(st);
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			/*check all pyconstraints*/
 | 
			
		||||
			for (obt=G.main->object.first; obt; obt=obt->id.next) {
 | 
			
		||||
				update = 0;
 | 
			
		||||
				if(obt->type==OB_ARMATURE && obt->pose) {
 | 
			
		||||
					bPoseChannel *pchan;
 | 
			
		||||
					for(pchan= obt->pose->chanbase.first; pchan; pchan= pchan->next) {
 | 
			
		||||
						for (con = pchan->constraints.first; con; con=con->next) {
 | 
			
		||||
							if (con->type==CONSTRAINT_TYPE_PYTHON) {
 | 
			
		||||
								bPythonConstraint *data = con->data;
 | 
			
		||||
								if (data->text==text) data->text = NULL;
 | 
			
		||||
								update = 1;
 | 
			
		||||
								
 | 
			
		||||
							}
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				for (con = obt->constraints.first; con; con=con->next) {
 | 
			
		||||
					if (con->type==CONSTRAINT_TYPE_PYTHON) {
 | 
			
		||||
						bPythonConstraint *data = con->data;
 | 
			
		||||
						if (data->text==text) data->text = NULL;
 | 
			
		||||
						update = 1;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				
 | 
			
		||||
				if (update) {
 | 
			
		||||
					DAG_object_flush_update(G.scene, obt, OB_RECALC_DATA);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			BPY_clear_bad_scriptlinks(text);
 | 
			
		||||
			BPY_free_pyconstraint_links(text);
 | 
			
		||||
			free_text_controllers(text);
 | 
			
		||||
			
 | 
			
		||||
			unlink_text(text);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user