diff --git a/src/lym/unit_tests/unit_tests.pro b/src/lym/unit_tests/unit_tests.pro index 8aec7683c..f6947c4d2 100644 --- a/src/lym/unit_tests/unit_tests.pro +++ b/src/lym/unit_tests/unit_tests.pro @@ -12,5 +12,17 @@ SOURCES = \ INCLUDEPATH += $$RBA_INC $$PYA_INC $$LYM_INC $$TL_INC $$GSI_INC DEPENDPATH += $$RBA_INC $$PYA_INC $$LYM_INC $$TL_INC $$GSI_INC -LIBS += -L$$DESTDIR_UT -lklayout_rba -lklayout_pya -lklayout_lym -lklayout_tl -lklayout_gsi +LIBS += -L$$DESTDIR_UT -lklayout_lym -lklayout_tl -lklayout_gsi + +equals(HAVE_RUBY, "1") { + LIBS += -lklayout_rba +} else { + LIBS += -lklayout_rbastub +} + +equals(HAVE_PYTHON, "1") { + LIBS += -lklayout_pya +} else { + LIBS += -lklayout_pyastub +} diff --git a/src/rba/rba/rba.cc b/src/rba/rba/rba.cc index 3ee9dd964..6de8b89fd 100644 --- a/src/rba/rba/rba.cc +++ b/src/rba/rba/rba.cc @@ -1010,16 +1010,29 @@ method_adaptor (int mid, int argc, VALUE *argv, VALUE self, bool ctor) static ID id_to_enum = rb_intern ("to_enum"); - VALUE method_sym = ID2SYM (rb_intern (meth->primary_name ().c_str ())); + VALUE method_sym = ID2SYM (rb_intern2 (meth->primary_name ().c_str (), (long) meth->primary_name ().size ())); if (argc == 0) { ret = rba_funcall2_checked (self, id_to_enum, 1, &method_sym); } else { +#if 0 + // this solution does not work on MSVC2017 for unknown reasons and + // makes the application segfault even without being called std::vector new_args; new_args.reserve (size_t (argc + 1)); new_args.push_back (method_sym); new_args.insert (new_args.end (), argv, argv + argc); ret = rba_funcall2_checked (self, id_to_enum, argc + 1, new_args.begin ().operator-> ()); +#else + VALUE new_args[16]; + tl_assert (argc + 1 <= sizeof(new_args) / sizeof(new_args[0])); + VALUE *a = &new_args[0]; + *a++ = method_sym; + for (int i = 0; i < argc; ++i) { + *a++ = argv[i]; + } + ret = rba_funcall2_checked (self, id_to_enum, argc + 1, &new_args[0]); +#endif } } else { diff --git a/testdata/ruby/qtbinding.rb b/testdata/ruby/qtbinding.rb index f8b7471d4..54b596542 100644 --- a/testdata/ruby/qtbinding.rb +++ b/testdata/ruby/qtbinding.rb @@ -679,9 +679,16 @@ class QtBinding_TestClass < TestBase w = RBA::QObject::new - on = nil - w.objectNameChanged do |name| - on = name + if w.respond_to?(:objectNameChanged) # Qt5 + + on = nil + w.objectNameChanged do |name| + on = name + end + + w.objectName = "uvw" + assert_equal(on, "uvw") + end od = false @@ -689,12 +696,7 @@ class QtBinding_TestClass < TestBase od = true end - w.objectName = "uvw" - - assert_equal(on, "uvw") - w._destroy - assert_equal(od, true) end