mirror of https://github.com/KLayout/klayout.git
Fixed an issue with destruction callbacks in the QApplication destructor - in this case the interpreter may be nulled already and callbacks must not happen into Ruby/Python.
This commit is contained in:
parent
5be469af90
commit
ce01ce2dae
|
|
@ -41,6 +41,7 @@ struct GSI_PUBLIC Callee
|
|||
virtual ~Callee () { }
|
||||
|
||||
virtual void call (int id, SerialArgs &args, SerialArgs &ret) const = 0;
|
||||
virtual bool can_call () const { return true; }
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -72,7 +73,7 @@ struct Callback
|
|||
|
||||
bool can_issue () const
|
||||
{
|
||||
return callee.get () != 0;
|
||||
return callee && callee->can_call ();
|
||||
}
|
||||
|
||||
// 0 arguments
|
||||
|
|
|
|||
|
|
@ -76,6 +76,11 @@ public:
|
|||
*/
|
||||
virtual void call (int id, gsi::SerialArgs &args, gsi::SerialArgs &ret) const;
|
||||
|
||||
/**
|
||||
* @brief Implementation of the Callee interface
|
||||
*/
|
||||
virtual bool can_call () const;
|
||||
|
||||
private:
|
||||
PYAObjectBase *mp_obj;
|
||||
std::vector<CallbackFunction> m_cbfuncs;
|
||||
|
|
@ -108,6 +113,12 @@ Callee::clear_callbacks ()
|
|||
m_cbfuncs.clear ();
|
||||
}
|
||||
|
||||
bool
|
||||
Callee::can_call () const
|
||||
{
|
||||
return pya::PythonInterpreter::instance () != 0;
|
||||
}
|
||||
|
||||
void
|
||||
Callee::call (int id, gsi::SerialArgs &args, gsi::SerialArgs &ret) const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1728,8 +1728,7 @@ RubyInterpreter::~RubyInterpreter ()
|
|||
|
||||
rb_release_top_self ();
|
||||
|
||||
// This prevents reinitialization
|
||||
sp_rba_interpreter = reinterpret_cast<RubyInterpreter *> (1);
|
||||
sp_rba_interpreter = 0;
|
||||
}
|
||||
|
||||
RubyInterpreter *RubyInterpreter::instance ()
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ public:
|
|||
: m_hash (hash)
|
||||
{
|
||||
rb_gc_register_address (&m_hash);
|
||||
m_keys = rb_ary_new2 (RHASH_SIZE (m_hash));
|
||||
m_keys = rb_ary_new2 (long (RHASH_SIZE (m_hash)));
|
||||
rb_gc_register_address (&m_keys);
|
||||
rb_hash_foreach (m_hash, (int (*)(...)) &push_key_to_ary_i, m_keys);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -301,6 +301,11 @@ Proxy::signal_handler (const gsi::MethodBase *meth)
|
|||
return sh;
|
||||
}
|
||||
|
||||
bool Proxy::can_call () const
|
||||
{
|
||||
return rba::RubyInterpreter::instance () != 0;
|
||||
}
|
||||
|
||||
void
|
||||
Proxy::call (int id, gsi::SerialArgs &args, gsi::SerialArgs &ret) const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -147,6 +147,7 @@ public:
|
|||
VALUE signal_handler (const gsi::MethodBase *meth);
|
||||
|
||||
virtual void call (int id, gsi::SerialArgs &args, gsi::SerialArgs &ret) const;
|
||||
virtual bool can_call () const;
|
||||
|
||||
private:
|
||||
const gsi::ClassBase *m_cls_decl;
|
||||
|
|
|
|||
|
|
@ -41,8 +41,7 @@ RubyInterpreter::RubyInterpreter ()
|
|||
|
||||
RubyInterpreter::~RubyInterpreter ()
|
||||
{
|
||||
// This prevents reinitialization
|
||||
sp_rba_interpreter = reinterpret_cast<RubyInterpreter *> (1);
|
||||
sp_rba_interpreter = 0;
|
||||
}
|
||||
|
||||
RubyInterpreter *RubyInterpreter::instance ()
|
||||
|
|
|
|||
Loading…
Reference in New Issue