Fix T57890: freestyle rendering crash.

Depsgraph objects are deleted after conversion to Freestyle data structures,
so don't keep a pointer to their name strings.
This commit is contained in:
Brecht Van Lommel 2019-01-04 17:35:07 +01:00
parent 0d736d6896
commit bd5394f6c0
Notes: blender-bot 2023-02-14 05:00:13 +01:00
Referenced by issue #57890, Blender 2.8 crashes when attempting to render. EEVEE
7 changed files with 28 additions and 33 deletions

View File

@ -733,7 +733,7 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id)
// sets the id of the rep
rep->setId(Id(id, 0));
rep->setName(ob->id.name + 2);
rep->setLibraryPath(ob->id.lib ? ob->id.lib->name : NULL);
rep->setLibraryPath(ob->id.lib ? ob->id.lib->name : "");
const BBox<Vec3r> bbox = BBox<Vec3r>(Vec3r(ls.minBBox[0], ls.minBBox[1], ls.minBBox[2]),
Vec3r(ls.maxBBox[0], ls.maxBBox[1], ls.maxBBox[2]));

View File

@ -185,7 +185,7 @@ PyDoc_STRVAR(SShape_name_doc,
static PyObject *SShape_name_get(BPy_SShape *self, void *UNUSED(closure))
{
return PyUnicode_FromString(self->ss->getName());
return PyUnicode_FromString(self->ss->getName().c_str());
}
static int SShape_name_set(BPy_SShape *self, PyObject *value, void *UNUSED(closure))

View File

@ -293,7 +293,7 @@ PyDoc_STRVAR(ViewShape_name_doc,
static PyObject *ViewShape_name_get(BPy_ViewShape *self, void *UNUSED(closure))
{
return PyUnicode_FromString(self->vs->getName());
return PyUnicode_FromString(self->vs->getName().c_str());
}
PyDoc_STRVAR(ViewShape_library_path_doc,
@ -303,10 +303,7 @@ PyDoc_STRVAR(ViewShape_library_path_doc,
static PyObject *ViewShape_library_path_get(BPy_ViewShape *self, void *UNUSED(closure))
{
const char *name = self->vs->getLibraryPath();
if (!name)
Py_RETURN_NONE;
return PyUnicode_FromString(name);
return PyUnicode_FromString(self->vs->getLibraryPath().c_str());
}
PyDoc_STRVAR(ViewShape_id_doc,

View File

@ -28,6 +28,8 @@
* \date 25/01/2002
*/
#include <string>
#include "FrsMaterial.h"
#include "SceneVisitor.h"
@ -38,6 +40,8 @@
#include "../system/Id.h"
#include "../system/Precision.h"
using namespace std;
namespace Freestyle {
using namespace Geometry;
@ -48,8 +52,6 @@ public:
inline Rep() : BaseObject()
{
_Id = 0;
_Name = 0;
_LibraryPath = 0;
_FrsMaterial = 0;
}
@ -132,12 +134,12 @@ public:
return _Id;
}
inline const char *getName() const
inline const string& getName() const
{
return _Name;
}
inline const char *getLibraryPath() const
inline const string& getLibraryPath() const
{
return _LibraryPath;
}
@ -158,12 +160,12 @@ public:
_Id = id;
}
inline void setName(const char *name)
inline void setName(const string& name)
{
_Name = name;
}
inline void setLibraryPath(const char *path)
inline void setLibraryPath(const string& path)
{
_LibraryPath = path;
}
@ -176,8 +178,8 @@ public:
private:
BBox<Vec3f> _BBox;
Id _Id;
const char *_Name;
const char *_LibraryPath;
string _Name;
string _LibraryPath;
FrsMaterial *_FrsMaterial;
};

View File

@ -1415,8 +1415,8 @@ private:
vector<SVertex*> _verticesList; // list of all vertices
vector<FEdge*> _edgesList; // list of all edges
Id _Id;
const char *_Name;
const char *_LibraryPath;
string _Name;
string _LibraryPath;
BBox<Vec3r> _BBox;
vector<FrsMaterial> _FrsMaterials;
@ -1436,8 +1436,6 @@ public:
userdata = NULL;
_importance = 0.0f;
_ViewShape = NULL;
_Name = NULL;
_LibraryPath = NULL;
}
/*! Copy constructor */
@ -1891,13 +1889,13 @@ public:
}
/*! Returns the name of the Shape. */
inline const char *getName() const
inline const string& getName() const
{
return _Name;
}
/*! Returns the library path of the Shape. */
inline const char *getLibraryPath() const
inline const string& getLibraryPath() const
{
return _LibraryPath;
}
@ -1910,13 +1908,13 @@ public:
}
/*! Sets the name of the shape.*/
inline void setName(const char *name)
inline void setName(const string& name)
{
_Name = name;
}
/*! Sets the library path of the shape.*/
inline void setLibraryPath(const char *path)
inline void setLibraryPath(const string& path)
{
_LibraryPath = path;
}

View File

@ -1566,13 +1566,13 @@ public:
}
/*! Returns the ViewShape name. */
inline const char *getName() const
inline const string& getName() const
{
return _SShape->getName();
}
/*! Returns the ViewShape library path. */
inline const char *getLibraryPath() const
inline const string& getLibraryPath() const
{
return _SShape->getLibraryPath();
}

View File

@ -1024,8 +1024,8 @@ protected:
vector<WEdge *> _EdgeList;
vector<WFace *> _FaceList;
int _Id;
const char *_Name;
const char *_LibraryPath;
string _Name;
string _LibraryPath;
static unsigned _SceneCurrentId;
#if 0
Vec3f _min;
@ -1044,8 +1044,6 @@ public:
#endif
_Id = _SceneCurrentId;
_SceneCurrentId++;
_Name = 0;
_LibraryPath = 0;
}
/*! copy constructor */
@ -1125,12 +1123,12 @@ public:
}
#endif
inline const char *getName() const
inline const string& getName() const
{
return _Name;
}
inline const char *getLibraryPath() const
inline const string& getLibraryPath() const
{
return _LibraryPath;
}
@ -1179,12 +1177,12 @@ public:
_FrsMaterials = iMaterials;
}
inline void setName(const char *name)
inline void setName(const string& name)
{
_Name = name;
}
inline void setLibraryPath(const char *path)
inline void setLibraryPath(const string& path)
{
_LibraryPath = path;
}