File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -561,9 +561,15 @@ namespace OGF {
561561
562562 Object* lua_tographite (lua_State* L, int index) {
563563 geo_debug_assert (lua_isgraphite (L,index));
564- return static_cast <GraphiteRef*>(
564+ Object* result = static_cast <GraphiteRef*>(
565565 lua_touserdata (L,index)
566566 )->object ;
567+ if (result->id () == Object::INVALID_ID) {
568+ Logger::warn (" GOM" ) << " Reference to invalid Object"
569+ << std::endl;
570+ result = nullptr ;
571+ }
572+ return result;
567573 }
568574
569575
Original file line number Diff line number Diff line change @@ -90,6 +90,7 @@ namespace OGF {
9090 id_to_object_ = nullptr ;
9191 }
9292 }
93+ id_ = static_cast <unsigned int >(0xbadbeef );
9394 }
9495
9596 void Object::disconnect () {
Original file line number Diff line number Diff line change @@ -64,6 +64,9 @@ namespace OGF {
6464 gom_attribute (abstract," true" )
6565 gom_class GOM_API Object : public Counted {
6666 public:
67+ static constexpr unsigned int INVALID_ID
68+ = static_cast <unsigned int >(0xbadbeef );
69+
6770 /* *
6871 * \brief Object constructor.
6972 * \param[in] transient if true, the object is transient.
Original file line number Diff line number Diff line change @@ -60,6 +60,10 @@ namespace OGF {
6060 grob_ = grob ;
6161 }
6262
63+ Grob* Interface::get_grob () const {
64+ return ((grob_->id () == Object::INVALID_ID) ? nullptr : grob_);
65+ }
66+
6367 SceneGraph* Interface::scene_graph () const {
6468 return grob_->scene_graph () ;
6569 }
@@ -171,7 +175,7 @@ namespace OGF {
171175 }
172176
173177 Interpreter* Commands::interpreter () {
174- if (get_grob () == nullptr ) {
178+ if (get_grob () == nullptr || get_grob ()-> id () == Object::INVALID_ID ) {
175179 return nullptr ;
176180 }
177181 return get_grob ()->interpreter ();
Original file line number Diff line number Diff line change @@ -111,9 +111,7 @@ namespace OGF {
111111 * \brief Gets the current Grob
112112 * \return a pointer to the current Grob
113113 */
114- Grob* get_grob () const {
115- return grob_;
116- }
114+ Grob* get_grob () const ;
117115
118116 private:
119117 Grob* grob_;
You can’t perform that action at this time.
0 commit comments