From ecc0520ffb93862d96d7c37eb5ed7bc34d69eabd Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 31 May 2018 17:54:29 +0200 Subject: [PATCH] WIP: Qt5 compatibility --- src/gsiqt/qtbasic/gsiQtCoreExternals.h | 10 +++++----- src/gsiqt/qtbasic/gsiQtDesignerExternals.h | 10 +++++----- src/gsiqt/qtbasic/gsiQtGuiExternals.h | 10 +++++----- src/gsiqt/qtbasic/gsiQtMultimediaExternals.h | 9 +++++---- src/gsiqt/qtbasic/gsiQtNetworkExternals.h | 10 +++++----- .../qtbasic/gsiQtPrintSupportExternals.h | 9 +++++---- src/gsiqt/qtbasic/gsiQtSqlExternals.h | 10 +++++----- src/gsiqt/qtbasic/gsiQtSvgExternals.h | 9 +++++---- src/gsiqt/qtbasic/gsiQtWidgetsExternals.h | 9 +++++---- src/gsiqt/qtbasic/gsiQtXmlExternals.h | 10 +++++----- src/gsiqt/qtbasic/gsiQtXmlPatternsExternals.h | 9 +++++---- src/lay/lay/gsiDeclLayApplication.cc | 2 ++ src/lay/lay/gsiDeclLayHelpDialog.cc | 1 + src/lay/lay/gsiDeclLayMainWindow.cc | 1 + src/lay/lay/layGSIHelpProvider.cc | 12 +++++------ src/lay/lay/laySaltDownloadManager.cc | 6 +++--- src/laybasic/laybasic/gsiDeclLayDialogs.cc | 2 ++ src/pya/pya/pya.cc | 9 +++++++-- src/pya/pya/pya.h | 3 +++ src/pymod/db/dbMain.cc | 20 ++++++++++++++++--- 20 files changed, 96 insertions(+), 65 deletions(-) diff --git a/src/gsiqt/qtbasic/gsiQtCoreExternals.h b/src/gsiqt/qtbasic/gsiQtCoreExternals.h index a75b9431a..e4455db87 100644 --- a/src/gsiqt/qtbasic/gsiQtCoreExternals.h +++ b/src/gsiqt/qtbasic/gsiQtCoreExternals.h @@ -20,8 +20,8 @@ */ -# if defined(HAVE_QT5) -# include "../qt5/QtCore/gsiQtExternals.h" -# else -# include "../qt4/QtCore/gsiQtExternals.h" -# endif +#if QT_VERSION >= 0x050000 +# include "../qt5/QtCore/gsiQtExternals.h" +#else +# include "../qt4/QtCore/gsiQtExternals.h" +#endif diff --git a/src/gsiqt/qtbasic/gsiQtDesignerExternals.h b/src/gsiqt/qtbasic/gsiQtDesignerExternals.h index b7a0e9b96..e1c28a161 100644 --- a/src/gsiqt/qtbasic/gsiQtDesignerExternals.h +++ b/src/gsiqt/qtbasic/gsiQtDesignerExternals.h @@ -20,8 +20,8 @@ */ -# if defined(HAVE_QT5) -# include "../qt5/QtDesigner/gsiQtExternals.h" -# else -# include "../qt4/QtDesigner/gsiQtExternals.h" -# endif +#if QT_VERSION >= 0x050000 +# include "../qt5/QtDesigner/gsiQtExternals.h" +#else +# include "../qt4/QtDesigner/gsiQtExternals.h" +#endif diff --git a/src/gsiqt/qtbasic/gsiQtGuiExternals.h b/src/gsiqt/qtbasic/gsiQtGuiExternals.h index d29f50f8e..2773c3da4 100644 --- a/src/gsiqt/qtbasic/gsiQtGuiExternals.h +++ b/src/gsiqt/qtbasic/gsiQtGuiExternals.h @@ -20,8 +20,8 @@ */ -# if defined(HAVE_QT5) -# include "../qt5/QtGui/gsiQtExternals.h" -# else -# include "../qt4/QtGui/gsiQtExternals.h" -# endif +#if QT_VERSION >= 0x050000 +# include "../qt5/QtGui/gsiQtExternals.h" +#else +# include "../qt4/QtGui/gsiQtExternals.h" +#endif diff --git a/src/gsiqt/qtbasic/gsiQtMultimediaExternals.h b/src/gsiqt/qtbasic/gsiQtMultimediaExternals.h index 92b57b42d..e06e15135 100644 --- a/src/gsiqt/qtbasic/gsiQtMultimediaExternals.h +++ b/src/gsiqt/qtbasic/gsiQtMultimediaExternals.h @@ -20,8 +20,9 @@ */ -# if defined(HAVE_QT5) -# include "../qt5/QtMultimedia/gsiQtExternals.h" -# else +#if QT_VERSION >= 0x050000 +# include "../qt5/QtMultimedia/gsiQtExternals.h" +#else // no present in Qt4 -# endif +# define FORCE_LINK_GSI_QTMULTIMEDIA +#endif diff --git a/src/gsiqt/qtbasic/gsiQtNetworkExternals.h b/src/gsiqt/qtbasic/gsiQtNetworkExternals.h index eaf881f54..003609d87 100644 --- a/src/gsiqt/qtbasic/gsiQtNetworkExternals.h +++ b/src/gsiqt/qtbasic/gsiQtNetworkExternals.h @@ -20,8 +20,8 @@ */ -# if defined(HAVE_QT5) -# include "../qt5/QtNetwork/gsiQtExternals.h" -# else -# include "../qt4/QtNetwork/gsiQtExternals.h" -# endif +#if QT_VERSION >= 0x050000 +# include "../qt5/QtNetwork/gsiQtExternals.h" +#else +# include "../qt4/QtNetwork/gsiQtExternals.h" +#endif diff --git a/src/gsiqt/qtbasic/gsiQtPrintSupportExternals.h b/src/gsiqt/qtbasic/gsiQtPrintSupportExternals.h index b06f09aa3..f372abccc 100644 --- a/src/gsiqt/qtbasic/gsiQtPrintSupportExternals.h +++ b/src/gsiqt/qtbasic/gsiQtPrintSupportExternals.h @@ -20,8 +20,9 @@ */ -# if defined(HAVE_QT5) -# include "../qt5/QtPrintSupport/gsiQtExternals.h" -# else +#if QT_VERSION >= 0x050000 +# include "../qt5/QtPrintSupport/gsiQtExternals.h" +#else // no present in Qt4 -# endif +# define FORCE_LINK_GSI_QTPRINTSUPPORT +#endif diff --git a/src/gsiqt/qtbasic/gsiQtSqlExternals.h b/src/gsiqt/qtbasic/gsiQtSqlExternals.h index 703a3c546..a0a45a4e2 100644 --- a/src/gsiqt/qtbasic/gsiQtSqlExternals.h +++ b/src/gsiqt/qtbasic/gsiQtSqlExternals.h @@ -20,8 +20,8 @@ */ -# if defined(HAVE_QT5) -# include "../qt5/QtSql/gsiQtExternals.h" -# else -# include "../qt4/QtSql/gsiQtExternals.h" -# endif +#if QT_VERSION >= 0x050000 +# include "../qt5/QtSql/gsiQtExternals.h" +#else +# include "../qt4/QtSql/gsiQtExternals.h" +#endif diff --git a/src/gsiqt/qtbasic/gsiQtSvgExternals.h b/src/gsiqt/qtbasic/gsiQtSvgExternals.h index 1a45dee68..07edc0492 100644 --- a/src/gsiqt/qtbasic/gsiQtSvgExternals.h +++ b/src/gsiqt/qtbasic/gsiQtSvgExternals.h @@ -20,8 +20,9 @@ */ -# if defined(HAVE_QT5) -# include "../qt5/QtSvg/gsiQtExternals.h" -# else +#if QT_VERSION >= 0x050000 +# include "../qt5/QtSvg/gsiQtExternals.h" +#else // no present in Qt4 -# endif +# define FORCE_LINK_GSI_QTSVG +#endif diff --git a/src/gsiqt/qtbasic/gsiQtWidgetsExternals.h b/src/gsiqt/qtbasic/gsiQtWidgetsExternals.h index d3a337121..5188b45a6 100644 --- a/src/gsiqt/qtbasic/gsiQtWidgetsExternals.h +++ b/src/gsiqt/qtbasic/gsiQtWidgetsExternals.h @@ -20,8 +20,9 @@ */ -# if defined(HAVE_QT5) -# include "../qt5/QtWidgets/gsiQtExternals.h" -# else +#if QT_VERSION >= 0x050000 +# include "../qt5/QtWidgets/gsiQtExternals.h" +#else // no present in Qt4 -# endif +# define FORCE_LINK_GSI_QTWIDGETS +#endif diff --git a/src/gsiqt/qtbasic/gsiQtXmlExternals.h b/src/gsiqt/qtbasic/gsiQtXmlExternals.h index cc7696962..317bd2fbe 100644 --- a/src/gsiqt/qtbasic/gsiQtXmlExternals.h +++ b/src/gsiqt/qtbasic/gsiQtXmlExternals.h @@ -20,8 +20,8 @@ */ -# if defined(HAVE_QT5) -# include "../qt5/QtXml/gsiQtExternals.h" -# else -# include "../qt4/QtXml/gsiQtExternals.h" -# endif +#if QT_VERSION >= 0x050000 +# include "../qt5/QtXml/gsiQtExternals.h" +#else +# include "../qt4/QtXml/gsiQtExternals.h" +#endif diff --git a/src/gsiqt/qtbasic/gsiQtXmlPatternsExternals.h b/src/gsiqt/qtbasic/gsiQtXmlPatternsExternals.h index 6d5c6b1da..99431a57c 100644 --- a/src/gsiqt/qtbasic/gsiQtXmlPatternsExternals.h +++ b/src/gsiqt/qtbasic/gsiQtXmlPatternsExternals.h @@ -20,8 +20,9 @@ */ -# if defined(HAVE_QT5) -# include "../qt5/QtXmlPatterns/gsiQtExternals.h" -# else +#if QT_VERSION >= 0x050000 +# include "../qt5/QtXmlPatterns/gsiQtExternals.h" +#else // Not present in Qt4 -# endif +# define FORCE_LINK_GSI_QTXMLPATTERNS +#endif diff --git a/src/lay/lay/gsiDeclLayApplication.cc b/src/lay/lay/gsiDeclLayApplication.cc index cce04ffdf..a00550fa6 100644 --- a/src/lay/lay/gsiDeclLayApplication.cc +++ b/src/lay/lay/gsiDeclLayApplication.cc @@ -25,6 +25,7 @@ #include "laySignalHandler.h" #include "gsiDecl.h" #include "gsiQtGuiExternals.h" +#include "gsiQtWidgetsExternals.h" // for Qt5 #include "gsiQtCoreExternals.h" #include "gsiQtXmlExternals.h" #include "tlArch.h" @@ -32,6 +33,7 @@ // this is here *once* FORCE_LINK_GSI_QTCORE FORCE_LINK_GSI_QTGUI +FORCE_LINK_GSI_QTWIDGETS // required because the GSI bindings use QDomDocument FORCE_LINK_GSI_QTXML diff --git a/src/lay/lay/gsiDeclLayHelpDialog.cc b/src/lay/lay/gsiDeclLayHelpDialog.cc index f3d2fd429..84b1d7234 100644 --- a/src/lay/lay/gsiDeclLayHelpDialog.cc +++ b/src/lay/lay/gsiDeclLayHelpDialog.cc @@ -27,6 +27,7 @@ #include "laybasicCommon.h" #include "gsiDecl.h" #include "gsiQtGuiExternals.h" +#include "gsiQtWidgetsExternals.h" namespace tl { diff --git a/src/lay/lay/gsiDeclLayMainWindow.cc b/src/lay/lay/gsiDeclLayMainWindow.cc index f0d0c5646..8cfd7f66c 100644 --- a/src/lay/lay/gsiDeclLayMainWindow.cc +++ b/src/lay/lay/gsiDeclLayMainWindow.cc @@ -23,6 +23,7 @@ #include "gsiDecl.h" #include "gsiSignals.h" #include "gsiQtGuiExternals.h" +#include "gsiQtWidgetsExternals.h" // for Qt5 #include "layMainWindow.h" namespace gsi diff --git a/src/lay/lay/layGSIHelpProvider.cc b/src/lay/lay/layGSIHelpProvider.cc index ede5ce477..a1f026a6b 100644 --- a/src/lay/lay/layGSIHelpProvider.cc +++ b/src/lay/lay/layGSIHelpProvider.cc @@ -46,7 +46,7 @@ namespace lay static std::string module_doc_path (const std::string &m) { - return "/code/index.xml?module=" + m; + return "/code/module_" + m + ".xml"; } static std::string class_doc_path (const std::string &c) @@ -448,15 +448,13 @@ GSIHelpProvider::get (const std::string &path) const QUrl url = QUrl::fromEncoded (path.c_str ()); QString url_path = url.path (); QRegExp class_doc_url (QString::fromUtf8 ("^/code/class_(.*)\\.xml$")); + QRegExp module_index_url (QString::fromUtf8 ("^/code/module_(.*)\\.xml$")); std::string text; if (url_path == QString::fromUtf8 ("/code/index.xml")) { - if (url.hasQueryItem (QString::fromUtf8 ("module"))) { - QString module = url.queryItemValue (QString::fromUtf8 ("module")); - text = produce_class_index (module.toUtf8 ().constData ()); - } else { - text = produce_class_index (0); - } + text = produce_class_index (0); + } else if (module_index_url.indexIn (url_path) == 0) { + text = produce_class_index (tl::to_string (module_index_url.cap (1)).c_str ()); } else if (class_doc_url.indexIn (url_path) == 0) { text = produce_class_doc (tl::to_string (class_doc_url.cap (1))); } else { diff --git a/src/lay/lay/laySaltDownloadManager.cc b/src/lay/lay/laySaltDownloadManager.cc index 4fe9c7b2b..529880cf2 100644 --- a/src/lay/lay/laySaltDownloadManager.cc +++ b/src/lay/lay/laySaltDownloadManager.cc @@ -86,7 +86,7 @@ ConfirmationDialog::mark_fetching (const std::string &name) list->scrollToItem (i->second); for (int c = 0; c < list->columnCount (); ++c) { i->second->setData (c, Qt::BackgroundColorRole, QColor (224, 244, 244)); - i->second->setData (c, Qt::TextColorRole, Qt::blue); + i->second->setData (c, Qt::TextColorRole, QColor (Qt::blue)); } i->second->setData (1, Qt::DisplayRole, tr ("FETCHING")); } @@ -102,7 +102,7 @@ ConfirmationDialog::mark_error (const std::string &name) list->scrollToItem (i->second); for (int c = 0; c < list->columnCount (); ++c) { i->second->setData (c, Qt::BackgroundColorRole, QColor (255, 224, 244)); - i->second->setData (c, Qt::TextColorRole, Qt::black); + i->second->setData (c, Qt::TextColorRole, QColor (Qt::black)); } i->second->setData (1, Qt::DisplayRole, tr ("ERROR")); } @@ -118,7 +118,7 @@ ConfirmationDialog::mark_success (const std::string &name) list->scrollToItem (i->second); for (int c = 0; c < list->columnCount (); ++c) { i->second->setData (c, Qt::BackgroundColorRole, QColor (160, 255, 160)); - i->second->setData (c, Qt::TextColorRole, Qt::black); + i->second->setData (c, Qt::TextColorRole, QColor (Qt::black)); } i->second->setData (1, Qt::DisplayRole, tr ("INSTALLED")); } diff --git a/src/laybasic/laybasic/gsiDeclLayDialogs.cc b/src/laybasic/laybasic/gsiDeclLayDialogs.cc index cee939cde..6aa3f587a 100644 --- a/src/laybasic/laybasic/gsiDeclLayDialogs.cc +++ b/src/laybasic/laybasic/gsiDeclLayDialogs.cc @@ -23,6 +23,7 @@ #include "gsiDecl.h" #include "gsiDeclBasic.h" #include "gsiQtGuiExternals.h" +#include "gsiQtWidgetsExternals.h" #include "layBrowserDialog.h" #include "layBrowserPanel.h" @@ -35,6 +36,7 @@ #include FORCE_LINK_GSI_QTGUI +FORCE_LINK_GSI_QTWIDGETS // for Qt5 namespace gsi { diff --git a/src/pya/pya/pya.cc b/src/pya/pya/pya.cc index cdd5e7382..a6c8dcc07 100644 --- a/src/pya/pya/pya.cc +++ b/src/pya/pya/pya.cc @@ -2253,8 +2253,6 @@ PythonModule::~PythonModule () m_getseters_heap.pop_back (); } - m_string_heap.clear (); - if (mp_mod_def) { delete[] mp_mod_def; mp_mod_def = 0; @@ -3129,6 +3127,13 @@ PythonInterpreter::~PythonInterpreter () sp_interpreter = 0; } +char * +PythonInterpreter::make_string (const std::string &s) +{ + m_string_heap.push_back (s); + return const_cast (m_string_heap.back ().c_str ()); +} + void PythonInterpreter::add_path (const std::string &p) { diff --git a/src/pya/pya/pya.h b/src/pya/pya/pya.h index 27eedd30a..882e685ad 100644 --- a/src/pya/pya/pya.h +++ b/src/pya/pya/pya.h @@ -329,6 +329,9 @@ private: size_t prepare_trace (PyObject *); tl::Variant eval_int (const char *string, const char *filename, int line, bool eval_expr, int context); void get_context (int context, PythonRef &globals, PythonRef &locals, const char *file); + char *make_string (const std::string &s); + + std::list m_string_heap; PythonRef m_stdout_channel, m_stderr_channel; PythonPtr m_stdout, m_stderr; diff --git a/src/pymod/db/dbMain.cc b/src/pymod/db/dbMain.cc index 2641f1c9f..28e9c7ae8 100644 --- a/src/pymod/db/dbMain.cc +++ b/src/pymod/db/dbMain.cc @@ -25,9 +25,7 @@ #include "gsi.h" #include "gsiExpression.h" -PyMODINIT_FUNC -DEF_INSIDE_PUBLIC -PyInit_db () +static PyObject *module_init () { gsi::initialize (); gsi::initialize_expressions (); @@ -38,3 +36,19 @@ PyInit_db () return module.module (); } + +#if PY_MAJOR_VERSION < 3 +PyMODINIT_FUNC +DEF_INSIDE_PUBLIC +initdb () +{ + module_init (); +} +#else +PyMODINIT_FUNC +DEF_INSIDE_PUBLIC +PyMODINIT_FUNC PyInit_themodulename () +{ + return module_init(); +} +#endif