From c442202ca4f08bca9fc4bfed389512ff43ccb524 Mon Sep 17 00:00:00 2001 From: klayoutmatthias Date: Sun, 23 Jul 2017 23:36:29 +0200 Subject: [PATCH] Enabled Windows build on Qt5. --- src/db/dbHash.h | 28 +++++++++++++++++++++++++++- src/lay/layApplication.cc | 2 +- src/lay/laySaltDownloadManager.cc | 3 ++- src/lay/laySignalHandler.cc | 3 ++- src/tl/tlFileUtils.h | 6 +++--- testdata/python/dbPCells.py | 17 +++++++++++++---- testdata/ruby/qtbinding.rb | 14 +++++++------- 7 files changed, 55 insertions(+), 18 deletions(-) diff --git a/src/db/dbHash.h b/src/db/dbHash.h index 75b050a46..57c9a5f45 100644 --- a/src/db/dbHash.h +++ b/src/db/dbHash.h @@ -62,7 +62,7 @@ namespace DB_HASH_NAMESPACE { #if defined(_WIN64) /** - * @brief Specialization missing for size_t on WIN32 + * @brief Specialization missing for size_t on WIN64 */ template<> struct hash @@ -74,6 +74,32 @@ namespace DB_HASH_NAMESPACE }; #endif +#if defined(_WIN64) + /** + * @brief Specialization missing for long long on WIN64 + */ + template<> + struct hash + { + size_t operator()(long long __x) const + { + return size_t (__x); + } + }; +#elif defined(_WIN32) + /** + * @brief Specialization missing for long long (64 bit) on WIN32 + */ + template<> + struct hash + { + size_t operator()(long long __x) const + { + return size_t (__x ^ (__x >> 32)); + } + }; +#endif + template inline size_t hfunc (const T &t) { diff --git a/src/lay/layApplication.cc b/src/lay/layApplication.cc index f03dc0987..fbbd78b5e 100644 --- a/src/lay/layApplication.cc +++ b/src/lay/layApplication.cc @@ -180,7 +180,7 @@ static PluginDescriptor load_plugin (const std::string &pp) if (! handle) { throw tl::Exception (tl::to_string (QObject::tr ("Unable to load plugin: %s with error message: %s ")), pp, GetLastError ()); } - init_func = reinterpret_cast (GetProcAddress (handle, init_func_name)); + init_func = reinterpret_cast (GetProcAddress (handle, init_func_name)); #else void *handle; handle = dlopen (tl::string_to_system (pp).c_str (), RTLD_LAZY); diff --git a/src/lay/laySaltDownloadManager.cc b/src/lay/laySaltDownloadManager.cc index efe5066b5..0fdd4dddb 100644 --- a/src/lay/laySaltDownloadManager.cc +++ b/src/lay/laySaltDownloadManager.cc @@ -28,6 +28,7 @@ #include #include #include +#include namespace lay { @@ -65,7 +66,7 @@ ConfirmationDialog::add_info (const std::string &name, bool update, const std::s item->setText (3, tl::to_qstring (url)); for (int column = 0; column < list->colorCount (); ++column) { - item->setData (column, Qt::ForegroundRole, update ? Qt::blue : Qt::black); + item->setData (column, Qt::ForegroundRole, QVariant (QBrush (update ? Qt::blue : Qt::black))); } } diff --git a/src/lay/laySignalHandler.cc b/src/lay/laySignalHandler.cc index 9b65614c2..68d6aceb1 100644 --- a/src/lay/laySignalHandler.cc +++ b/src/lay/laySignalHandler.cc @@ -43,6 +43,7 @@ #endif #include +#include namespace lay { @@ -234,7 +235,7 @@ static void handle_signal (int signo) RaiseException(signo + user_base, 0, 0, NULL); } -static void install_signal_handlers () +void install_signal_handlers () { // disable any signal handlers that Ruby might have installed. signal (SIGSEGV, SIG_DFL); diff --git a/src/tl/tlFileUtils.h b/src/tl/tlFileUtils.h index be25bd843..634dc6b7c 100644 --- a/src/tl/tlFileUtils.h +++ b/src/tl/tlFileUtils.h @@ -38,7 +38,7 @@ bool TL_PUBLIC is_parent_path (const QString &parent, const QString &path); /** * @brief Returns a value indicating whether the parent path is a parent directory of the path (version with std::string) */ -inline bool TL_PUBLIC is_parent_path (const std::string &parent, const std::string &path) +inline bool is_parent_path (const std::string &parent, const std::string &path) { return is_parent_path (tl::to_qstring (parent), tl::to_qstring (path)); } @@ -53,7 +53,7 @@ bool TL_PUBLIC rm_dir_recursive (const QString &path); * @brief Recursively remove the given directory, the files from that directory and all sub-directories (version with std::string) * @return True, if successful. false otherwise. */ -inline bool TL_PUBLIC rm_dir_recursive (const std::string &path) +inline bool rm_dir_recursive (const std::string &path) { return rm_dir_recursive (tl::to_qstring (path)); } @@ -70,7 +70,7 @@ bool TL_PUBLIC cp_dir_recursive (const QString &source, const QString &target); * @brief Recursively remove the given directory, the files from that directory and all sub-directories (version with std::string) * @return True, if successful. false otherwise. */ -inline bool TL_PUBLIC cp_dir_recursive (const std::string &source, const std::string &target) +inline bool cp_dir_recursive (const std::string &source, const std::string &target) { return cp_dir_recursive (tl::to_qstring (source), tl::to_qstring (target)); } diff --git a/testdata/python/dbPCells.py b/testdata/python/dbPCells.py index b5320462a..17f2eb299 100644 --- a/testdata/python/dbPCells.py +++ b/testdata/python/dbPCells.py @@ -88,6 +88,15 @@ def find_layer(ly, lp): return None +def nh(h): + """ + Returns a normalized hash representation + """ + v = [] + for k in sorted(h): + v.append(repr(k) + ": " + repr(h[k])) + return "{" + (", ".join(v)) + "}" + class DBPCellTests(unittest.TestCase): def test_1(self): @@ -132,12 +141,12 @@ class DBPCellTests(unittest.TestCase): self.assertEqual(pcell_var.pcell_id(), pcell_decl_id) self.assertEqual(pcell_var.pcell_library().__repr__(), lib.__repr__()) self.assertEqual(pcell_var.pcell_parameters().__repr__(), "[<1/0>, 1.0, 1.0]") - self.assertEqual(pcell_var.pcell_parameters_by_name().__repr__(), "{'h': 1.0, 'l': <1/0>, 'w': 1.0}") + self.assertEqual(nh(pcell_var.pcell_parameters_by_name()), "{'h': 1.0, 'l': <1/0>, 'w': 1.0}") self.assertEqual(pcell_var.pcell_parameter("h").__repr__(), "1.0") self.assertEqual(c1.pcell_parameters(pcell_inst).__repr__(), "[<1/0>, 1.0, 1.0]") - self.assertEqual(c1.pcell_parameters_by_name(pcell_inst).__repr__(), "{'h': 1.0, 'l': <1/0>, 'w': 1.0}") + self.assertEqual(nh(c1.pcell_parameters_by_name(pcell_inst)), "{'h': 1.0, 'l': <1/0>, 'w': 1.0}") self.assertEqual(c1.pcell_parameter(pcell_inst, "h").__repr__(), "1.0") - self.assertEqual(pcell_inst.pcell_parameters_by_name().__repr__(), "{'h': 1.0, 'l': <1/0>, 'w': 1.0}") + self.assertEqual(nh(pcell_inst.pcell_parameters_by_name()), "{'h': 1.0, 'l': <1/0>, 'w': 1.0}") self.assertEqual(pcell_inst["h"].__repr__(), "1.0") self.assertEqual(pcell_inst["i"].__repr__(), "None") self.assertEqual(pcell_inst.pcell_parameter("h").__repr__(), "1.0") @@ -146,7 +155,7 @@ class DBPCellTests(unittest.TestCase): self.assertEqual(pcell_inst.pcell_declaration().__repr__(), pcell_decl.__repr__()) pcell_inst.change_pcell_parameter("h", 2.0) - self.assertEqual(pcell_inst.pcell_parameters_by_name().__repr__(), "{'h': 2.0, 'l': <1/0>, 'w': 1.0}") + self.assertEqual(nh(pcell_inst.pcell_parameters_by_name()), "{'h': 2.0, 'l': <1/0>, 'w': 1.0}") pcell_inst.set_property("abc", "a property") self.assertEqual(pcell_inst.property("abc").__repr__(), "'a property'") diff --git a/testdata/ruby/qtbinding.rb b/testdata/ruby/qtbinding.rb index cada243dd..c74c396ad 100644 --- a/testdata/ruby/qtbinding.rb +++ b/testdata/ruby/qtbinding.rb @@ -156,8 +156,8 @@ class QtBinding_TestClass < TestBase # destroying a will also destroy aa a.destroy - assert_equal(a.destroyed?, true) - assert_equal(aa.destroyed?, true) + assert_equal(a._destroyed?, true) + assert_equal(aa._destroyed?, true) end @@ -174,7 +174,7 @@ class QtBinding_TestClass < TestBase a = nil GC.start - assert_equal(aa.destroyed?, true) + assert_equal(aa._destroyed?, true) end @@ -207,7 +207,7 @@ class QtBinding_TestClass < TestBase assert_equal(aa != nil, true) assert_equal(aa.class.to_s, "RBA::QAction") assert_equal(aa.text, "aatext") - assert_equal(aa.destroyed?, false) + assert_equal(aa._destroyed?, false) end @@ -569,7 +569,7 @@ class QtBinding_TestClass < TestBase child = parent.viewport # ensure parent and child are working - assert_equal(child.destroyed?, false) + assert_equal(child._destroyed?, false) parent.resize(200, 200) assert_equal(child.width() > 100, true) @@ -582,8 +582,8 @@ class QtBinding_TestClass < TestBase # now if we delete the parent, the child needs to become disconnected parent._destroy() - assert_equal(parent.destroyed?, true) - assert_equal(child.destroyed?, true) + assert_equal(parent._destroyed?, true) + assert_equal(child._destroyed?, true) end