luabind with boost::signals error

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

luabind with boost::signals error

Szymon Gatner
Hi,

I am trying to use luabind::object as a slot for boost::signal.

This code is perfectly fine:

  boost::signal<void(const std::string&)> sig;

  luabind::object slot = globals(lua)["slot"];

  sig.connect(slot);

  sig("signal call");

but a call to:

 sig.disconnect(slot);

throws a std::runtime_error("Trying to use unregistered class");

call stack:

  KernelBase.dll!7717b727()
  [Frames below may be incorrect and/or missing, no symbols loaded for
KernelBase.dll]
  KernelBase.dll!7717b727()
  msvcr90d.dll!_CxxThrowException(void * pExceptionObject=0x0020ece4,
const _s__ThrowInfo * pThrowInfo=0x00e18090)  Line 161 C++
> playground.exe!luabind::detail::make_instance<std::auto_ptr<boost::function<void __cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &)> > >(lua_State * L=0x000c01c0, std::auto_ptr<boost::function<void __cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char> > const &)> > p=auto_ptr {...})  Line 80 + 0x41 bytes C++
  playground.exe!luabind::detail::make_pointee_instance<boost::function<void
__cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
> const &)> >(lua_State * L=0x000c01c0, boost::function<void
__cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
> const &)> & x={...}, boost::mpl::bool_<0> __formal={...},
boost::mpl::bool_<0> __formal={...})  Line 183 + 0x21 bytes C++
  playground.exe!luabind::detail::make_pointee_instance<boost::function<void
__cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
> const &)>,boost::mpl::bool_<1> >(lua_State * L=0x000c01c0,
boost::function<void
__cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
> const &)> & x={...}, boost::mpl::bool_<1> __formal={...})  Line 195
+ 0x25 bytes C++
  playground.exe!luabind::detail::value_converter::apply<boost::function<void
__cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
> const &)> >(lua_State * L=0x000c01c0, boost::function<void
__cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
> const &)> x={...})  Line 281 + 0x1d bytes C++
  playground.exe!luabind::detail::push_aux<boost::function<void
__cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
> const &)> const ,luabind::detail::default_policy>(lua_State *
interpreter=0x000c01c0, const boost::function<void
__cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
> const &)> & value={...}, luabind::detail::default_policy *
__formal=0x00000000)  Line 73 C++
  playground.exe!luabind::detail::push<boost::function<void
__cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
> const &)> const ,luabind::detail::null_type>(lua_State *
interpreter=0x000c01c0, const boost::function<void
__cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
> const &)> & value={...}, const luabind::detail::null_type &
__formal={...})  Line 83 + 0xf bytes C++
  playground.exe!luabind::detail::push<boost::function<void
__cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
> const &)> const >(lua_State * interpreter=0x000c01c0, const
boost::function<void
__cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
> const &)> & value={...})  Line 89 + 0x1c bytes C++
  playground.exe!luabind::adl::operator==<boost::function<void
__cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
> const &)>,luabind::adl::object>(const boost::function<void
__cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
> const &)> & lhs={...}, const luabind::adl::object & rhs={...})  Line
214 + 0xc9 bytes C++
  playground.exe!boost::signal1<void,std::basic_string<char,std::char_traits<char>,std::allocator<char>
> const &,boost::last_value<void>,int,std::less<int>,boost::function<void
__cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
> const &)> >::do_disconnect<luabind::adl::object>(const
luabind::adl::object & f={...}, boost::mpl::bool_<0> __formal={...})
Line 242 + 0xd bytes C++
  playground.exe!boost::signal1<void,std::basic_string<char,std::char_traits<char>,std::allocator<char>
> const &,boost::last_value<void>,int,std::less<int>,boost::function<void
__cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
> const &)> >::disconnect<luabind::adl::object>(const
luabind::adl::object & t={...})  Line 225 C++
  playground.exe!main()  Line 144 C++
  playground.exe!__tmainCRTStartup()  Line 586 + 0x19 bytes C
  playground.exe!mainCRTStartup()  Line 403 C
  kernel32.dll!759f3677()
  ntdll.dll!77a89f02()
  ntdll.dll!77a89ed5()

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: luabind with boost::signals error

Linker
You should not do that.


On 2/15/11, Szymon Gatner <[hidden email]> wrote:

> Hi,
>
> I am trying to use luabind::object as a slot for boost::signal.
>
> This code is perfectly fine:
>
>   boost::signal<void(const std::string&)> sig;
>
>   luabind::object slot = globals(lua)["slot"];
>
>   sig.connect(slot);
>
>   sig("signal call");
>
> but a call to:
>
>  sig.disconnect(slot);
>
> throws a std::runtime_error("Trying to use unregistered class");
>
> call stack:
>
>   KernelBase.dll!7717b727()
>   [Frames below may be incorrect and/or missing, no symbols loaded for
> KernelBase.dll]
>   KernelBase.dll!7717b727()
>   msvcr90d.dll!_CxxThrowException(void * pExceptionObject=0x0020ece4,
> const _s__ThrowInfo * pThrowInfo=0x00e18090)  Line 161 C++
>> playground.exe!luabind::detail::make_instance<std::auto_ptr<boost::function<void
>> __cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
>> > const &)> > >(lua_State * L=0x000c01c0,
>> std::auto_ptr<boost::function<void
>> __cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
>> > const &)> > p=auto_ptr {...})  Line 80 + 0x41 bytes C++
>   playground.exe!luabind::detail::make_pointee_instance<boost::function<void
> __cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
>> const &)> >(lua_State * L=0x000c01c0, boost::function<void
> __cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
>> const &)> & x={...}, boost::mpl::bool_<0> __formal={...},
> boost::mpl::bool_<0> __formal={...})  Line 183 + 0x21 bytes C++
>   playground.exe!luabind::detail::make_pointee_instance<boost::function<void
> __cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
>> const &)>,boost::mpl::bool_<1> >(lua_State * L=0x000c01c0,
> boost::function<void
> __cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
>> const &)> & x={...}, boost::mpl::bool_<1> __formal={...})  Line 195
> + 0x25 bytes C++
> playground.exe!luabind::detail::value_converter::apply<boost::function<void
> __cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
>> const &)> >(lua_State * L=0x000c01c0, boost::function<void
> __cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
>> const &)> x={...})  Line 281 + 0x1d bytes C++
>   playground.exe!luabind::detail::push_aux<boost::function<void
> __cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
>> const &)> const ,luabind::detail::default_policy>(lua_State *
> interpreter=0x000c01c0, const boost::function<void
> __cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
>> const &)> & value={...}, luabind::detail::default_policy *
> __formal=0x00000000)  Line 73 C++
>   playground.exe!luabind::detail::push<boost::function<void
> __cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
>> const &)> const ,luabind::detail::null_type>(lua_State *
> interpreter=0x000c01c0, const boost::function<void
> __cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
>> const &)> & value={...}, const luabind::detail::null_type &
> __formal={...})  Line 83 + 0xf bytes C++
>   playground.exe!luabind::detail::push<boost::function<void
> __cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
>> const &)> const >(lua_State * interpreter=0x000c01c0, const
> boost::function<void
> __cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
>> const &)> & value={...})  Line 89 + 0x1c bytes C++
>   playground.exe!luabind::adl::operator==<boost::function<void
> __cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
>> const &)>,luabind::adl::object>(const boost::function<void
> __cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
>> const &)> & lhs={...}, const luabind::adl::object & rhs={...})  Line
> 214 + 0xc9 bytes C++
> playground.exe!boost::signal1<void,std::basic_string<char,std::char_traits<char>,std::allocator<char>
>> const &,boost::last_value<void>,int,std::less<int>,boost::function<void
> __cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
>> const &)> >::do_disconnect<luabind::adl::object>(const
> luabind::adl::object & f={...}, boost::mpl::bool_<0> __formal={...})
> Line 242 + 0xd bytes C++
> playground.exe!boost::signal1<void,std::basic_string<char,std::char_traits<char>,std::allocator<char>
>> const &,boost::last_value<void>,int,std::less<int>,boost::function<void
> __cdecl(std::basic_string<char,std::char_traits<char>,std::allocator<char>
>> const &)> >::disconnect<luabind::adl::object>(const
> luabind::adl::object & t={...})  Line 225 C++
>   playground.exe!main()  Line 144 C++
>   playground.exe!__tmainCRTStartup()  Line 586 + 0x19 bytes C
>   playground.exe!mainCRTStartup()  Line 403 C
>   kernel32.dll!759f3677()
>   ntdll.dll!77a89f02()
>   ntdll.dll!77a89ed5()
>
> ------------------------------------------------------------------------------
> The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
> Pinpoint memory and threading errors before they happen.
> Find and fix more than 250 security defects in the development cycle.
> Locate bottlenecks in serial and parallel code that limit performance.
> http://p.sf.net/sfu/intel-dev2devfeb
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>

--
Sent from my mobile device

*Regards,
Linker Lin
[hidden email]*

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: luabind with boost::signals error

Szymon Gatner
In reply to this post by Szymon Gatner
Care to elaborate?

I should not use luabind::object as a slot? Or just not disconnecting this way?

Previous code modified like so:

  signals::connection c = sig.connect(slot);

  c.disconnect();

works fine but I do not like the idea of signaled objects to keep
every connection
to every signal they register to. Any other suggestions?

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: luabind with boost::signals error

Tony Kostanjsek
Are you absolutely sure you're not destroying the Lua state before the
disconnects occur?

----- Urspr√ľngliche Mail ----
Von: Szymon Gatner <[hidden email]>
An: [hidden email]
Gesendet: Dienstag, den 15. Februar 2011, 18:01:40 Uhr
Betreff: Re: [luabind] luabind with boost::signals error

Care to elaborate?

I should not use luabind::object as a slot? Or just not disconnecting this way?

Previous code modified like so:

  signals::connection c = sig.connect(slot);

  c.disconnect();

works fine but I do not like the idea of signaled objects to keep
every connection
to every signal they register to. Any other suggestions?

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user




------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user