diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-02-04 08:27:52 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-02-04 08:27:52 +0100 |
commit | b849292b36f306cd71cd9456bccf6a514c2bb71e (patch) | |
tree | 67aadaef7bafc7f51c93b244f5d1a68eb98e6808 | |
parent | c0a4d44b22ce813850d6aced10302efcef2e9acd (diff) | |
parent | f89cb615182fe818bcc17984b4babc40095ac339 (diff) |
Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: I22fe4e58477f979cab347f2d6303472f97a53860
26 files changed, 278 insertions, 46 deletions
diff --git a/build_scripts/config.py b/build_scripts/config.py index 8356be302..0b1547660 100644 --- a/build_scripts/config.py +++ b/build_scripts/config.py @@ -192,12 +192,12 @@ class Config(object): if self.internal_build_type == self.shiboken_module_option_name: setup_kwargs['name'] = self.shiboken_module_st_name - setup_kwargs['description'] = "Python / C++ bindings helper module", + setup_kwargs['description'] = "Python / C++ bindings helper module" setup_kwargs['entry_points'] = {} elif self.internal_build_type == self.shiboken_generator_option_name: setup_kwargs['name'] = self.shiboken_generator_st_name - setup_kwargs['description'] = "Python / C++ bindings generator", + setup_kwargs['description'] = "Python / C++ bindings generator" setup_kwargs['install_requires'] = [self.shiboken_module_st_name] setup_kwargs['entry_points'] = { 'console_scripts': [ diff --git a/build_scripts/platforms/windows_desktop.py b/build_scripts/platforms/windows_desktop.py index c98ef3959..f204ba3a4 100644 --- a/build_scripts/platforms/windows_desktop.py +++ b/build_scripts/platforms/windows_desktop.py @@ -245,10 +245,46 @@ def prepare_packages_win32(self, vars): "ssleay32.dll"], force=False, vars=vars) + if config.is_internal_shiboken_module_build(): + # The C++ std library dlls need to be packaged with the + # shiboken module, because libshiboken uses C++ code. + copy_msvc_redist_files(vars, "{build_dir}/msvc_redist".format(**vars)) + if config.is_internal_pyside_build() or config.is_internal_shiboken_generator_build(): copy_qt_artifacts(self, copy_pdbs, vars) +def copy_msvc_redist_files(vars, redist_target_path): + # MSVC redistributable file list. + msvc_redist = [ + "concrt140.dll", + "msvcp140.dll", + "ucrtbase.dll", + "vcamp140.dll", + "vccorlib140.dll", + "vcomp140.dll", + "vcruntime140.dll" + ] + + # Make a directory where the files should be extracted. + if not os.path.exists(redist_target_path): + os.makedirs(redist_target_path) + + # Extract Qt dependency dlls when building on Qt CI. + # There is no proper CI env variable, so using agent launch params. + in_coin = os.environ.get("QTEST_ENVIRONMENT", "") == "ci" + if in_coin is not None: + redist_url = "http://download.qt.io/development_releases/prebuilt/vcredist/" + zip_file = "pyside_qt_deps_64.7z" + if "{target_arch}".format(**vars) == "32": + zip_file = "pyside_qt_deps_32.7z" + download_and_extract_7z(redist_url + zip_file, redist_target_path) + + copydir(redist_target_path, + "{st_build_dir}/{st_package_name}", + filter=msvc_redist, recursive=False, vars=vars) + + def copy_qt_artifacts(self, copy_pdbs, vars): built_modules = self.get_built_pyside_config(vars)['built_modules'] @@ -283,17 +319,6 @@ def copy_qt_artifacts(self, copy_pdbs, vars): "qtdiag.exe" ] - # MSVC redistributable - msvc_redist = [ - "concrt140.dll", - "msvcp140.dll", - "ucrtbase.dll", - "vcamp140.dll", - "vccorlib140.dll", - "vcomp140.dll" , - "vcruntime140.dll" - ] - # Choose which EGL library variants to copy. qt_artifacts_egl = [ "libEGL{}.dll", @@ -313,17 +338,11 @@ def copy_qt_artifacts(self, copy_pdbs, vars): artifacts += qt_artifacts_egl if copy_msvc_redist: - artifacts += msvc_redist - - # Extract Qt dependency dll's when building on Qt CI - # There is no proper CI env variable, so using agent launch params - in_coin = os.environ.get('COIN_LAUNCH_PARAMETERS', None) - if in_coin is not None: - redist_url = "http://download.qt.io/development_releases/prebuilt/vcredist//" - zip_file = "pyside_qt_deps_64.7z" - if "{target_arch}".format(**vars) == "32": - zip_file = "pyside_qt_deps_32.7z" - download_and_extract_7z(redist_url + zip_file, "{qt_bin_dir}".format(**vars)) + # The target path has to be qt_bin_dir at the moment, + # because the extracted archive also contains the opengl32sw + # and the d3dcompiler dlls, which are copied not by this + # function, but by the copydir below. + copy_msvc_redist_files(vars, "{qt_bin_dir}".format(**vars)) if artifacts: copydir("{qt_bin_dir}", diff --git a/examples/webenginewidgets/tabbedbrowser/browsertabwidget.py b/examples/webenginewidgets/tabbedbrowser/browsertabwidget.py index d85b8ad3d..29411d368 100644 --- a/examples/webenginewidgets/tabbedbrowser/browsertabwidget.py +++ b/examples/webenginewidgets/tabbedbrowser/browsertabwidget.py @@ -43,11 +43,12 @@ import sys from bookmarkwidget import BookmarkWidget from webengineview import WebEngineView +from historywindow import HistoryWindow from PySide2 import QtCore from PySide2.QtCore import QPoint, Qt, QUrl from PySide2.QtWidgets import (QAction, QMenu, QTabBar, QTabWidget) from PySide2.QtWebEngineWidgets import (QWebEngineDownloadItem, - QWebEnginePage, QWebEngineProfile) + QWebEngineHistory, QWebEnginePage, QWebEngineProfile) class BrowserTabWidget(QTabWidget): """Enables having several tabs with QWebEngineView.""" @@ -61,6 +62,7 @@ class BrowserTabWidget(QTabWidget): self.setTabsClosable(True) self._window_factory_function = window_factory_function self._webengineviews = [] + self._history_windows = {} # map WebengineView to HistoryWindow self.currentChanged.connect(self._current_changed) self.tabCloseRequested.connect(self.handle_tab_close_request) self._actions_enabled = {} @@ -165,6 +167,24 @@ class BrowserTabWidget(QTabWidget): def select_all(self): self._trigger_action(QWebEnginePage.SelectAll) + def show_history(self): + index = self.currentIndex() + if index >= 0: + webengineview = self._webengineviews[index] + history_window = self._history_windows.get(webengineview) + if not history_window: + history = webengineview.page().history() + history_window = HistoryWindow(history, self) + history_window.open_url.connect(self.load) + history_window.setWindowFlags(history_window.windowFlags() + | Qt.Window) + history_window.setWindowTitle('History') + self._history_windows[webengineview] = history_window + else: + history_window.refresh() + history_window.show() + history_window.raise_() + def zoom_factor(self): return self._webengineviews[0].zoomFactor() if self._webengineviews else 1.0 @@ -200,7 +220,10 @@ class BrowserTabWidget(QTabWidget): def handle_tab_close_request(self, index): if (index >= 0 and self.count() > 1): - self._webengineviews.remove(self._webengineviews[index]) + webengineview = self._webengineviews[index] + if self._history_windows.get(webengineview): + del self._history_windows[webengineview] + self._webengineviews.remove(webengineview) self.removeTab(index) def close_current_tab(self): diff --git a/examples/webenginewidgets/tabbedbrowser/historywindow.py b/examples/webenginewidgets/tabbedbrowser/historywindow.py new file mode 100644 index 000000000..06c9b73be --- /dev/null +++ b/examples/webenginewidgets/tabbedbrowser/historywindow.py @@ -0,0 +1,107 @@ +############################################################################# +## +## Copyright (C) 2019 The Qt Company Ltd. +## Contact: http://www.qt.io/licensing/ +## +## This file is part of the Qt for Python examples of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:BSD$ +## You may use this file under the terms of the BSD license as follows: +## +## "Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions are +## met: +## * Redistributions of source code must retain the above copyright +## notice, this list of conditions and the following disclaimer. +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in +## the documentation and/or other materials provided with the +## distribution. +## * Neither the name of The Qt Company Ltd nor the names of its +## contributors may be used to endorse or promote products derived +## from this software without specific prior written permission. +## +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +## +## $QT_END_LICENSE$ +## +############################################################################# + +from PySide2.QtWebEngineWidgets import (QWebEnginePage, QWebEngineView, + QWebEngineHistory, QWebEngineHistoryItem) + +from PySide2.QtWidgets import QApplication, QDesktopWidget, QTreeView + +from PySide2.QtCore import (Signal, QAbstractTableModel, QModelIndex, Qt, + QRect, QUrl) + + +class HistoryModel(QAbstractTableModel): + + def __init__(self, history, parent = None): + super(HistoryModel, self).__init__(parent) + self._history = history + + def headerData(self, section, orientation, role=Qt.DisplayRole): + if orientation == Qt.Horizontal and role == Qt.DisplayRole: + return 'Title' if section == 0 else 'Url' + return None + + def rowCount(self, index=QModelIndex()): + return self._history.count() + + def columnCount(self, index=QModelIndex()): + return 2 + + def item_at(self, model_index): + return self._history.itemAt(model_index.row()) + + def data(self, index, role=Qt.DisplayRole): + item = self.item_at(index) + column = index.column() + if role == Qt.DisplayRole: + return item.title() if column == 0 else item.url().toString() + return None + + def refresh(self): + self.beginResetModel() + self.endResetModel() + + +class HistoryWindow(QTreeView): + + open_url = Signal(QUrl) + + def __init__(self, history, parent): + super(HistoryWindow, self).__init__(parent) + + self._model = HistoryModel(history, self) + self.setModel(self._model) + self.activated.connect(self._activated) + + screen = QApplication.desktop().screenGeometry(parent) + self.resize(screen.width() / 3, screen.height() / 3) + self._adjustSize() + + def refresh(self): + self._model.refresh() + self._adjustSize() + + def _adjustSize(self): + if (self._model.rowCount() > 0): + self.resizeColumnToContents(0) + + def _activated(self, index): + item = self._model.item_at(index) + self.open_url.emit(item.url()) diff --git a/examples/webenginewidgets/tabbedbrowser/main.py b/examples/webenginewidgets/tabbedbrowser/main.py index 31714a535..51220469a 100644 --- a/examples/webenginewidgets/tabbedbrowser/main.py +++ b/examples/webenginewidgets/tabbedbrowser/main.py @@ -171,6 +171,12 @@ class MainWindow(QMainWindow): triggered = self._close_current_tab) navigation_menu.addAction(close_tab_action) + navigation_menu.addSeparator() + + history_action = QAction("History...", self, + triggered = self._tab_widget.show_history) + navigation_menu.addAction(history_action) + edit_menu = self.menuBar().addMenu("&Edit") find_action = QAction("Find", self, diff --git a/examples/webenginewidgets/tabbedbrowser/tabbedbrowser.pyqtc b/examples/webenginewidgets/tabbedbrowser/tabbedbrowser.pyqtc index 1ad61c350..b5fbffa28 100644 --- a/examples/webenginewidgets/tabbedbrowser/tabbedbrowser.pyqtc +++ b/examples/webenginewidgets/tabbedbrowser/tabbedbrowser.pyqtc @@ -3,4 +3,5 @@ bookmarkwidget.py browsertabwidget.py downloadwidget.py findtoolbar.py +historywindow.py webengineview.py diff --git a/sources/pyside2/PySide2/Qt3DCore/typesystem_3dcore.xml b/sources/pyside2/PySide2/Qt3DCore/typesystem_3dcore.xml index 013a49165..83e96abe7 100644 --- a/sources/pyside2/PySide2/Qt3DCore/typesystem_3dcore.xml +++ b/sources/pyside2/PySide2/Qt3DCore/typesystem_3dcore.xml @@ -45,7 +45,6 @@ <namespace-type name="Qt3DCore"> <enum-type name="ChangeFlag" flags="ChangeFlags"/> <object-type name="QAbstractAspect"/> - <object-type name="QAbstractEngine"/> <object-type name="QAbstractSkeleton" since="5.10"/> <object-type name="QArmature" since="5.10"/> <object-type name="QAspectEngine"> @@ -110,10 +109,5 @@ <!-- Disambiguate from QtGui/qtransform.h --> <include file-name="Qt3DCore/qtransform.h" location="global"/> </object-type> - <namespace-type name="Quick"> - <object-type name="QQmlAspectEngine"> - <enum-type name="Status"/> - </object-type> - </namespace-type> </namespace-type> </typesystem> diff --git a/sources/pyside2/PySide2/Qt3DInput/typesystem_3dinput.xml b/sources/pyside2/PySide2/Qt3DInput/typesystem_3dinput.xml index ebac94f03..6107f0b26 100644 --- a/sources/pyside2/PySide2/Qt3DInput/typesystem_3dinput.xml +++ b/sources/pyside2/PySide2/Qt3DInput/typesystem_3dinput.xml @@ -45,9 +45,7 @@ <namespace-type name="Qt3DInput"> <object-type name="QAbstractActionInput"/> <object-type name="QAbstractAxisInput"/> - <object-type name="QAbstractPhysicalDevice"> - <enum-type name="DeviceStatus"/> - </object-type> + <object-type name="QAbstractPhysicalDevice"/> <object-type name="QAction"/> <object-type name="QActionInput"/> <object-type name="QAnalogAxisInput"/> diff --git a/sources/pyside2/PySide2/Qt3DRender/typesystem_3drender.xml b/sources/pyside2/PySide2/Qt3DRender/typesystem_3drender.xml index e4fda946e..851f46b14 100644 --- a/sources/pyside2/PySide2/Qt3DRender/typesystem_3drender.xml +++ b/sources/pyside2/PySide2/Qt3DRender/typesystem_3drender.xml @@ -43,7 +43,6 @@ <typesystem package="PySide2.Qt3DRender"> <load-typesystem name="Qt3DCore/typesystem_3dcore.xml" generate="no"/> <namespace-type name="Qt3DRender"> - <object-type name="AssimpImporter"/> <object-type name="PropertyReaderInterface"/> <object-type name="QAbstractFunctor"/> <object-type name="QAbstractLight"> @@ -133,8 +132,6 @@ <enum-type name="Api"/> <enum-type name="OpenGLProfile"/> </object-type> - <object-type name="GLTFImporter"/> - <object-type name="GLTFExporter"/> <object-type name="QLayer"/> <object-type name="QLayerFilter"> <enum-type name="FilterMode"/> diff --git a/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml index 2181ff073..e61e1b6e7 100644 --- a/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml +++ b/sources/pyside2/PySide2/QtGui/typesystem_gui_common.xml @@ -2574,9 +2574,12 @@ <modify-function signature="glEndTransformFeedback()" remove="all"/> <modify-function signature="glPauseTransformFeedback()" remove="all"/> <modify-function signature="glResumeTransformFeedback()" remove="all"/> - <modify-function signature="^glClearBuffer.*\(.*$"> + <modify-function signature="^glClearBuffer.*\(.*\*.*$"> <modify-argument index="3"><array/></modify-argument> </modify-function> + <modify-function signature="glDebugMessageControl(unsigned int,unsigned int,unsigned int,int,const unsigned int*,unsigned char)"> + <modify-argument index="5"><array/></modify-argument> + </modify-function> <modify-function signature="glDeleteProgramPipelines(int,const unsigned int*)"> <modify-argument index="2"><array/></modify-argument> </modify-function> @@ -2742,6 +2745,12 @@ <modify-function signature="glSamplerParameteriv(unsigned int,unsigned int,const int*)"> <modify-argument index="3"><array/></modify-argument> </modify-function> + <modify-function signature="^glSamplerParameterI?u?[fi]v\(.*$"> + <modify-argument index="3"><array/></modify-argument> + </modify-function> + <modify-function signature="^glTexParameterI?u?[fi]v\(.*$"> + <modify-argument index="3"><array/></modify-argument> + </modify-function> <modify-function signature="glUniform1uiv(int,int,const unsigned int*)"> <modify-argument index="3"><array/></modify-argument> </modify-function> @@ -2822,7 +2831,7 @@ <modify-function signature="^glGen[A-Z].*s\(.*$"> <modify-argument index="2"><array/></modify-argument> </modify-function> - <modify-function signature="^gl(Get)?TexParameter[fi]v\(.*$"> + <modify-function signature="^gl(Get)?TexParameterI?u?[fi]v\(.*$"> <modify-argument index="3"><array/></modify-argument> </modify-function> <modify-function signature="^glUniformMatrix\dfv\(.*$"> @@ -2845,6 +2854,9 @@ <insert-template name="glGetString_return_QString"/> </inject-code> </modify-function> + <modify-function signature="glShaderBinary(int,const unsigned int*,unsigned int,const void *,int)"> + <modify-argument index="2"><array/></modify-argument> + </modify-function> </object-type> <object-type name="QAbstractOpenGLFunctions" since="5.1"/> <!-- Classes are result of a macro expansion in src/gui/opengl/qopenglversionfunctions.h diff --git a/sources/pyside2/PySide2/QtQml/typesystem_qml.xml b/sources/pyside2/PySide2/QtQml/typesystem_qml.xml index 250d1ea81..ef370ad02 100644 --- a/sources/pyside2/PySide2/QtQml/typesystem_qml.xml +++ b/sources/pyside2/PySide2/QtQml/typesystem_qml.xml @@ -98,6 +98,7 @@ </add-function> </object-type> <value-type name="QJSValue"> + <enum-type name="ErrorType" since="5.12"/> <enum-type name="SpecialValue"/> </value-type> <object-type name="QJSValueIterator"/> diff --git a/sources/pyside2/PySide2/QtWebEngineWidgets/typesystem_webenginewidgets.xml b/sources/pyside2/PySide2/QtWebEngineWidgets/typesystem_webenginewidgets.xml index dfe4e0d7a..e51303c42 100644 --- a/sources/pyside2/PySide2/QtWebEngineWidgets/typesystem_webenginewidgets.xml +++ b/sources/pyside2/PySide2/QtWebEngineWidgets/typesystem_webenginewidgets.xml @@ -55,6 +55,7 @@ <object-type name="QWebEngineDownloadItem"> <enum-type name="DownloadInterruptReason"/> <enum-type name="DownloadState"/> + <enum-type name="DownloadType"/> <enum-type name="SavePageFormat"/> </object-type> diff --git a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml index 456a411d3..c2c36d60f 100644 --- a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml +++ b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml @@ -1558,6 +1558,16 @@ <insert-template name="fix_arg,arg,arg,arg,arg,arg,arg,bool*,arg"/> </inject-code> </modify-function> + + <modify-function signature="getDouble(QWidget*,const QString&,const QString&,double,double,double,int,bool*,QFlags<Qt::WindowType>,double)" allow-thread="yes"> + <modify-argument index="8"> + <remove-default-expression/> + <remove-argument/> + </modify-argument> + <inject-code class="target" position="beginning"> + <insert-template name="fix_arg,arg,arg,arg,arg,arg,arg,bool*,arg,arg"/> + </inject-code> + </modify-function> </object-type> <object-type name="QGraphicsScene"> diff --git a/sources/pyside2/PySide2/QtXmlPatterns/typesystem_xmlpatterns.xml b/sources/pyside2/PySide2/QtXmlPatterns/typesystem_xmlpatterns.xml index f3f689cf6..dedcfdd7c 100644 --- a/sources/pyside2/PySide2/QtXmlPatterns/typesystem_xmlpatterns.xml +++ b/sources/pyside2/PySide2/QtXmlPatterns/typesystem_xmlpatterns.xml @@ -86,7 +86,7 @@ <rejection class="QXmlNodeModelIndex" function-name="sequencedTypedValue"/> <rejection class="QXmlNodeModelIndex" function-name="iterate"/> <!-- ### This enum isn't part of Qt public API --> - <suppress-warning text="enum 'QXmlNodeModelIndex::Axis' does not have a type entry or is not an enum"/> + <suppress-warning text="Enum 'QXmlNodeModelIndex::Axis' (class: QXmlNodeModelIndex) does not have a type entry"/> <value-type name="QXmlNodeModelIndex"> <enum-type name="DocumentOrder"/> <enum-type name="NodeKind"/> diff --git a/sources/pyside2/PySide2/templates/core_common.xml b/sources/pyside2/PySide2/templates/core_common.xml index 4984cb21a..96a9be620 100644 --- a/sources/pyside2/PySide2/templates/core_common.xml +++ b/sources/pyside2/PySide2/templates/core_common.xml @@ -134,6 +134,14 @@ <insert-template name="tuple_retval_ok"/> </template> + <template name="fix_arg,arg,arg,arg,arg,arg,arg,bool*,arg,arg"> + bool ok_; + %BEGIN_ALLOW_THREADS + %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, %5, %6, %7, &ok_, %9, %10); + %END_ALLOW_THREADS + <insert-template name="tuple_retval_ok"/> + </template> + <template name="fix_arg,arg,arg,arg,arg,arg,bool*,arg"> bool ok_; %BEGIN_ALLOW_THREADS diff --git a/sources/pyside2/pyside_version.py b/sources/pyside2/pyside_version.py index 11ca86bd2..c33b275f5 100644 --- a/sources/pyside2/pyside_version.py +++ b/sources/pyside2/pyside_version.py @@ -39,7 +39,7 @@ major_version = "5" minor_version = "12" -patch_version = "1" +patch_version = "2" # For example: "a", "b", "rc" # (which means "alpha", "beta", "release candidate"). diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp index 7498d3a18..15700e91e 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp @@ -112,7 +112,8 @@ static QStringList parseTemplateType(const QString& name) { } AbstractMetaBuilderPrivate::AbstractMetaBuilderPrivate() : m_currentClass(0), - m_logDirectory(QLatin1String(".") + QDir::separator()) + m_logDirectory(QLatin1String(".") + QDir::separator()), + m_skipDeprecated(false) { } @@ -571,6 +572,7 @@ void AbstractMetaBuilderPrivate::traverseDom(const FileModelItem &dom) TypeEntry *entry = it.value(); if (!entry->isPrimitive()) { if ((entry->isValue() || entry->isObject()) + && !types->shouldDropTypeEntry(entry->qualifiedCppName()) && !entry->isString() && !entry->isChar() && !entry->isContainer() @@ -1937,7 +1939,17 @@ AbstractMetaFunction *AbstractMetaBuilderPrivate::traverseFunction(const Functio if (functionItem->isFriend()) return 0; + const bool deprecated = functionItem->isDeprecated(); + if (deprecated && m_skipDeprecated) { + m_rejectedFunctions.insert(originalQualifiedSignatureWithReturn + QLatin1String(" is deprecated."), + AbstractMetaBuilder::GenerationDisabled); + return nullptr; + } + AbstractMetaFunction *metaFunction = new AbstractMetaFunction; + if (deprecated) + *metaFunction += AbstractMetaAttributes::Deprecated; + // Additional check for assignment/move assignment down below metaFunction->setFunctionType(functionTypeFromCodeModel(functionItem->functionType())); metaFunction->setConstant(functionItem->isConstant()); @@ -3075,6 +3087,10 @@ static void writeRejectLogFile(const QString &name, s << "Incompatible API"; break; + case AbstractMetaBuilder::Deprecated: + s << "Deprecated"; + break; + default: s << "unknown reason"; break; @@ -3241,6 +3257,11 @@ void AbstractMetaBuilder::setGlobalHeader(const QString& globalHeader) d->m_globalHeader = QFileInfo(globalHeader); } +void AbstractMetaBuilder::setSkipDeprecated(bool value) +{ + d->m_skipDeprecated = value; +} + void AbstractMetaBuilderPrivate::setInclude(TypeEntry *te, const QString &fileName) const { QFileInfo info(fileName); diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.h b/sources/shiboken2/ApiExtractor/abstractmetabuilder.h index 01806f6b4..7e5c1fc79 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.h +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.h @@ -53,6 +53,7 @@ public: UnmatchedArgumentType, UnmatchedReturnType, ApiIncompatible, + Deprecated, NoReason }; @@ -87,6 +88,8 @@ public: */ void setGlobalHeader(const QString& globalHeader); + void setSkipDeprecated(bool value); + static AbstractMetaType *translateType(const TypeInfo &_typei, AbstractMetaClass *currentClass = nullptr, bool resolveType = true, diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h b/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h index 1633bd868..226d6defd 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h @@ -185,6 +185,7 @@ public: QString m_logDirectory; QFileInfo m_globalHeader; + bool m_skipDeprecated; }; #endif // ABSTRACTMETBUILDER_P_H diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.h b/sources/shiboken2/ApiExtractor/abstractmetalang.h index bb17ad8d7..1ab3049b2 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetalang.h +++ b/sources/shiboken2/ApiExtractor/abstractmetalang.h @@ -140,7 +140,8 @@ public: OverriddenCppMethod = 0x00800000, FinalCppMethod = 0x01000000, // Add by meta builder (implicit constructors, inherited methods, etc) - AddedMethod = 0x02000000 + AddedMethod = 0x02000000, + Deprecated = 0x04000000 }; Q_DECLARE_FLAGS(Attributes, Attribute) Q_FLAG(Attribute) diff --git a/sources/shiboken2/ApiExtractor/apiextractor.cpp b/sources/shiboken2/ApiExtractor/apiextractor.cpp index 775485c81..7d2ce250e 100644 --- a/sources/shiboken2/ApiExtractor/apiextractor.cpp +++ b/sources/shiboken2/ApiExtractor/apiextractor.cpp @@ -97,6 +97,13 @@ void ApiExtractor::setDebugLevel(ReportHandler::DebugLevel debugLevel) ReportHandler::setDebugLevel(debugLevel); } +void ApiExtractor::setSkipDeprecated(bool value) +{ + m_skipDeprecated = value; + if (m_builder) + m_builder->setSkipDeprecated(m_skipDeprecated); +} + void ApiExtractor::setSuppressWarnings ( bool value ) { TypeDatabase::instance()->setSuppressWarnings(value); @@ -216,6 +223,7 @@ bool ApiExtractor::run() m_builder = new AbstractMetaBuilder; m_builder->setLogDirectory(m_logDirectory); m_builder->setGlobalHeader(m_cppFileName); + m_builder->setSkipDeprecated(m_skipDeprecated); QByteArrayList arguments; arguments.reserve(m_includePaths.size() + 1); for (const HeaderPath &headerPath : qAsConst(m_includePaths)) diff --git a/sources/shiboken2/ApiExtractor/apiextractor.h b/sources/shiboken2/ApiExtractor/apiextractor.h index ab520c9de..3eb90e748 100644 --- a/sources/shiboken2/ApiExtractor/apiextractor.h +++ b/sources/shiboken2/ApiExtractor/apiextractor.h @@ -66,6 +66,7 @@ public: void setCppFileName(const QString& cppFileName); QString cppFileName() const { return m_cppFileName; } void setDebugLevel(ReportHandler::DebugLevel debugLevel); + void setSkipDeprecated(bool value); void setSuppressWarnings(bool value); void setSilent(bool value); void addTypesystemSearchPath(const QString& path); @@ -99,6 +100,7 @@ private: AbstractMetaBuilder* m_builder; QString m_logDirectory; LanguageLevel m_languageLevel = LanguageLevel::Default; + bool m_skipDeprecated = false; // disable copy ApiExtractor(const ApiExtractor&); diff --git a/sources/shiboken2/doc/commandlineoptions.rst b/sources/shiboken2/doc/commandlineoptions.rst index c335fab75..19f614653 100644 --- a/sources/shiboken2/doc/commandlineoptions.rst +++ b/sources/shiboken2/doc/commandlineoptions.rst @@ -69,6 +69,11 @@ Options ``--generation-set`` Generator set to be used (e.g. qtdoc). +.. _skip-deprecated: + +``--skip-deprecated`` + Skip deprecated functions. + .. _diff: ``--diff`` diff --git a/sources/shiboken2/generator/main.cpp b/sources/shiboken2/generator/main.cpp index 362191fd0..c5bcb766d 100644 --- a/sources/shiboken2/generator/main.cpp +++ b/sources/shiboken2/generator/main.cpp @@ -57,6 +57,7 @@ static inline QString typesystemPathOption() { return QStringLiteral("typesystem static inline QString helpOption() { return QStringLiteral("help"); } static inline QString diffOption() { return QStringLiteral("diff"); } static inline QString dryrunOption() { return QStringLiteral("dry-run"); } +static inline QString skipDeprecatedOption() { return QStringLiteral("skip-deprecated"); } static const char helpHint[] = "Note: use --help or -h for more information.\n"; @@ -310,6 +311,8 @@ void printUsage() QLatin1String("System include paths used by the C++ parser")) << qMakePair(QLatin1String("generator-set=<\"generator module\">"), QLatin1String("generator-set to be used. e.g. qtdoc")) + << qMakePair(skipDeprecatedOption(), + QLatin1String("Skip deprecated functions")) << qMakePair(diffOption(), QLatin1String("Print a diff of wrapper files")) << qMakePair(dryrunOption(), @@ -475,6 +478,11 @@ int main(int argc, char *argv[]) // Create and set-up API Extractor ApiExtractor extractor; extractor.setLogDirectory(outputDirectory); + ait = args.find(skipDeprecatedOption()); + if (ait != args.end()) { + extractor.setSkipDeprecated(true); + args.erase(ait); + } ait = args.find(QLatin1String("silent")); if (ait != args.end()) { diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index 9cfc95fd1..d15f3a951 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -705,7 +705,7 @@ void CppGenerator::writeConstructorNative(QTextStream& s, const AbstractMetaFunc OriginalTypeDescription | SkipDefaultValues); s << " : "; writeFunctionCall(s, func); - s << " {" << endl; + s << endl << "{" << endl; const AbstractMetaArgument* lastArg = func->arguments().isEmpty() ? 0 : func->arguments().constLast(); writeCodeSnips(s, func->injectedCodeSnips(), TypeSystem::CodeSnipPositionBeginning, TypeSystem::NativeCode, func, lastArg); s << INDENT << "// ... middle" << endl; @@ -2656,6 +2656,12 @@ void CppGenerator::writeFunctionCalls(QTextStream &s, const OverloadData &overlo { Indentation indent(INDENT); writeSingleFunctionCall(s, overloadData, func, context); + if (func->attributes().testFlag(AbstractMetaAttributes::Deprecated)) { + s << INDENT << "PyErr_WarnEx(PyExc_DeprecationWarning, \""; + if (auto cls = context.metaClass()) + s << cls->name() << '.'; + s << func->signature() << " is deprecated\", 1);\n"; + } s << INDENT << "break;" << endl; } s << INDENT << '}' << endl; diff --git a/sources/shiboken2/shiboken_version.py b/sources/shiboken2/shiboken_version.py index 11ca86bd2..c33b275f5 100644 --- a/sources/shiboken2/shiboken_version.py +++ b/sources/shiboken2/shiboken_version.py @@ -39,7 +39,7 @@ major_version = "5" minor_version = "12" -patch_version = "1" +patch_version = "2" # For example: "a", "b", "rc" # (which means "alpha", "beta", "release candidate"). |