From af6f11c2b3a2d35774ee4150bdf08b8f9c15b5f8 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 18 Apr 2021 14:02:26 +0200 Subject: [PATCH 1/4] Fixes #715 (selection box larger than drawn) --- src/ant/ant/antService.cc | 10 +++- src/ant/ant/antService.h | 9 ++- src/edt/edt/edtPartialService.cc | 10 +++- src/edt/edt/edtPartialService.h | 9 ++- src/edt/edt/edtService.cc | 10 +++- src/edt/edt/edtService.h | 9 ++- src/img/img/imgService.cc | 8 ++- src/img/img/imgService.h | 7 ++- .../laybasic/LayoutViewConfigPage2c.ui | 55 +++++++++++++------ src/laybasic/laybasic/layEditable.h | 13 ++++- src/laybasic/laybasic/layLayoutView.cc | 20 +++++++ src/laybasic/laybasic/layLayoutView.h | 17 +++++- .../laybasic/layLayoutViewConfigPages.cc | 6 ++ src/laybasic/laybasic/laybasicConfig.h | 1 + testdata/ruby/layLayoutView.rb | 1 + 15 files changed, 151 insertions(+), 34 deletions(-) diff --git a/src/ant/ant/antService.cc b/src/ant/ant/antService.cc index f9666fd2c..74f8bd9fd 100644 --- a/src/ant/ant/antService.cc +++ b/src/ant/ant/antService.cc @@ -887,7 +887,13 @@ Service::catch_distance () return double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag (); } -void +double +Service::catch_distance_box () +{ + return double (view ()->search_range_box ()) / widget ()->mouse_event_trans ().mag (); +} + +void Service::drag_cancel () { if (m_drawing) { @@ -2037,7 +2043,7 @@ Service::select (const db::DBox &box, lay::Editable::SelectionMode mode) } else { // compute search box - double l = catch_distance (); + double l = box.is_point () ? catch_distance () : catch_distance_box (); db::DBox search_dbox = box.enlarged (db::DVector (l, l)); if (! box.is_point ()) { diff --git a/src/ant/ant/antService.h b/src/ant/ant/antService.h index 657fc4154..52d6516fb 100644 --- a/src/ant/ant/antService.h +++ b/src/ant/ant/antService.h @@ -276,11 +276,16 @@ public: virtual double click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mode); /** - * @brief Gets the catch distance + * @brief Gets the catch distance (for single click) */ virtual double catch_distance (); - /** + /** + * @brief Gets the catch distance (for box) + */ + virtual double catch_distance_box (); + + /** * @brief "select" operation */ virtual bool select (const db::DBox &box, lay::Editable::SelectionMode mode); diff --git a/src/edt/edt/edtPartialService.cc b/src/edt/edt/edtPartialService.cc index 6223a0649..abe291b3d 100644 --- a/src/edt/edt/edtPartialService.cc +++ b/src/edt/edt/edtPartialService.cc @@ -2349,7 +2349,13 @@ PartialService::catch_distance () return double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag (); } -db::DPoint +double +PartialService::catch_distance_box () +{ + return double (view ()->search_range_box ()) / widget ()->mouse_event_trans ().mag (); +} + +db::DPoint PartialService::single_selected_point () const { // build the transformation variants cache and @@ -2576,7 +2582,7 @@ PartialService::partial_select (const db::DBox &box, lay::Editable::SelectionMod clear_partial_transient_selection (); // compute search box - double l = catch_distance (); + double l = box.is_point () ? catch_distance () : catch_distance_box (); db::DBox search_box = box.enlarged (db::DVector (l, l)); bool needs_update = false; diff --git a/src/edt/edt/edtPartialService.h b/src/edt/edt/edtPartialService.h index cc94f27d5..d59b1a64e 100644 --- a/src/edt/edt/edtPartialService.h +++ b/src/edt/edt/edtPartialService.h @@ -235,11 +235,16 @@ public: virtual void transform (const db::DCplxTrans &tr); /** - * @brief Gets the catch distance + * @brief Gets the catch distance (for single click) */ virtual double catch_distance (); - /** + /** + * @brief Gets the catch distance (for box) + */ + virtual double catch_distance_box (); + + /** * @brief Indicates whether objects are selected */ virtual bool has_selection (); diff --git a/src/edt/edt/edtService.cc b/src/edt/edt/edtService.cc index e27414117..6008078a7 100644 --- a/src/edt/edt/edtService.cc +++ b/src/edt/edt/edtService.cc @@ -895,7 +895,13 @@ Service::catch_distance () return double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag (); } -double +double +Service::catch_distance_box () +{ + return double (view ()->search_range_box ()) / widget ()->mouse_event_trans ().mag (); +} + +double Service::click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mode) { // compute search box @@ -1231,7 +1237,7 @@ bool Service::select (const db::DBox &box, lay::Editable::SelectionMode mode) { // compute search box - double l = catch_distance (); + double l = box.is_point () ? catch_distance () : catch_distance_box (); db::DBox search_box = box.enlarged (db::DVector (l, l)); bool needs_update = false; diff --git a/src/edt/edt/edtService.h b/src/edt/edt/edtService.h index 129838ddf..28e61a2e9 100644 --- a/src/edt/edt/edtService.h +++ b/src/edt/edt/edtService.h @@ -179,11 +179,16 @@ public: virtual double click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mode); /** - * @brief Gets the catch distance + * @brief Gets the catch distance (for single click) */ virtual double catch_distance (); - /** + /** + * @brief Gets the catch distance (for box) + */ + virtual double catch_distance_box (); + + /** * @brief "select" operation */ virtual bool select (const db::DBox &box, lay::Editable::SelectionMode mode); diff --git a/src/img/img/imgService.cc b/src/img/img/imgService.cc index ace1ba630..71ab0e8b1 100644 --- a/src/img/img/imgService.cc +++ b/src/img/img/imgService.cc @@ -1153,6 +1153,12 @@ Service::catch_distance () return double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag (); } +double +Service::catch_distance_box () +{ + return double (view ()->search_range_box ()) / widget ()->mouse_event_trans ().mag (); +} + double Service::click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mode) { @@ -1293,7 +1299,7 @@ Service::select (const db::DBox &box, lay::Editable::SelectionMode mode) } else { // compute search box - double l = catch_distance (); + double l = box.is_point () ? catch_distance () : catch_distance_box (); db::DBox search_dbox = box.enlarged (db::DVector (l, l)); if (! box.is_point ()) { diff --git a/src/img/img/imgService.h b/src/img/img/imgService.h index e5976ec32..d3739fcfe 100644 --- a/src/img/img/imgService.h +++ b/src/img/img/imgService.h @@ -295,10 +295,15 @@ public: virtual double click_proximity (const db::DPoint &pos, lay::Editable::SelectionMode mode); /** - * @brief Gets the catch distance + * @brief Gets the catch distance for single click */ virtual double catch_distance (); + /** + * @brief Gets the catch distance for box + */ + virtual double catch_distance_box (); + /** * @brief "select" operation */ diff --git a/src/laybasic/laybasic/LayoutViewConfigPage2c.ui b/src/laybasic/laybasic/LayoutViewConfigPage2c.ui index 27e462baa..ec01634f5 100644 --- a/src/laybasic/laybasic/LayoutViewConfigPage2c.ui +++ b/src/laybasic/laybasic/LayoutViewConfigPage2c.ui @@ -214,7 +214,7 @@ QFrame::Raised - + 0 @@ -227,28 +227,14 @@ 0 - - - - Capture range to mouse cursor - - - - - - - 9999 - - - - + pixel - + Qt::Horizontal @@ -261,6 +247,41 @@ + + + + 9999 + + + + + + + Capture range to mouse cursor (single click) + + + + + + + Capture range to mouse cursor (box) + + + + + + + 9999 + + + + + + + pixel + + + diff --git a/src/laybasic/laybasic/layEditable.h b/src/laybasic/laybasic/layEditable.h index a2bfe7de1..59cbcde0d 100644 --- a/src/laybasic/laybasic/layEditable.h +++ b/src/laybasic/laybasic/layEditable.h @@ -156,7 +156,7 @@ public: } /** - * @brief The catch distance + * @brief The catch distance (for single click) * * The catch distance is a typical value for the "fuzzyness" of a mouse click. * It is given in micron. @@ -166,6 +166,17 @@ public: return 0.0; } + /** + * @brief The catch distance (for box) + * + * The catch distance is a typical value for the "fuzzyness" of a box selection. + * It is given in micron. + */ + virtual double catch_distance_box () + { + return 0.0; + } + /** * @brief transient selection * diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index 78c676c0a..1d73fdbb6 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -463,6 +463,7 @@ LayoutView::init (db::Manager *mgr, QWidget * /*parent*/) m_always_show_ld = true; m_always_show_layout_index = false; m_search_range = 5; + m_search_range_box = 0; m_layer_properties_lists.push_back (new LayerPropertiesList ()); m_layer_properties_lists.back ()->attach_view (this, (unsigned int) (m_layer_properties_lists.size () - 1)); @@ -1250,6 +1251,13 @@ LayoutView::configure (const std::string &name, const std::string &value) set_search_range (n); return true; + } else if (name == cfg_search_range_box) { + + unsigned int n; + tl::from_string (value, n); + set_search_range_box (n); + return true; + } else if (name == cfg_abstract_mode_enabled) { bool e; @@ -5882,6 +5890,18 @@ LayoutView::set_search_range (unsigned int sr) m_search_range = sr; } +unsigned int +LayoutView::search_range_box () +{ + return m_search_range_box; +} + +void +LayoutView::set_search_range_box (unsigned int sr) +{ + m_search_range_box = sr; +} + void LayoutView::message (const std::string &s, int timeout) { diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutView.h index 75cd1c4d0..93c0545d8 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutView.h @@ -2277,17 +2277,29 @@ public: } /** - * @brief Gets the "search range" in pixels + * @brief Gets the "search range" in pixels (for single click) * The search range applies whenever some object is looked up in the vicinity of the * mouse cursor. This value gives the search range in pixels. */ unsigned int search_range (); /** - * @brief Sets the "search range" in pixels + * @brief Sets the "search range" in pixels (for single click) */ void set_search_range (unsigned int sr); + /** + * @brief Gets the "search range" in pixels (for box) + * The search range applies whenever some object is looked up in the vicinity of the + * mouse cursor. This value gives the search range in pixels. + */ + unsigned int search_range_box (); + + /** + * @brief Sets the "search range" in pixels (for box) + */ + void set_search_range_box (unsigned int sr); + /** * @brief Return true, if any cellview is editable */ @@ -2808,6 +2820,7 @@ private: bool m_marker_halo; unsigned int m_search_range; + unsigned int m_search_range_box; bool m_transient_selection_mode; bool m_sel_inside_pcells; diff --git a/src/laybasic/laybasic/layLayoutViewConfigPages.cc b/src/laybasic/laybasic/layLayoutViewConfigPages.cc index 506b63294..fd9d48996 100644 --- a/src/laybasic/laybasic/layLayoutViewConfigPages.cc +++ b/src/laybasic/laybasic/layLayoutViewConfigPages.cc @@ -374,6 +374,10 @@ LayoutViewConfigPage2c::setup (lay::Dispatcher *root) unsigned int sr = 0; root->config_get (cfg_search_range, sr); mp_ui->search_range_spinbx->setValue (sr); + + unsigned int srbox = 0; + root->config_get (cfg_search_range_box, srbox); + mp_ui->search_range_box_spinbx->setValue (srbox); } void @@ -388,6 +392,7 @@ LayoutViewConfigPage2c::commit (lay::Dispatcher *root) root->config_set (cfg_sel_transient_mode, mp_ui->transient_mode_cb->isChecked ()); root->config_set (cfg_sel_inside_pcells_mode, mp_ui->sel_inside_pcells_cb->isChecked ()); root->config_set (cfg_search_range, (unsigned int) mp_ui->search_range_spinbx->value ()); + root->config_set (cfg_search_range_box, (unsigned int) mp_ui->search_range_box_spinbx->value ()); } // ------------------------------------------------------------ @@ -1564,6 +1569,7 @@ public: options.push_back (std::pair (cfg_child_ctx_hollow, "false")); options.push_back (std::pair (cfg_child_ctx_enabled, "false")); options.push_back (std::pair (cfg_search_range, "5")); + options.push_back (std::pair (cfg_search_range_box, "0")); options.push_back (std::pair (cfg_abstract_mode_width, "10.0")); options.push_back (std::pair (cfg_abstract_mode_enabled, "false")); options.push_back (std::pair (cfg_fit_new_cell, "true")); diff --git a/src/laybasic/laybasic/laybasicConfig.h b/src/laybasic/laybasic/laybasicConfig.h index e2f596f54..3cdd575f0 100644 --- a/src/laybasic/laybasic/laybasicConfig.h +++ b/src/laybasic/laybasic/laybasicConfig.h @@ -62,6 +62,7 @@ static const std::string cfg_child_ctx_hollow ("child-context-hollow"); static const std::string cfg_child_ctx_enabled ("child-context-enabled"); static const std::string cfg_search_range ("search-range"); +static const std::string cfg_search_range_box ("search-range-box"); static const std::string cfg_abstract_mode_enabled ("abstract-mode-enabled"); static const std::string cfg_abstract_mode_width ("abstract-mode-width"); diff --git a/testdata/ruby/layLayoutView.rb b/testdata/ruby/layLayoutView.rb index 056e53f82..8ed0b6817 100644 --- a/testdata/ruby/layLayoutView.rb +++ b/testdata/ruby/layLayoutView.rb @@ -183,6 +183,7 @@ class LAYLayoutView_TestClass < TestBase assert_equal(view.has_selection?, false) assert_equal(view.selection_size, 0) + view.set_config("search-range-box", "5") view.select_from(RBA::DBox::new(-1.0, -1.0, 1.0, 1.0)) assert_equal(selection_changed, 1) assert_equal(view.selection_size, 4) From 7a6364506d1187de7d3576d90fb07be58c24632d Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 18 Apr 2021 14:27:00 +0200 Subject: [PATCH 2/4] klayout -v and -h now work without a display --- src/klayout_main/klayout_main/klayout.cc | 45 ++++++++++++++++-------- src/lay/lay/gsiDeclLayApplication.cc | 8 ++++- src/lay/lay/layApplication.cc | 12 +------ src/lay/lay/layApplication.h | 4 +-- src/lay/lay/layHelpSource.cc | 4 +-- src/lay/lay/layMainWindow.cc | 4 +-- 6 files changed, 45 insertions(+), 32 deletions(-) diff --git a/src/klayout_main/klayout_main/klayout.cc b/src/klayout_main/klayout_main/klayout.cc index 8091c7196..8d2fec11d 100644 --- a/src/klayout_main/klayout_main/klayout.cc +++ b/src/klayout_main/klayout_main/klayout.cc @@ -202,20 +202,6 @@ static int klayout_main_cont (int &argc, char **argv); */ int klayout_main (int &argc, char **argv) -{ - // This special initialization is required by the Ruby interpreter because it wants to mark the stack - int ret = rba::RubyInterpreter::initialize (argc, argv, &klayout_main_cont); - - // clean up all static data now, since we don't trust the static destructors. - // NOTE: this needs to happen after the Ruby interpreter went down since otherwise the GC will - // access objects that are already cleaned up. - tl::StaticObjects::cleanup (); - - return ret; -} - -int -klayout_main_cont (int &argc, char **argv) { // install the version strings lay::Version::set_exe_name (prg_exe_name); @@ -237,6 +223,37 @@ klayout_main_cont (int &argc, char **argv) about_text += prg_about_text; lay::Version::set_about_text (about_text.c_str ()); + // Capture the shortcut command line arguments + for (int i = 1; i < argc; ++i) { + + if (argv [i] == std::string ("-v")) { + + tl::info << lay::ApplicationBase::version (); + return 0; + + } else if (argv [i] == std::string ("-h")) { + + tl::info << lay::ApplicationBase::usage () << tl::noendl; + return 0; + + } + + } + + // This special initialization is required by the Ruby interpreter because it wants to mark the stack + int ret = rba::RubyInterpreter::initialize (argc, argv, &klayout_main_cont); + + // clean up all static data now, since we don't trust the static destructors. + // NOTE: this needs to happen after the Ruby interpreter went down since otherwise the GC will + // access objects that are already cleaned up. + tl::StaticObjects::cleanup (); + + return ret; +} + +int +klayout_main_cont (int &argc, char **argv) +{ #if QT_VERSION >= 0x050000 qInstallMessageHandler (myMessageOutput); #else diff --git a/src/lay/lay/gsiDeclLayApplication.cc b/src/lay/lay/gsiDeclLayApplication.cc index f499f921e..a578881dd 100644 --- a/src/lay/lay/gsiDeclLayApplication.cc +++ b/src/lay/lay/gsiDeclLayApplication.cc @@ -81,6 +81,12 @@ static std::string arch (C *) return tl::arch_string (); } +template +static std::string version (C *) +{ + return C::version (); +} + template static gsi::Methods application_methods () { @@ -213,7 +219,7 @@ static gsi::Methods application_methods () "\n" "This method has been added in version 0.22." ) + - method ("version", &C::version, + method_ext ("version", &version, "@brief Returns the application's version string\n" ) + method_ext ("arch", &arch, diff --git a/src/lay/lay/layApplication.cc b/src/lay/lay/layApplication.cc index 21bc51c24..76a9000cd 100644 --- a/src/lay/lay/layApplication.cc +++ b/src/lay/lay/layApplication.cc @@ -483,16 +483,6 @@ ApplicationBase::parse_cmd (int &argc, char **argv) m_packages_with_dep = true; - } else if (a == "-v") { - - tl::info << lay::Version::name () << " " << lay::Version::version (); - exit (0); - - } else if (a == "-h") { - - tl::info << usage () << tl::noendl; - exit (0); - } else if (a == "-m" && (i + 1) < argc) { m_files.push_back (std::make_pair (rdb_file, std::make_pair (std::string (args [++i]), std::string ()))); @@ -929,7 +919,7 @@ ApplicationBase::instance () } std::string -ApplicationBase::version () const +ApplicationBase::version () { return std::string (lay::Version::name ()) + " " + lay::Version::version (); } diff --git a/src/lay/lay/layApplication.h b/src/lay/lay/layApplication.h index 6aedf8d41..0e28ae394 100644 --- a/src/lay/lay/layApplication.h +++ b/src/lay/lay/layApplication.h @@ -100,12 +100,12 @@ public: /** * @brief Return the program's version */ - std::string version () const; + static std::string version (); /** * @brief Return the program's usage string */ - std::string usage (); + static std::string usage (); /** * @brief Returns the main window's reference diff --git a/src/lay/lay/layHelpSource.cc b/src/lay/lay/layHelpSource.cc index 4b6f236f1..1460084d0 100644 --- a/src/lay/lay/layHelpSource.cc +++ b/src/lay/lay/layHelpSource.cc @@ -283,7 +283,7 @@ HelpSource::initialize_index () try { tl::XMLFileSource in (*c); help_index_structure.parse (in, *this); - if (m_klayout_version == lay::ApplicationBase::instance ()->version ()) { + if (m_klayout_version == lay::ApplicationBase::version ()) { ok = true; } } catch (tl::Exception &ex) { @@ -352,7 +352,7 @@ HelpSource::create_index_file (const std::string &path) std::string HelpSource::klayout_version () const { - return lay::ApplicationBase::instance ()->version (); + return lay::ApplicationBase::version (); } void diff --git a/src/lay/lay/layMainWindow.cc b/src/lay/lay/layMainWindow.cc index 41cf82007..9a33b027f 100644 --- a/src/lay/lay/layMainWindow.cc +++ b/src/lay/lay/layMainWindow.cc @@ -3543,9 +3543,9 @@ MainWindow::update_window_title () if (current_view ()->is_dirty ()) { sep += "[+] "; } - setWindowTitle (tl::to_qstring (lay::ApplicationBase::instance ()->version () + sep + current_view ()->title ())); + setWindowTitle (tl::to_qstring (lay::ApplicationBase::version () + sep + current_view ()->title ())); } else { - setWindowTitle (tl::to_qstring (lay::ApplicationBase::instance ()->version ())); + setWindowTitle (tl::to_qstring (lay::ApplicationBase::version ())); } } From f8b8408adbe45c14bb0568516279be2097a2c213 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 18 Apr 2021 14:36:39 +0200 Subject: [PATCH 3/4] No comment skipping in descriptions - fixed #747 --- src/rdb/rdb/rdbRVEReader.cc | 2 +- src/rdb/unit_tests/rdbRVEReaderTests.cc | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/rdb/rdb/rdbRVEReader.cc b/src/rdb/rdb/rdbRVEReader.cc index 950dfe2ae..533ddde7a 100644 --- a/src/rdb/rdb/rdbRVEReader.cc +++ b/src/rdb/rdb/rdbRVEReader.cc @@ -146,7 +146,7 @@ public: error (tl::to_string (tr ("Unexpected end of file"))); } - std::string l = get_line (); + std::string l = m_input_stream.get_line (); if (l.size () > 3 && l[0] == 'W' && l[1] == 'E' && isdigit (l[2])) { size_t n = 0; diff --git a/src/rdb/unit_tests/rdbRVEReaderTests.cc b/src/rdb/unit_tests/rdbRVEReaderTests.cc index 096c36df1..bb4b6129c 100644 --- a/src/rdb/unit_tests/rdbRVEReaderTests.cc +++ b/src/rdb/unit_tests/rdbRVEReaderTests.cc @@ -76,3 +76,8 @@ TEST(2) { run_rve_test (_this, "rve2.db", "rve2_au.txt"); } + +TEST(3) +{ + run_rve_test (_this, "rve3.db", "rve3_au.txt"); +} From e6ab8c2483511e221d95c316bc3c833b026f6b24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20K=C3=B6fferlein?= Date: Mon, 19 Apr 2021 22:28:27 +0200 Subject: [PATCH 4/4] Issue 771 (#773) * Fixed the issue - Byte array variant was not properly converted to Python/Ruby objects. * Added tests + properly converting byte arrays to byte array variants in Python. --- src/pya/pya/pyaConvert.cc | 8 ++++++-- src/rba/rba/rbaConvert.cc | 2 ++ testdata/python/basic.py | 7 +++++++ testdata/python/qtbinding.py | 10 ++++++++++ testdata/ruby/qtbinding.rb | 11 +++++++++++ 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/pya/pya/pyaConvert.cc b/src/pya/pya/pyaConvert.cc index 9c091b568..271a71234 100644 --- a/src/pya/pya/pyaConvert.cc +++ b/src/pya/pya/pyaConvert.cc @@ -282,10 +282,12 @@ tl::Variant python2c_func::operator() (PyObject *rval) return tl::Variant (python2c (rval)); #else } else if (PyBytes_Check (rval)) { - return tl::Variant (python2c (rval)); + return tl::Variant (python2c > (rval)); #endif - } else if (PyUnicode_Check (rval) || PyByteArray_Check (rval)) { + } else if (PyUnicode_Check (rval)) { return tl::Variant (python2c (rval)); + } else if (PyByteArray_Check (rval)) { + return tl::Variant (python2c > (rval)); } else if (PyList_Check (rval)) { size_t len = PyList_Size (rval); @@ -496,6 +498,8 @@ PyObject *c2python_func::operator() (const tl::Variant &c) return c2python (c.to_bool ()); } else if (c.is_a_string ()) { return c2python (c.to_string ()); + } else if (c.is_a_bytearray ()) { + return c2python (c.to_bytearray ()); } else if (c.is_long ()) { return c2python (c.to_long ()); } else if (c.is_ulong ()) { diff --git a/src/rba/rba/rbaConvert.cc b/src/rba/rba/rbaConvert.cc index a654748b5..06292b34f 100644 --- a/src/rba/rba/rbaConvert.cc +++ b/src/rba/rba/rbaConvert.cc @@ -262,6 +262,8 @@ VALUE c2ruby (const tl::Variant &c) return c2ruby (c.to_bool ()); } else if (c.is_a_string ()) { return c2ruby (c.to_string ()); + } else if (c.is_a_bytearray ()) { + return c2ruby > (c.to_bytearray ()); } else if (c.is_long () || c.is_char ()) { return c2ruby (c.to_long ()); } else if (c.is_ulong ()) { diff --git a/testdata/python/basic.py b/testdata/python/basic.py index 0e5d67fa7..1e653628d 100644 --- a/testdata/python/basic.py +++ b/testdata/python/basic.py @@ -1304,6 +1304,13 @@ class BasicTest(unittest.TestCase): self.assertEqual( str(b.b22c()), "hallo" ) self.assertEqual( type(b.b22c()).__name__, "LayerInfo" ) + # byte arrays through Variants + if sys.version_info >= (3, 0): + self.assertEqual( b.b22a( [ bytes('abc', 'utf-8') ] ), 1 ) + self.assertEqual( str(b.b22c()), "b'abc'" ) + self.assertEqual( str(b.b22d()), "b'abc'" ) + self.assertEqual( str(b.var()), "b'abc'" ) + def test_23(self): b = pya.B() diff --git a/testdata/python/qtbinding.py b/testdata/python/qtbinding.py index 5a2acd1a0..c25c4745c 100644 --- a/testdata/python/qtbinding.py +++ b/testdata/python/qtbinding.py @@ -629,6 +629,16 @@ class QtBindingTest(unittest.TestCase): self.assertEqual(len(buf.data) > 100, True) self.assertEqual(buf.data[0:8], b'\x89PNG\r\n\x1a\n') + def test_53(self): + + # issue #771 (QMimeData not working) + mimeData = pya.QMimeData() + mimeData.setData("application/json",'{"test":"test"}') + jsonData = mimeData.data("application/json"); + if sys.version_info < (3, 0): + self.assertEqual(str(jsonData), '{"test":"test"}') + else: + self.assertEqual(str(jsonData), 'b\'{"test":"test"}\'') # run unit tests if __name__ == '__main__': diff --git a/testdata/ruby/qtbinding.rb b/testdata/ruby/qtbinding.rb index dfd4ecac3..e55bbc532 100644 --- a/testdata/ruby/qtbinding.rb +++ b/testdata/ruby/qtbinding.rb @@ -744,6 +744,17 @@ class QtBinding_TestClass < TestBase end + def test_53 + + # issue #771 (QMimeData not working) + + mimeData = RBA::QMimeData::new + mimeData.setData("application/json", '{"test":"test"}') + jsonData = mimeData.data("application/json"); + assert_equal(jsonData.to_s, '{"test":"test"}') + + end + end load("test_epilogue.rb")