diff --git a/cmake/QtCreatorAPI.cmake b/cmake/QtCreatorAPI.cmake index 751f2d4f6f0..7dd104caf00 100644 --- a/cmake/QtCreatorAPI.cmake +++ b/cmake/QtCreatorAPI.cmake @@ -382,14 +382,12 @@ function(enable_pch target) endfunction() if (NOT TARGET QtCreatorPchGui AND NOT TARGET QtCreatorPchConsole) - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/empty_pch.c_cpp.in "/*empty file*/") - configure_file( - ${CMAKE_CURRENT_BINARY_DIR}/empty_pch.c_cpp.in - ${CMAKE_CURRENT_BINARY_DIR}/empty_pch.cpp) - configure_file( - ${CMAKE_CURRENT_BINARY_DIR}/empty_pch.c_cpp.in - ${CMAKE_CURRENT_BINARY_DIR}/empty_pch.c) - + file(GENERATE + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/empty_pch.c + CONTENT "/*empty file*/") + file(GENERATE + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/empty_pch.cpp + CONTENT "/*empty file*/") _add_pch_target(QtCreatorPchGui "${PROJECT_SOURCE_DIR}/src/shared/qtcreator_gui_pch.h" Qt5::Widgets) _add_pch_target(QtCreatorPchConsole @@ -728,9 +726,10 @@ function(add_qtc_plugin target_name) string(REGEX REPLACE "^.*=" "" json_value ${_arg_PLUGIN_JSON_IN}) string(REPLACE "$$${json_key}" "${json_value}" plugin_json_in ${plugin_json_in}) endif() - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${name}.json.cmakein" ${plugin_json_in}) - - configure_file("${CMAKE_CURRENT_BINARY_DIR}/${name}.json.cmakein" "${name}.json") + string(CONFIGURE "${plugin_json_in}" plugin_json) + file(GENERATE + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.json" + CONTENT "${plugin_json}") endif() add_library(${target_name} SHARED ${_arg_SOURCES}) diff --git a/doc/qtcreator/images/creator-diff-editor.png b/doc/qtcreator/images/creator-diff-editor.png index 70ae71f7e9c..3d2ce4bb431 100644 Binary files a/doc/qtcreator/images/creator-diff-editor.png and b/doc/qtcreator/images/creator-diff-editor.png differ diff --git a/doc/qtcreator/images/qtcreator-add-online-doc.png b/doc/qtcreator/images/qtcreator-add-online-doc.png index 4081f15fb8f..761b3c74f87 100644 Binary files a/doc/qtcreator/images/qtcreator-add-online-doc.png and b/doc/qtcreator/images/qtcreator-add-online-doc.png differ diff --git a/doc/qtcreator/images/qtcreator-help-options.png b/doc/qtcreator/images/qtcreator-help-options.png index 63c34700b51..c08bc176409 100644 Binary files a/doc/qtcreator/images/qtcreator-help-options.png and b/doc/qtcreator/images/qtcreator-help-options.png differ diff --git a/doc/qtcreator/images/qtcreator-link-with-qt.png b/doc/qtcreator/images/qtcreator-link-with-qt.png new file mode 100644 index 00000000000..5173be111d6 Binary files /dev/null and b/doc/qtcreator/images/qtcreator-link-with-qt.png differ diff --git a/doc/qtcreator/images/qtcreator-locator-customize.png b/doc/qtcreator/images/qtcreator-locator-customize.png index 6b7aacf7d30..8b28fa80fe5 100644 Binary files a/doc/qtcreator/images/qtcreator-locator-customize.png and b/doc/qtcreator/images/qtcreator-locator-customize.png differ diff --git a/doc/qtcreator/images/qtcreator-locator-example.png b/doc/qtcreator/images/qtcreator-locator-example.png new file mode 100644 index 00000000000..8c23d94f721 Binary files /dev/null and b/doc/qtcreator/images/qtcreator-locator-example.png differ diff --git a/doc/qtcreator/images/qtcreator-locator-generic-directory-filter.png b/doc/qtcreator/images/qtcreator-locator-generic-directory-filter.png new file mode 100644 index 00000000000..ad9ee419265 Binary files /dev/null and b/doc/qtcreator/images/qtcreator-locator-generic-directory-filter.png differ diff --git a/doc/qtcreator/images/qtcreator-locator-open.png b/doc/qtcreator/images/qtcreator-locator-open.png index 62dea9497eb..186cc6504b9 100644 Binary files a/doc/qtcreator/images/qtcreator-locator-open.png and b/doc/qtcreator/images/qtcreator-locator-open.png differ diff --git a/doc/qtcreator/images/qtcreator-locator-url-template.png b/doc/qtcreator/images/qtcreator-locator-url-template.png new file mode 100644 index 00000000000..e0932c7be64 Binary files /dev/null and b/doc/qtcreator/images/qtcreator-locator-url-template.png differ diff --git a/doc/qtcreator/images/qtcreator-locator.png b/doc/qtcreator/images/qtcreator-locator.png index 0b4097394ab..16b656317d2 100644 Binary files a/doc/qtcreator/images/qtcreator-locator.png and b/doc/qtcreator/images/qtcreator-locator.png differ diff --git a/doc/qtcreator/images/qtcreator-navigate-customfilter.png b/doc/qtcreator/images/qtcreator-navigate-customfilter.png deleted file mode 100644 index 2ce1d850d8b..00000000000 Binary files a/doc/qtcreator/images/qtcreator-navigate-customfilter.png and /dev/null differ diff --git a/doc/qtcreator/images/qtcreator-navigate-popup.png b/doc/qtcreator/images/qtcreator-navigate-popup.png deleted file mode 100644 index 6c6a4800deb..00000000000 Binary files a/doc/qtcreator/images/qtcreator-navigate-popup.png and /dev/null differ diff --git a/doc/qtcreator/images/qtcreator-qt-versions.png b/doc/qtcreator/images/qtcreator-qt-versions.png new file mode 100644 index 00000000000..8d456039e30 Binary files /dev/null and b/doc/qtcreator/images/qtcreator-qt-versions.png differ diff --git a/doc/qtcreator/images/qtcreator-qt4-qtversions-add.png b/doc/qtcreator/images/qtcreator-qt4-qtversions-add.png deleted file mode 100644 index 6b292a697d1..00000000000 Binary files a/doc/qtcreator/images/qtcreator-qt4-qtversions-add.png and /dev/null differ diff --git a/doc/qtcreator/src/editors/creator-code-syntax.qdoc b/doc/qtcreator/src/editors/creator-code-syntax.qdoc index 3f542df9d1f..4d05f3f288e 100644 --- a/doc/qtcreator/src/editors/creator-code-syntax.qdoc +++ b/doc/qtcreator/src/editors/creator-code-syntax.qdoc @@ -669,10 +669,18 @@ \l{http://linterrors.com/js/the-array-literal-notation-is-preferrable} {The array literal notation [] is preferable}. + \row + \li M324 + \li Error + \li Hit maximum recursion limit visiting AST, the code model will be unreliable + and most likely invalid + \li + \row \li M400 \li Warning \li Duplicate import + \li \endtable diff --git a/doc/qtcreator/src/editors/creator-coding-edit-mode.qdoc b/doc/qtcreator/src/editors/creator-coding-edit-mode.qdoc index 7c458a7d4c5..bd5d5e2b565 100644 --- a/doc/qtcreator/src/editors/creator-coding-edit-mode.qdoc +++ b/doc/qtcreator/src/editors/creator-coding-edit-mode.qdoc @@ -54,12 +54,18 @@ \section2 Navigating Between Open Files and Symbols - Use the toolbar to navigate between open files and symbols in use. To browse - backward or forward through your location history, click - \inlineimage prev.png + Use the toolbar, \uicontrol Window menu items, or + \l{General Keyboard Shortcuts}{keyboard shortcuts} + to navigate between open files and symbols in use. + + To browse backward or forward through your + location history, click \inlineimage prev.png (\uicontrol {Go Back}) and \inlineimage next.png (\uicontrol {Go Forward}). + To return to the last location where you made a change, select + \uicontrol Window > \uicontrol {Go to Last Edit}. + To go to any open file, select it from the \uicontrol {Open files} drop-down menu (1). To open a context menu that contains commands for managing open files, right-click the file name or icon on the toolbar. In addition to the @@ -80,8 +86,7 @@ number in the locator, separated by a colon (:). \note Other convenient ways of navigating in \QC are provided - by the \l{Keyboard Shortcuts} {keyboard shortcuts} and the - \l{Browsing Project Contents}{sidebar}. + by the \l{Browsing Project Contents}{sidebars}. \if defined(qtcreator) \section2 Selecting Parse Context @@ -187,10 +192,10 @@ the bookmark. To go to the previous bookmark in the current session, select - \uicontrol Tools \uicontrol Bookmarks > \uicontrol {Previous Bookmark} + \uicontrol Tools > \uicontrol Bookmarks > \uicontrol {Previous Bookmark} or press \key {Ctrl+,}. - To go to the next bookmark in the current session, select \uicontrol Tools + To go to the next bookmark in the current session, select \uicontrol Tools > \uicontrol Bookmarks > \uicontrol {Previous Bookmark} or press \key {Ctrl+.}. @@ -265,10 +270,10 @@ \section1 Inspecting the Code Model - When you report a bug that is related to the C++ code model, the \QC - developers might ask you to write information about the internal state of - the code model into a log file and to deliver the file to them for - inspection. + When you \l{https://bugreports.qt.io/}{report a bug} that is related to the + C++ code model, the \QC developers might ask you to write information about + the internal state of the code model into a log file and to deliver the file + to them for inspection. To view information about the C++ code model in the \uicontrol {C++ Code Model Inspector} dialog and write it to a log file, diff --git a/doc/qtcreator/src/editors/creator-diff-editor.qdoc b/doc/qtcreator/src/editors/creator-diff-editor.qdoc index a49d1028448..11608e0ce53 100644 --- a/doc/qtcreator/src/editors/creator-diff-editor.qdoc +++ b/doc/qtcreator/src/editors/creator-diff-editor.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2018 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Creator documentation. @@ -80,11 +80,11 @@ \image creator-diff-editor.png "Diff editor output in the Edit mode" - The changes are displayed in the \uicontrol Edit mode. Color coding is used - to mark changed lines. By default, light red indicates lines that contain - removed text (painted a darker red) in the left pane and light green - indicates lines that contain added text (painted a darker green) in the - right pane. + The changes are displayed in the \uicontrol Edit mode. Color coding is + used to mark changed lines. By default, red indicates lines that contain + removed text (painted another shade of red) in the left pane and green + indicates lines that contain added text (painted another shade of green) + in the right pane. To revert the changes, right-click added text and then select \uicontrol {Revert Chunk} in the context menu. To apply the changes, select diff --git a/doc/qtcreator/src/editors/creator-locator.qdoc b/doc/qtcreator/src/editors/creator-locator.qdoc index cd99ab139b2..951e61f4905 100644 --- a/doc/qtcreator/src/editors/creator-locator.qdoc +++ b/doc/qtcreator/src/editors/creator-locator.qdoc @@ -33,7 +33,7 @@ You can find the locator in the bottom left of the \QC window. - \image qtcreator-locator.png + \image qtcreator-locator.png "List of locator filters" To activate the locator: @@ -59,7 +59,7 @@ \li Start typing the filename. - \image qtcreator-locator-open.png + \image qtcreator-locator-open.png "List of files found in the locator" \li Move to the filename in the list and press \key Enter. @@ -148,6 +148,9 @@ \li Triggering menu items from the main menu (\c {t}) + \li Searching for issues from the \l{https://bugreports.qt.io/} + {Qt Project Bug Tracker} (\c bug). + \if defined(qtcreator) \li Running external tools (\c x) \li Using CMake to build the project for the current run configuration @@ -184,7 +187,7 @@ The locator lists the results. - \image qtcreator-navigate-popup.png + \image qtcreator-locator-example.png "List of files matching the locator filter" \endlist @@ -265,7 +268,7 @@ \li Select \uicontrol Add to add a new entry to the list. - \image qtcreator-add-online-doc.png "Filter Configuration dialog" + \image qtcreator-add-online-doc.png "List of URLs in Filter Configuration dialog" \li Double-click the new entry to specify a URL and a search command. For example, \c {http://www.google.com/search?q=%1}. @@ -276,49 +279,48 @@ \section1 Creating Locator Filters + You can create custom locator filters for finding in a directory structure + or on the web. + To quickly access files not directly mentioned in your project, you can - create your own locator filters. That way you can locate files in a + create your own directory filters. That way you can locate files in a directory structure you have defined. - To create a locator filter: + To create custom locator filters: \list 1 \li In the locator, select \uicontrol Options > \uicontrol Configure to open the \uicontrol Locator options. - \image qtcreator-locator-customize.png + \image qtcreator-locator-customize.png "Locator options tab" - \li Click \uicontrol Add. + \li Select \uicontrol Add > \uicontrol {Files in Directories} to add + a directory filter or \uicontrol {URL Template} to add a URL + filter. The settings to specify depend on the filter type. - \li In the \uicontrol {Filter Configuration} dialog: + \image qtcreator-locator-generic-directory-filter.png "Filter Configuration dialog" - \image qtcreator-navigate-customfilter.png + \li In the \uicontrol Name field, enter a name for your filter. - \list + \li In the \uicontrol Directories field, select at least one + directory. The locator searches directories recursively. - \li In the \uicontrol Name field, enter a name for your filter. + \li In the \uicontrol {File pattern} field, specify file patterns to + restrict the search to files that match the pattern. + Use a comma separated list. For example, to search for all + \c {.qml} and \c {.ui.qml} files, enter \c{*.qml,*.ui.qml} - \li In the \uicontrol Directories field, select at least one - directory. The locator searches directories recursively. + \li In the \uicontrol {Exclusion pattern} field, specify file + patterns to omit files from the search. - \li In the \uicontrol {File pattern} field, specify file patterns to - restrict the search to files that match the pattern. - Use a comma separated list. For example, to search for all - \c {.qml} and \c {.ui.qml} files, enter \c{*.qml,*.ui.qml} + \li In the \uicontrol Prefix field, specify the prefix string. - \li In the \uicontrol {Exclusion pattern} field, specify file - patterns to omit files from the search. + To implicitly include the filter even when not typing a prefix + as a part of the search string, select + \uicontrol {Include by default}. - \li In the \uicontrol Prefix field, specify the prefix string. - - To implicitly include the filter even when not typing a prefix - as a part of the search string, select - \uicontrol {Include by default}. - - \endlist - - \li Click \uicontrol OK. + \li Select \uicontrol OK. \endlist diff --git a/doc/qtcreator/src/editors/creator-only/creator-language-server.qdoc b/doc/qtcreator/src/editors/creator-only/creator-language-server.qdoc index b354f762b43..b6c09ff1f4a 100644 --- a/doc/qtcreator/src/editors/creator-only/creator-language-server.qdoc +++ b/doc/qtcreator/src/editors/creator-only/creator-language-server.qdoc @@ -38,15 +38,22 @@ \list \li \l{Completing Code}{Code completion} + \li Sending document formatting requests to the language server to + automatically format documents using the settings specified in + \uicontrol Tools > \uicontrol Options > \uicontrol {Text Editor} + > \uicontrol Behavior \li Highlighting the symbol under cursor + \li \l{Viewing Function Tooltips}{Viewing function tooltips} \li \l{Semantic Highlighting}{Semantic highlighting}, as defined in \l{https://github.com/microsoft/vscode-languageserver-node/pull/367} {Proposal of the semantic highlighting protocol extension} \li Navigating in the code by using the \l{Searching with the Locator} {locator} or \l{Moving to Symbol Definition or Declaration} {moving to the symbol definition} - \li Inspecting code by viewing the document - \l{Viewing Defined Types and Symbols}{outline} + \li Inspecting code by viewing the document outline in the + \l{Viewing Defined Types and Symbols}{Outline} view or + in the \uicontrol Symbols list on the \l{Using the Editor Toolbar} + {editor toolbar} \li \l{Finding Symbols}{Finding references to symbols} \li Code actions \li Integrating diagnostics from the language server @@ -123,7 +130,8 @@ The language service client has been mostly tested with Python. If problems arise when you try it or some other language, please select - \uicontrol Help > \uicontrol {Report Bug} to report them in the Qt Bug - Tracker. The reports should include \QC console output with the environment + \uicontrol Help > \uicontrol {Report Bug} to report them in the + \l{https://bugreports.qt.io/}{Qt Project Bug Tracker}. The reports + should include \QC console output with the environment variable \c {QT_LOGGING_RULES=qtc.languageclient.*=true} set. */ diff --git a/doc/qtcreator/src/howto/creator-help.qdoc b/doc/qtcreator/src/howto/creator-help.qdoc index bdfca10777f..abf949be08b 100644 --- a/doc/qtcreator/src/howto/creator-help.qdoc +++ b/doc/qtcreator/src/howto/creator-help.qdoc @@ -92,6 +92,12 @@ \QC, \QSDK and other Qt deliverables contain documentation as .qch files. All the documentation is accessible in the \uicontrol Help mode. + By default, \QC registers only the latest available version of the + documentation for each installed Qt module. To register all installed + documentation, select \uicontrol Tools > \uicontrol Options > + \uicontrol Kits > \uicontrol {Qt Versions} > + \uicontrol {Register documentation}. + To find information in the documentation, select: \list @@ -210,6 +216,9 @@ in the \uicontrol {On context help} field. To detach the help window, select \uicontrol {Always Show in External Window}. + To change this setting in a help view, select the \inlineimage linkicon.png + toolbar button. + \section1 Selecting the Start Page You can select the page to display when you open the \uicontrol Help mode in the diff --git a/doc/qtcreator/src/howto/creator-only/qtcreator-faq.qdoc b/doc/qtcreator/src/howto/creator-only/qtcreator-faq.qdoc index 5690fe6201e..6928e6ed939 100644 --- a/doc/qtcreator/src/howto/creator-only/qtcreator-faq.qdoc +++ b/doc/qtcreator/src/howto/creator-only/qtcreator-faq.qdoc @@ -73,7 +73,7 @@ \b {Has a reported issue been addressed?} You can look up any issue in the - \l{https://bugreports.qt.io/}{Qt bug tracker}. + \l{https://bugreports.qt.io/}{Qt Project Bug Tracker}. \include widgets/creator-faq-qtdesigner.qdocinc qt designer faq diff --git a/doc/qtcreator/src/overview/creator-only/creator-configuring.qdoc b/doc/qtcreator/src/overview/creator-only/creator-configuring.qdoc index 51b50d93ef2..312d51bd393 100644 --- a/doc/qtcreator/src/overview/creator-only/creator-configuring.qdoc +++ b/doc/qtcreator/src/overview/creator-only/creator-configuring.qdoc @@ -74,9 +74,12 @@ Each kit consists of a set of values that define one environment, such as a \l{glossary-device}{device}, compiler, and Qt version. If you know you have - installed a Qt - version, but it is not listed in \uicontrol Tools > \uicontrol Options > - \uicontrol Kits > \uicontrol {Qt Versions}, you must add it. + installed a Qt version, but it is not listed in \uicontrol Tools > + \uicontrol Options > \uicontrol Kits > \uicontrol {Qt Versions}, select + \uicontrol {Link with Qt}. + + If the Qt version is still not listed under \uicontrol Auto-detected, select + \uicontrol {Add} to add it manually. For more information, see \l{Adding Qt Versions}. diff --git a/doc/qtcreator/src/overview/creator-only/creator-issues.qdoc b/doc/qtcreator/src/overview/creator-only/creator-issues.qdoc index fd1171ba36f..453718b219d 100644 --- a/doc/qtcreator/src/overview/creator-only/creator-issues.qdoc +++ b/doc/qtcreator/src/overview/creator-only/creator-issues.qdoc @@ -43,7 +43,7 @@ For a list of fixed issues and added features, see the changelog file in the \c{qtcreator\dist} folder or the \l{https://bugreports.qt.io} - {Qt Bug Tracker}. + {Qt Project Bug Tracker}. \section1 General Issues diff --git a/doc/qtcreator/src/projects/creator-only/creator-projects-qt-versions.qdoc b/doc/qtcreator/src/projects/creator-only/creator-projects-qt-versions.qdoc index 58539f5534a..db9f985bd9c 100644 --- a/doc/qtcreator/src/projects/creator-only/creator-projects-qt-versions.qdoc +++ b/doc/qtcreator/src/projects/creator-only/creator-projects-qt-versions.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2018 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Creator documentation. @@ -42,12 +42,41 @@ \l{glossary-device}{device} manufacturers provide special Qt versions for developing applications for their devices. + \section1 Registering Installed Qt Versions + \QC automatically detects the Qt versions that are registered by your system or by installers. To view detailed information for each Qt version, select it in the list and select \uicontrol Details in the - \uicontrol {Qt version for} section. To add Qt versions, select - \uicontrol Tools > \uicontrol Options > \uicontrol Kits > - \uicontrol {Qt Versions}. + \uicontrol {Qt version for} section. + + \image qtcreator-qt-versions.png "Qt Versions tab in Kit options" + + To remove invalid Qt versions, select \uicontrol {Clean Up}. + + You can link to a Qt that you installed using the Qt Maintenance Tool to + automatically register the installed Qt versions. The mechanism does not + handle Qt versions installed by the system using some other package manager, + such as your Linux distribution, brew on \macos, or Chocolatey on Windows, + nor a self-built Qt. + + To link to a Qt installation: + + \list 1 + \li Select \uicontrol Tools > \uicontrol Options > \uicontrol Kits > + \uicontrol {Qt Versions} > \uicontrol {Link with Qt}. + \image qtcreator-link-with-qt.png "Choose Qt Installation dialog" + \li In the \uicontrol {Qt installation path} field, enter the path to + the directory where you installed Qt. + \li Select \uicontrol {Link with Qt} to automatically register Qt + versions and kits in the Qt installation directory. + \li Select \uicontrol {Restart Now} to restart \QC. + \endlist + + To remove the automatically detected Qt versions from the list, select + \uicontrol {Link with Qt} > \uicontrol {Remove Link}. + + If a Qt version is still not listed under \uicontrol Auto-detected, select + \uicontrol {Add} to add it manually. You specify the Qt version to use for each \l{glossary-buildandrun-kit} {kit} for building and running your projects @@ -67,8 +96,6 @@ \li Select the Qt version to view and edit it. - \image qtcreator-qt4-qtversions-add.png - \li In the \uicontrol{Version name} field, edit the name that \QC suggests for the Qt version. @@ -80,7 +107,10 @@ \endlist - \section1 Documentation + To remove a Qt version that you added manually, select it in the + \uicontrol Manual list and then select \uicontrol Remove. + + \section1 Registering Documentation By default, \QC registers only the latest available version of the documentation for each installed Qt module. @@ -109,13 +139,15 @@ If your build of Qt is incomplete but you still want to use QMake as build system, you need to ensure the following minimum requirements to be able to use that setup with \QC. \list 1 - \li qmake is an executable that understands the -query command line argument. - \li The bin and include directories have to exist. \QC fetches these directories by running \c{qmake -query}. - \li The mkspecs directory should be complete enough to parse .pro files. + \li qmake is an executable that understands the \c -query command line + argument. + \li The \c bin and \c include directories have to exist. \QC fetches + these directories by running \c{qmake -query}. + \li The \c mkspecs directory should be complete enough to parse .pro + files. \endlist - If your Qt version has no libQtCore.so, \QC is unable to detect the ABI. + If your Qt version has no \c libQtCore.so, \QC is unable to detect the ABI. */ - diff --git a/doc/qtcreator/src/qtcreator.qdoc b/doc/qtcreator/src/qtcreator.qdoc index 58db763d760..8a17cf193b5 100644 --- a/doc/qtcreator/src/qtcreator.qdoc +++ b/doc/qtcreator/src/qtcreator.qdoc @@ -130,8 +130,9 @@ \row \li {4,1} \l{All Topics} \row - \li {4,1} \note To report bugs and suggestions to the Qt Bug - Tracker, select \uicontrol {Help > Report Bug}. + \li {4,1} \note To report bugs and suggestions to the + \l{https://bugreports.qt.io/}{Qt Project Bug Tracker}, + select \uicontrol {Help > Report Bug}. To copy and paste detailed information about your system to the bug report, select \uicontrol Help > \uicontrol {System Information}. diff --git a/doc/qtcreator/src/vcs/creator-only/creator-vcs.qdoc b/doc/qtcreator/src/vcs/creator-only/creator-vcs.qdoc index 852eebdbf58..9c253adcda8 100644 --- a/doc/qtcreator/src/vcs/creator-only/creator-vcs.qdoc +++ b/doc/qtcreator/src/vcs/creator-only/creator-vcs.qdoc @@ -151,7 +151,8 @@ instead, select the \uicontrol {Switch to Text Diff Editor} (1) option from the toolbar. In the inline diff view, you can use context menu commands to apply, revert, stage, and - unstage hunks, as well as send them to a code pasting service. + unstage chunks or selected lines, as well as send chunks to a code pasting + service. \section2 Viewing Versioning History and Change Details diff --git a/doc/qtcreator/src/vcs/creator-vcs-git.qdoc b/doc/qtcreator/src/vcs/creator-vcs-git.qdoc index ca1512bb9eb..5d87adabedb 100644 --- a/doc/qtcreator/src/vcs/creator-vcs-git.qdoc +++ b/doc/qtcreator/src/vcs/creator-vcs-git.qdoc @@ -89,7 +89,8 @@ by default. To use the unified diff view instead, select the \uicontrol {Switch to Unified Diff Editor} (1) option from the toolbar. In both views, you can use context menu commands to apply, revert, stage, - and unstage hunks, as well as send them to a code pasting service. + and unstage chunks or selected lines, as well as send chunks to a code + pasting service. \section2 Viewing Git Log @@ -186,11 +187,18 @@ When you have finished filling out the commit page information, click on \uicontrol Commit to start committing. - The \uicontrol {Diff Selected Files} button brings up a diff view of the - files selected in the file list. Since the commit page is just another - editor, you can go back to it by closing the diff view. You can also switch - to an open diff view by selecting it in the \uicontrol {Open Documents} view - in the sidebar. + The \uicontrol {Diff Selected Files} button opens a \l{Viewing Git Diff} + {diff view} of the files selected in the file list. Select + \uicontrol {Stage Chunk} in the context menu to stage a chunk or + \uicontrol {Stage Selection} to stage the selected lines. + + To unstage chunks or selected lines, select \uicontrol {Unstage Chunk} or + \uicontrol {Unstage Selection} in the context menu. To revert the changes + in a chunk, select \uicontrol {Revert Chunk}. + + The commit page is just another editor, and therefore you return to it when + you close the diff view. You can also switch to an open diff view by + selecting it in the \uicontrol {Open Documents} view in the sidebar. \section2 Amending Commits diff --git a/doc/qtdesignstudio/src/qtdesignstudio.qdoc b/doc/qtdesignstudio/src/qtdesignstudio.qdoc index f69cd066c69..6195330faeb 100644 --- a/doc/qtdesignstudio/src/qtdesignstudio.qdoc +++ b/doc/qtdesignstudio/src/qtdesignstudio.qdoc @@ -107,8 +107,9 @@ \row \li {4,1} \l{All Topics} \row - \li {4,1} \note To report bugs and suggestions to the Qt Bug - Tracker, select \uicontrol {Help > Report Bug}. + \li {4,1} \note To report bugs and suggestions to the + \l{https://bugreports.qt.io/}{Qt Project Bug Tracker}, + select \uicontrol {Help > Report Bug}. To copy and paste detailed information about your system to the bug report, select \uicontrol Help > \uicontrol {System Information}. diff --git a/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-editor.qdoc b/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-editor.qdoc index 199c579bb7c..1e340182b51 100644 --- a/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-editor.qdoc +++ b/doc/qtdesignstudio/src/qtquick3d-editor/qtdesignstudio-3d-editor.qdoc @@ -161,7 +161,7 @@ or press \key R. You can use the scale handles to adjust the local x, y, or z scale of an - item. You can ajust the scale across one, two, or three axes, depending + item. You can adjust the scale across one, two, or three axes, depending on the handle. To adjust the scale across one axis, select the scale handle attached to diff --git a/share/qtcreator/debugger/boosttypes.py b/share/qtcreator/debugger/boosttypes.py index 215ccc6922e..214f3692313 100644 --- a/share/qtcreator/debugger/boosttypes.py +++ b/share/qtcreator/debugger/boosttypes.py @@ -25,6 +25,7 @@ from dumper import Children + def qdump__boost__bimaps__bimap(d, value): #leftType = value.type[0] #rightType = value.type[1] @@ -64,7 +65,7 @@ def qdump__boost__shared_ptr(d, value): (vptr, usecount, weakcount) = d.split('pii', pi) d.check(weakcount >= 0) d.check(weakcount <= usecount) - d.check(usecount <= 10*1000*1000) + d.check(usecount <= 10 * 1000 * 1000) d.putItem(d.createValue(px, value.type[0])) d.putBetterType(value.type) @@ -105,7 +106,7 @@ def qdump__boost__posix_time__time_duration(d, value): def qdump__boost__unordered__unordered_set(d, value): innerType = value.type[0] - if value.type.size() == 6 * d.ptrSize(): # 48 for boost 1.55+, 40 for 1.48 + if value.type.size() == 6 * d.ptrSize(): # 48 for boost 1.55+, 40 for 1.48 # boost 1.58 or 1.55 # bases are 3? bytes, and mlf is actually a float, but since # its followed by size_t maxload, it's # effectively padded to a size_t @@ -125,6 +126,7 @@ def qdump__boost__unordered__unordered_set(d, value): if forward: # boost 1.58 code = 'pp{%s}' % innerType.name + def children(p): while True: p, dummy, val = d.split(code, p) @@ -134,12 +136,13 @@ def qdump__boost__unordered__unordered_set(d, value): code = '{%s}@p' % innerType.name (pp, ssize, fields) = d.describeStruct(code) offset = fields[2].offset() + def children(p): while True: val, pad, p = d.split(code, p - offset) yield val p = d.extractPointer(buckets + bucketCount * d.ptrSize()) - d.putItems(size, children(p), maxNumChild = 10000) + d.putItems(size, children(p), maxNumChild=10000) def qdump__boost__variant(d, value): diff --git a/share/qtcreator/debugger/cdbbridge.py b/share/qtcreator/debugger/cdbbridge.py index ec55b183124..f73140dc0fb 100644 --- a/share/qtcreator/debugger/cdbbridge.py +++ b/share/qtcreator/debugger/cdbbridge.py @@ -35,8 +35,9 @@ sys.path.insert(1, os.path.dirname(os.path.abspath(inspect.getfile(inspect.curre from dumper import DumperBase, SubItem + class FakeVoidType(cdbext.Type): - def __init__(self, name , dumper): + def __init__(self, name, dumper): cdbext.Type.__init__(self) self.typeName = name.strip() self.dumper = dumper @@ -49,19 +50,19 @@ class FakeVoidType(cdbext.Type): def code(self): if self.typeName.endswith('*'): - return TypeCode.TypeCodePointer + return TypeCode.Pointer if self.typeName.endswith(']'): - return TypeCode.TypeCodeArray - return TypeCode.TypeCodeVoid + return TypeCode.Array + return TypeCode.Void def unqualified(self): return self def target(self): code = self.code() - if code == TypeCode.TypeCodePointer: + if code == TypeCode.Pointer: return FakeVoidType(self.typeName[:-1], self.dumper) - if code == TypeCode.TypeCodeVoid: + if code == TypeCode.Void: return self try: return FakeVoidType(self.typeName[:self.typeName.rindex('[')], self.dumper) @@ -89,6 +90,7 @@ class FakeVoidType(cdbext.Type): def templateArguments(self): return [] + class Dumper(DumperBase): def __init__(self): DumperBase.__init__(self) @@ -107,14 +109,14 @@ class Dumper(DumperBase): val.type = self.fromNativeType(nativeValue.type()) # There is no cdb api for the size of bitfields. # Workaround this issue by parsing the native debugger text for integral types. - if val.type.code == TypeCode.TypeCodeIntegral: + if val.type.code == TypeCode.Integral: integerString = nativeValue.nativeDebuggerValue() if integerString == 'true': val.ldata = int(1).to_bytes(1, byteorder='little') elif integerString == 'false': val.ldata = int(0).to_bytes(1, byteorder='little') else: - integerString = integerString.replace('`','') + integerString = integerString.replace('`', '') integerString = integerString.split(' ')[0] if integerString.startswith('0n'): integerString = integerString[2:] @@ -125,12 +127,12 @@ class Dumper(DumperBase): base = 10 signed = not val.type.name.startswith('unsigned') try: - val.ldata = int(integerString, base).to_bytes(val.type.size(), \ - byteorder='little', signed=signed) + val.ldata = int(integerString, base).to_bytes(val.type.size(), + byteorder='little', signed=signed) except: # read raw memory in case the integerString can not be interpreted pass - if val.type.code == TypeCode.TypeCodeEnum: + if val.type.code == TypeCode.Enum: val.ldisplay = self.enumValue(nativeValue) val.isBaseClass = val.name == val.type.name val.nativeValue = nativeValue @@ -148,7 +150,8 @@ class Dumper(DumperBase): c = 'u' else: return name - typeId = c + ''.join(['{%s:%s}' % (f.name(), self.nativeTypeId(f.type())) for f in nativeType.fields()]) + typeId = c + ''.join(['{%s:%s}' % (f.name(), self.nativeTypeId(f.type())) + for f in nativeType.fields()]) return typeId def fromNativeType(self, nativeType): @@ -161,21 +164,22 @@ class Dumper(DumperBase): nativeType = FakeVoidType(nativeType.name(), self) code = nativeType.code() - if code == TypeCode.TypeCodePointer: + if code == TypeCode.Pointer: if not nativeType.name().startswith(''): targetType = self.lookupType(nativeType.targetName(), nativeType.moduleId()) if targetType is not None: return self.createPointerType(targetType) - code = TypeCode.TypeCodeFunction + code = TypeCode.Function - if code == TypeCode.TypeCodeArray: + if code == TypeCode.Array: # cdb reports virtual function tables as arrays those ar handled separetly by - # the DumperBase. Declare those types as structs prevents a lookup to a none existing type + # the DumperBase. Declare those types as structs prevents a lookup to a + # none existing type if not nativeType.name().startswith('__fptr()') and not nativeType.name().startswith(' 0: namespace = name[:namespaceIndex + 2] self.qtNamespace = lambda: namespace - self.qtCustomEventFunc = self.parseAndEvaluate('%s!%sQObject::customEvent' - % (self.qtCoreModuleName(), namespace)).address() + self.qtCustomEventFunc = self.parseAndEvaluate( + '%s!%sQObject::customEvent' % + (self.qtCoreModuleName(), namespace)).address() return namespace def qtVersion(self): qtVersion = None try: - qtVersion = self.parseAndEvaluate('((void**)&%s)[2]' % self.qtHookDataSymbolName()).integer() + qtVersion = self.parseAndEvaluate( + '((void**)&%s)[2]' % self.qtHookDataSymbolName()).integer() except: if self.qtCoreModuleName() is not None: try: @@ -391,7 +397,7 @@ class Dumper(DumperBase): else: return typeName - def lookupType(self, typeNameIn, module = 0): + def lookupType(self, typeNameIn, module=0): if len(typeNameIn) == 0: return None typeName = self.stripQintTypedefs(typeNameIn) @@ -405,7 +411,7 @@ class Dumper(DumperBase): return type return self.Type(self, typeName) - def lookupNativeType(self, name, module = 0): + def lookupNativeType(self, name, module=0): if name.startswith('void'): return FakeVoidType(name, self) return cdbext.lookupType(name, module) @@ -447,7 +453,7 @@ class Dumper(DumperBase): variables = [] for val in cdbext.listOfLocals(self.partialVariable): dumperVal = self.fromNativeValue(val) - dumperVal.lIsInScope = not dumperVal.name in self.uninitialized + dumperVal.lIsInScope = dumperVal.name not in self.uninitialized variables.append(dumperVal) self.handleLocals(variables) @@ -472,7 +478,7 @@ class Dumper(DumperBase): return cdbext.parseAndEvaluate(exp) def nativeDynamicTypeName(self, address, baseType): - return None # Does not work with cdb + return None # Does not work with cdb def nativeValueDereferenceReference(self, value): return self.nativeValueDereferencePointer(value) diff --git a/share/qtcreator/debugger/creatortypes.py b/share/qtcreator/debugger/creatortypes.py index 346b53ae7da..0bb0be0699f 100644 --- a/share/qtcreator/debugger/creatortypes.py +++ b/share/qtcreator/debugger/creatortypes.py @@ -23,15 +23,18 @@ # ############################################################################ + def typeTarget(type): target = type.target() if target: return target return type + def stripTypeName(value): return typeTarget(value.type).unqualified().name + def extractPointerType(d, value): postfix = "" while stripTypeName(value) == "CPlusPlus::PointerType": @@ -47,6 +50,7 @@ def extractPointerType(d, value): return "void" + postfix return "" + def readTemplateName(d, value): name = readLiteral(d, value["_identifier"]) + "<" args = value["_templateArguments"] @@ -65,6 +69,7 @@ def readTemplateName(d, value): name += ">" return name + def readLiteral(d, value): if not value.integer(): return "" @@ -78,9 +83,11 @@ def readLiteral(d, value): except: return "" + def dumpLiteral(d, value): d.putValue(d.hexencode(readLiteral(d, value)), "latin1") + def qdump__Core__Id(d, value): val = value.extractPointer() if True: @@ -93,36 +100,44 @@ def qdump__Core__Id(d, value): d.putValue(val) d.putPlainChildren(value) + def qdump__Debugger__Internal__GdbMi(d, value): val = d.encodeString(value["m_name"]) + "3a002000" \ + d.encodeString(value["m_data"]) d.putValue(val, "utf16") d.putPlainChildren(value) + def qdump__Debugger__Internal__DisassemblerLine(d, value): d.putByteArrayValue(value["m_data"]) d.putPlainChildren(value) + def qdump__Debugger__Internal__WatchData(d, value): d.putStringValue(value["iname"]) d.putPlainChildren(value) + def qdump__Debugger__Internal__WatchItem(d, value): d.putStringValue(value["iname"]) d.putPlainChildren(value) + def qdump__Debugger__Internal__BreakpointModelId(d, value): d.putValue("%s.%s" % (value["m_majorPart"].integer(), value["m_minorPart"].integer())) d.putPlainChildren(value) + def qdump__Debugger__Internal__ThreadId(d, value): d.putValue("%s" % value["m_id"]) d.putPlainChildren(value) + def qdump__CPlusPlus__ByteArrayRef(d, value): d.putSimpleCharArray(value["m_start"], value["m_length"]) d.putPlainChildren(value) + def qdump__CPlusPlus__Identifier(d, value): try: d.putSimpleCharArray(value["_chars"], value["_size"]) @@ -130,14 +145,17 @@ def qdump__CPlusPlus__Identifier(d, value): pass d.putPlainChildren(value) + def qdump__CPlusPlus__Symbol(d, value): dumpLiteral(d, value["_name"]) d.putBetterType(value.type) d.putPlainChildren(value) + def qdump__CPlusPlus__Class(d, value): qdump__CPlusPlus__Symbol(d, value) + def kindName(d, value): e = value.integer() if e: @@ -146,10 +164,12 @@ def kindName(d, value): else: return '' + def qdump__CPlusPlus__IntegerType(d, value): d.putValue(kindName(d, value["_kind"])) d.putPlainChildren(value) + def qdump__CPlusPlus__FullySpecifiedType(d, value): type = value["_type"] typeName = stripTypeName(type) @@ -159,36 +179,44 @@ def qdump__CPlusPlus__FullySpecifiedType(d, value): d.putValue(d.hexencode(extractPointerType(d, type)), "latin1") d.putPlainChildren(value) + def qdump__CPlusPlus__NamedType(d, value): dumpLiteral(d, value["_name"]) d.putBetterType(value.type) d.putPlainChildren(value) + def qdump__CPlusPlus__PointerType(d, value): d.putValue(d.hexencode(extractPointerType(d, value)), "latin1") d.putPlainChildren(value) + def qdump__CPlusPlus__TemplateNameId(d, value): dumpLiteral(d, value) d.putBetterType(value.type) d.putPlainChildren(value) + def qdump__CPlusPlus__QualifiedNameId(d, value): dumpLiteral(d, value) d.putPlainChildren(value) + def qdump__CPlusPlus__Literal(d, value): dumpLiteral(d, value) d.putPlainChildren(value) + def qdump__CPlusPlus__StringLiteral(d, value): d.putSimpleCharArray(value["_chars"], value["_size"]) d.putPlainChildren(value) + def qdump__CPlusPlus__Internal__Value(d, value): d.putValue(value["l"]) d.putPlainChildren(value) + def qdump__Utils__FilePath(d, value): try: if not d.extractPointer(value["m_url"]): # there is no valid URL @@ -199,21 +227,26 @@ def qdump__Utils__FilePath(d, value): d.putStringValue(value) # support FileName before 4.10 as well d.putPlainChildren(value) + def qdump__Utils__FileName(d, value): qdump__Utils__FilePath(d, value) + def qdump__Utils__ElfSection(d, value): d.putByteArrayValue(value["name"]) d.putPlainChildren(value) + def qdump__Utils__Port(d, value): d.putValue(d.extractInt(value)) d.putPlainChildren(value) + def qdump__Utf8String(d, value): d.putByteArrayValue(value['byteArray']) d.putPlainChildren(value) + def qdump__CPlusPlus__Token(d, value): k = value["f"]["kind"] e = k.lvalue @@ -228,6 +261,7 @@ def qdump__CPlusPlus__Token(d, value): d.putValue(type) d.putPlainChildren(value) + def qdump__CPlusPlus__Internal__PPToken(d, value): data, size, alloc = d.byteArrayData(value["m_src"]) length = value["f"]["utf16chars"].integer() @@ -237,6 +271,7 @@ def qdump__CPlusPlus__Internal__PPToken(d, value): d.putValue(d.readMemory(data + offset, min(100, length)), "latin1") d.putPlainChildren(value) + def qdump__ProString(d, value): try: s = value["m_string"] @@ -249,10 +284,12 @@ def qdump__ProString(d, value): d.putEmptyValue() d.putPlainChildren(value) + def qdump__ProKey(d, value): qdump__ProString(d, value) d.putBetterType(value.type) + def qdump__Core__GeneratedFile(d, value): d.putStringValue(value["m_d"]["d"]["path"]) d.putPlainChildren(value) @@ -275,14 +312,18 @@ def qdump__Core__GeneratedFile(d, value): # d.putStringValue(value["d"]["m_unexpandedDisplayName"]) # d.putPlainChildren(value) + def qdump__ProjectExplorer__ProjectNode(d, value): qdump__ProjectExplorer__FolderNode(d, value) + def qdump__CMakeProjectManager__Internal__CMakeProjectNode(d, value): qdump__ProjectExplorer__FolderNode(d, value) + def qdump__QmakeProjectManager__QmakePriFileNode(d, value): qdump__ProjectExplorer__FolderNode(d, value) + def qdump__QmakeProjectManager__QmakeProFileNode(d, value): qdump__ProjectExplorer__FolderNode(d, value) diff --git a/share/qtcreator/debugger/dumper.py b/share/qtcreator/debugger/dumper.py index b292b145df3..90ce78887ce 100644 --- a/share/qtcreator/debugger/dumper.py +++ b/share/qtcreator/debugger/dumper.py @@ -25,7 +25,6 @@ import os import codecs -import copy import collections import struct import sys @@ -33,7 +32,6 @@ import base64 import re import time import inspect -import threading from utils import DisplayFormat, TypeCode try: @@ -53,13 +51,14 @@ else: toInteger = long -class ReportItem: +class ReportItem(): """ Helper structure to keep temporary 'best' information about a value or a type scheduled to be reported. This might get overridden be subsequent better guesses during a putItem() run. """ - def __init__(self, value = None, encoding = None, priority = -100, elided = None): + + def __init__(self, value=None, encoding=None, priority=-100, elided=None): self.value = value self.priority = priority self.encoding = encoding @@ -70,7 +69,7 @@ class ReportItem: % (self.value, self.encoding, self.priority, self.elided) -class Timer: +class Timer(): def __init__(self, d, desc): self.d = d self.desc = desc + '-' + d.currentIName @@ -83,9 +82,9 @@ class Timer: self.d.timings.append([self.desc, elapsed]) -class Children: - def __init__(self, d, numChild = 1, childType = None, childNumChild = None, - maxNumChild = None, addrBase = None, addrStep = None): +class Children(): + def __init__(self, d, numChild=1, childType=None, childNumChild=None, + maxNumChild=None, addrBase=None, addrStep=None): self.d = d self.numChild = numChild self.childNumChild = childNumChild @@ -132,7 +131,7 @@ class Children: return True -class SubItem: +class SubItem(): def __init__(self, d, component): self.d = d self.name = component @@ -144,19 +143,22 @@ class SubItem: def __exit__(self, exType, exValue, exTraceBack): return self.d.exitSubItem(self, exType, exValue, exTraceBack) + class TopLevelItem(SubItem): def __init__(self, d, iname): self.d = d self.iname = iname self.name = None + class UnnamedSubItem(SubItem): def __init__(self, d, component): self.d = d self.iname = '%s.%s' % (self.d.currentIName, component) self.name = None -class DumperBase: + +class DumperBase(): @staticmethod def warn(message): print('bridgemessage={msg="%s"},' % message.replace('"', '$').encode('latin1')) @@ -259,7 +261,7 @@ class DumperBase: def resetCaches(self): # This is a cache mapping from 'type name' to 'display alternatives'. - self.qqFormats = { 'QVariant (QVariantMap)' : [DisplayFormat.CompactMapFormat] } + self.qqFormats = {'QVariant (QVariantMap)': [DisplayFormat.CompactMap]} # This is a cache of all known dumpers. self.qqDumpers = {} # Direct type match @@ -326,13 +328,13 @@ class DumperBase: item.savedValue = self.currentValue item.savedType = self.currentType self.currentIName = item.iname - self.currentValue = ReportItem(); - self.currentType = ReportItem(); + self.currentValue = ReportItem() + self.currentType = ReportItem() def exitSubItem(self, item, exType, exValue, exTraceBack): #DumperBase.warn('CURRENT VALUE: %s: %s %s' % # (self.currentIName, self.currentValue, self.currentType)) - if not exType is None: + if exType is not None: if self.passExceptions: self.showException('SUBITEM', exType, exValue, exTraceBack) self.putSpecialValue('notaccessible') @@ -346,7 +348,7 @@ class DumperBase: if self.currentValue.value is None: self.put('value="",encoding="notaccessible",numchild="0",') else: - if not self.currentValue.encoding is None: + if self.currentValue.encoding is not None: self.put('valueencoded="%s",' % self.currentValue.encoding) if self.currentValue.elided: self.put('valueelided="%s",' % self.currentValue.elided) @@ -363,7 +365,7 @@ class DumperBase: typeName = self.currentType.value self.put('<%s> = {' % typeName) - if self.currentValue.value is None: + if self.currentValue.value is None: self.put('') else: value = self.currentValue.value @@ -405,7 +407,7 @@ class DumperBase: inArray -= 1 if inArray and ord(c) >= 48 and ord(c) <= 57: continue - stripped += c + stripped += c self.cachedFormats[typeName] = stripped return stripped @@ -437,7 +439,7 @@ class DumperBase: tdata.name = typeId tdata.typeId = typeId tdata.lbitsize = 16 - tdata.code = TypeCode.TypeCodeIntegral + tdata.code = TypeCode.Integral self.registerType(typeId, tdata) typeId = 'QChar' @@ -445,14 +447,15 @@ class DumperBase: tdata.name = typeId tdata.typeId = typeId tdata.lbitsize = 16 - tdata.code = TypeCode.TypeCodeStruct - tdata.lfields = [self.Field(dumper=self, name='ucs', type='unsigned short', bitsize=16, bitpos=0)] + tdata.code = TypeCode.Struct + tdata.lfields = [self.Field(dumper=self, name='ucs', + type='unsigned short', bitsize=16, bitpos=0)] tdata.lalignment = 2 tdata.templateArguments = [] self.registerType(typeId, tdata) def nativeDynamicType(self, address, baseType): - return baseType # Override in backends. + return baseType # Override in backends. def listTemplateParameters(self, typename): return self.listTemplateParametersManually(typename) @@ -467,7 +470,7 @@ class DumperBase: inner = inner.strip()[::-1] p = inner.find(')::') if p > -1: - inner = inner[p+3:].strip() + inner = inner[p + 3:].strip() if inner.startswith('const '): inner = inner[6:].strip() if inner.endswith(' const'): @@ -478,7 +481,7 @@ class DumperBase: #DumperBase.warn("SPLITTING %s" % typename) level = 0 inner = '' - for c in typename[::-1]: # Reversed... + for c in typename[::-1]: # Reversed... #DumperBase.warn("C: %s" % c) if c == '>': if level > 0: @@ -508,7 +511,7 @@ class DumperBase: if len(item) == 0: continue c = ord(item[0]) - if c in (45, 46) or (c >= 48 and c < 58): # '-', '.' or digit. + if c in (45, 46) or (c >= 48 and c < 58): # '-', '.' or digit. if item.find('.') > -1: res.append(float(item)) else: @@ -613,24 +616,24 @@ class DumperBase: return 0, '' data, size, alloc = self.byteArrayDataHelper(addr) if alloc != 0: - self.check(0 <= size and size <= alloc and alloc <= 100*1000*1000) + self.check(0 <= size and size <= alloc and alloc <= 100 * 1000 * 1000) elided, shown = self.computeLimit(size, limit) return elided, self.readMemory(data, 2 * shown) def encodeByteArrayHelper(self, addr, limit): data, size, alloc = self.byteArrayDataHelper(addr) if alloc != 0: - self.check(0 <= size and size <= alloc and alloc <= 100*1000*1000) + self.check(0 <= size and size <= alloc and alloc <= 100 * 1000 * 1000) elided, shown = self.computeLimit(size, limit) return elided, self.readMemory(data, shown) def putCharArrayValue(self, data, size, charSize, - displayFormat = DisplayFormat.AutomaticFormat): + displayFormat=DisplayFormat.Automatic): bytelen = size * charSize elided, shown = self.computeLimit(bytelen, self.displayStringLimit) mem = self.readMemory(data, shown) if charSize == 1: - if displayFormat in (DisplayFormat.Latin1StringFormat, DisplayFormat.SeparateLatin1StringFormat): + if displayFormat in (DisplayFormat.Latin1String, DisplayFormat.SeparateLatin1String): encodingType = 'latin1' else: encodingType = 'utf8' @@ -644,15 +647,18 @@ class DumperBase: self.putValue(mem, encodingType, elided=elided) - if displayFormat in (DisplayFormat.SeparateLatin1StringFormat, DisplayFormat.SeparateUtf8StringFormat, DisplayFormat.SeparateFormat): + if displayFormat in ( + DisplayFormat.SeparateLatin1String, + DisplayFormat.SeparateUtf8String, + DisplayFormat.Separate): elided, shown = self.computeLimit(bytelen, 100000) self.putDisplay(encodingType + ':separate', self.readMemory(data, shown)) def putCharArrayHelper(self, data, size, charType, - displayFormat = DisplayFormat.AutomaticFormat, - makeExpandable = True): + displayFormat=DisplayFormat.Automatic, + makeExpandable=True): charSize = charType.size() - self.putCharArrayValue(data, size, charSize, displayFormat = displayFormat) + self.putCharArrayValue(data, size, charSize, displayFormat=displayFormat) if makeExpandable: self.putNumChild(size) @@ -664,7 +670,7 @@ class DumperBase: def readMemory(self, addr, size): return self.hexencode(bytes(self.readRawMemory(addr, size))) - def encodeByteArray(self, value, limit = 0): + def encodeByteArray(self, value, limit=0): elided, data = self.encodeByteArrayHelper(self.extractPointer(value), limit) return data @@ -672,17 +678,18 @@ class DumperBase: return self.byteArrayDataHelper(self.extractPointer(value)) def putByteArrayValue(self, value): - elided, data = self.encodeByteArrayHelper(self.extractPointer(value), self.displayStringLimit) + elided, data = self.encodeByteArrayHelper( + self.extractPointer(value), self.displayStringLimit) self.putValue(data, 'latin1', elided=elided) - def encodeString(self, value, limit = 0): + def encodeString(self, value, limit=0): elided, data = self.encodeStringHelper(self.extractPointer(value), limit) return data def encodedUtf16ToUtf8(self, s): - return ''.join([chr(int(s[i:i+2], 16)) for i in range(0, len(s), 4)]) + return ''.join([chr(int(s[i:i + 2], 16)) for i in range(0, len(s), 4)]) - def encodeStringUtf8(self, value, limit = 0): + def encodeStringUtf8(self, value, limit=0): return self.encodedUtf16ToUtf8(self.encodeString(value, limit)) def stringData(self, value): @@ -692,7 +699,7 @@ class DumperBase: level = 0 skipSpace = False inner = '' - for c in typename[typename.find('<') + 1 : -1]: + for c in typename[typename.find('<') + 1: -1]: if c == '<': inner += c level += 1 @@ -718,7 +725,7 @@ class DumperBase: inner = inner.strip() p = inner.find(')::') if p > -1: - inner = inner[p+3:] + inner = inner[p + 3:] return inner def putStringValue(self, value): @@ -796,7 +803,7 @@ class DumperBase: if address is not None and not self.isCli: self.put('address="0x%x",' % address) - def putPlainChildren(self, value, dumpBase = True): + def putPlainChildren(self, value, dumpBase=True): self.putEmptyValue(-99) self.putNumChild(1) if self.isExpanded(): @@ -829,7 +836,7 @@ class DumperBase: p += self.ptrSize() return itemCount - def putFields(self, value, dumpBase = True): + def putFields(self, value, dumpBase=True): baseIndex = 0 for item in value.members(True): if item.name is not None: @@ -861,8 +868,7 @@ class DumperBase: with SubItem(self, item.name): self.putItem(item) - - def putMembersItem(self, value, sortorder = 10): + def putMembersItem(self, value, sortorder=10): with SubItem(self, '[members]'): self.putField('sortgroup', sortorder) self.putPlainChildren(value) @@ -912,7 +918,7 @@ class DumperBase: elided, shown, blob = self.readToFirstZero(p, tsize, limit) return elided, blob - def putItemCount(self, count, maximum = 1000000000): + def putItemCount(self, count, maximum=1000000000): # This needs to override the default value, so don't use 'put' directly. if count > maximum: self.putSpecialValue('minimumitemcount', maximum) @@ -921,20 +927,20 @@ class DumperBase: self.putNumChild(count) def resultToMi(self, value): - if type(value) is bool: + if isinstance(value, bool): return '"%d"' % int(value) - if type(value) is dict: + if isinstance(value, dict): return '{' + ','.join(['%s=%s' % (k, self.resultToMi(v)) - for (k, v) in list(value.items())]) + '}' - if type(value) is list: + for (k, v) in list(value.items())]) + '}' + if isinstance(value, list): return '[' + ','.join([self.resultToMi(k) - for k in list(value.items())]) + ']' + for k in list(value.items())]) + ']' return '"%s"' % value def variablesToMi(self, value, prefix): - if type(value) is bool: + if isinstance(value, bool): return '"%d"' % int(value) - if type(value) is dict: + if isinstance(value, dict): pairs = [] for (k, v) in list(value.items()): if k == 'iname': @@ -946,7 +952,7 @@ class DumperBase: v = self.variablesToMi(v, prefix) pairs.append('%s=%s' % (k, v)) return '{' + ','.join(pairs) + '}' - if type(value) is list: + if isinstance(value, list): index = 0 pairs = [] for item in value: @@ -957,7 +963,7 @@ class DumperBase: name = str(index) index += 1 pairs.append((name, self.variablesToMi(item, prefix))) - pairs.sort(key = lambda pair: pair[0]) + pairs.sort(key=lambda pair: pair[0]) return '[' + ','.join([pair[1] for pair in pairs]) + ']' return '"%s"' % value @@ -1016,7 +1022,7 @@ class DumperBase: def putField(self, name, value): self.put('%s="%s",' % (name, value)) - def putType(self, typish, priority = 0): + def putType(self, typish, priority=0): # Higher priority values override lower ones. if priority >= self.currentType.priority: types = (str) if sys.version_info[0] >= 3 else (str, unicode) @@ -1026,14 +1032,14 @@ class DumperBase: self.currentType.value = typish.name self.currentType.priority = priority - def putValue(self, value, encoding = None, priority = 0, elided = None): + def putValue(self, value, encoding=None, priority=0, elided=None): # Higher priority values override lower ones. # elided = 0 indicates all data is available in value, # otherwise it's the true length. if priority >= self.currentValue.priority: self.currentValue = ReportItem(value, encoding, priority, elided) - def putSpecialValue(self, encoding, value = '', children = None): + def putSpecialValue(self, encoding, value='', children=None): self.putValue(value, encoding) if children is not None: self.putNumChild(1) @@ -1043,7 +1049,7 @@ class DumperBase: with SubItem(self, name): self.putValue(str(value).replace('"', '$')) - def putEmptyValue(self, priority = -10): + def putEmptyValue(self, priority=-10): if priority >= self.currentValue.priority: self.currentValue = ReportItem('', None, priority, None) @@ -1081,7 +1087,7 @@ class DumperBase: def mangleName(self, typeName): return '_ZN%sE' % ''.join(map(lambda x: '%d%s' % (len(x), x), - typeName.split('::'))) + typeName.split('::'))) def putCStyleArray(self, value): arrayType = value.type.unqualified() @@ -1090,7 +1096,7 @@ class DumperBase: innerType = value.type.target().unqualified() address = value.address() if address: - self.putValue('@0x%x' % address, priority = -1) + self.putValue('@0x%x' % address, priority=-1) else: self.putEmptyValue() self.putType(arrayType) @@ -1102,20 +1108,27 @@ class DumperBase: # GDB/GCC produce sizeof == 0 for QProcess arr[3] # And in the Nim string dumper. s = value.type.name - itemCount = s[s.find('[')+1:s.find(']')] + itemCount = s[s.find('[') + 1:s.find(']')] if not itemCount: itemCount = '100' - arrayByteSize = int(itemCount) * innerType.size(); + arrayByteSize = int(itemCount) * innerType.size() n = arrayByteSize // innerType.size() p = value.address() - if displayFormat != DisplayFormat.RawFormat and p: - if innerType.name in ('char', 'wchar_t', 'unsigned char', 'signed char', 'CHAR', 'WCHAR'): + if displayFormat != DisplayFormat.Raw and p: + if innerType.name in ( + 'char', + 'wchar_t', + 'unsigned char', + 'signed char', + 'CHAR', + 'WCHAR' + ): self.putCharArrayHelper(p, n, innerType, self.currentItemFormat(), - makeExpandable = False) + makeExpandable=False) else: self.tryPutSimpleFormattedPointer(p, arrayType, innerType, - displayFormat, arrayByteSize) + displayFormat, arrayByteSize) self.putNumChild(n) if self.isExpanded(): @@ -1146,10 +1159,10 @@ class DumperBase: continue elif s == '>': lvl -= 1 - if lvl < 0 : + if lvl < 0: raise RuntimeError("Unbalanced '<' in type, @index %d" % index) if lvl == 0: - stripChunks.append((pos, index+1)) + stripChunks.append((pos, index + 1)) if lvl != 0: raise RuntimeError("unbalanced at end of type name") for (f, l) in reversed(stripChunks): @@ -1158,7 +1171,7 @@ class DumperBase: def tryPutPrettyItem(self, typeName, value): value.check() - if self.useFancy and self.currentItemFormat() != DisplayFormat.RawFormat: + if self.useFancy and self.currentItemFormat() != DisplayFormat.Raw: self.putType(typeName) nsStrippedType = self.stripNamespaceFromType(typeName)\ @@ -1190,7 +1203,7 @@ class DumperBase: return False - def putSimpleCharArray(self, base, size = None): + def putSimpleCharArray(self, base, size=None): if size is None: elided, shown, data = self.readToFirstZero(base, 1, self.displayStringLimit) else: @@ -1204,7 +1217,7 @@ class DumperBase: # This is shared by pointer and array formatting. def tryPutSimpleFormattedPointer(self, ptr, typeName, innerType, displayFormat, limit): - if displayFormat == DisplayFormat.AutomaticFormat: + if displayFormat == DisplayFormat.Automatic: if innerType.name in ('char', 'signed char', 'unsigned char', 'CHAR'): # Use UTF-8 as default for char *. self.putType(typeName) @@ -1224,45 +1237,45 @@ class DumperBase: self.putValue(data, 'ucs4', elided=elided) return True - if displayFormat == DisplayFormat.Latin1StringFormat: + if displayFormat == DisplayFormat.Latin1String: self.putType(typeName) (elided, data) = self.encodeCArray(ptr, 1, limit) self.putValue(data, 'latin1', elided=elided) return True - if displayFormat == DisplayFormat.SeparateLatin1StringFormat: + if displayFormat == DisplayFormat.SeparateLatin1String: self.putType(typeName) (elided, data) = self.encodeCArray(ptr, 1, limit) self.putValue(data, 'latin1', elided=elided) self.putDisplay('latin1:separate', data) return True - if displayFormat == DisplayFormat.Utf8StringFormat: + if displayFormat == DisplayFormat.Utf8String: self.putType(typeName) (elided, data) = self.encodeCArray(ptr, 1, limit) self.putValue(data, 'utf8', elided=elided) return True - if displayFormat == DisplayFormat.SeparateUtf8StringFormat: + if displayFormat == DisplayFormat.SeparateUtf8String: self.putType(typeName) (elided, data) = self.encodeCArray(ptr, 1, limit) self.putValue(data, 'utf8', elided=elided) self.putDisplay('utf8:separate', data) return True - if displayFormat == DisplayFormat.Local8BitStringFormat: + if displayFormat == DisplayFormat.Local8BitString: self.putType(typeName) (elided, data) = self.encodeCArray(ptr, 1, limit) self.putValue(data, 'local8bit', elided=elided) return True - if displayFormat == DisplayFormat.Utf16StringFormat: + if displayFormat == DisplayFormat.Utf16String: self.putType(typeName) (elided, data) = self.encodeCArray(ptr, 2, limit) self.putValue(data, 'utf16', elided=elided) return True - if displayFormat == DisplayFormat.Ucs4StringFormat: + if displayFormat == DisplayFormat.Ucs4String: self.putType(typeName) (elided, data) = self.encodeCArray(ptr, 4, limit) self.putValue(data, 'ucs4', elided=elided) @@ -1276,7 +1289,7 @@ class DumperBase: def putDerefedPointer(self, value): derefValue = value.dereference() - innerType = value.type.target() #.unqualified() + innerType = value.type.target() # .unqualified() self.putType(innerType) savedCurrentChildType = self.currentChildType self.currentChildType = innerType.name @@ -1315,7 +1328,7 @@ class DumperBase: return displayFormat = self.currentItemFormat(value.type.name) - innerType = value.type.target() #.unqualified() + innerType = value.type.target() # .unqualified() if innerType.name == 'void': #DumperBase.warn('VOID POINTER: %s' % displayFormat) @@ -1324,7 +1337,7 @@ class DumperBase: self.putNumChild(0) return - if displayFormat == DisplayFormat.RawFormat: + if displayFormat == DisplayFormat.Raw: # Explicitly requested bald pointer. #DumperBase.warn('RAW') self.putType(typeName) @@ -1337,21 +1350,21 @@ class DumperBase: return limit = self.displayStringLimit - if displayFormat in (DisplayFormat.SeparateLatin1StringFormat, DisplayFormat.SeparateUtf8StringFormat): + if displayFormat in (DisplayFormat.SeparateLatin1String, DisplayFormat.SeparateUtf8String): limit = 1000000 if self.tryPutSimpleFormattedPointer(pointer, typeName, innerType, displayFormat, limit): self.putNumChild(1) return - if DisplayFormat.Array10Format <= displayFormat and displayFormat <= DisplayFormat.Array1000Format: - n = (10, 100, 1000, 10000)[displayFormat - DisplayFormat.Array10Format] + if DisplayFormat.Array10 <= displayFormat and displayFormat <= DisplayFormat.Array1000: + n = (10, 100, 1000, 10000)[displayFormat - DisplayFormat.Array10] self.putType(typeName) self.putItemCount(n) self.putArrayData(value.pointer(), n, innerType) return - if innerType.code == TypeCode.TypeCodeFunction: + if innerType.code == TypeCode.Function: # A function pointer. self.putSymbolValue(pointer) self.putType(typeName) @@ -1363,7 +1376,14 @@ class DumperBase: #DumperBase.warn('INNER: %s' % innerType.name) if self.autoDerefPointers: # Generic pointer type with AutomaticFormat, but never dereference char types: - if innerType.name not in ('char', 'signed char', 'unsigned char', 'wchar_t', 'CHAR', 'WCHAR'): + if innerType.name not in ( + 'char', + 'signed char', + 'unsigned char', + 'wchar_t', + 'CHAR', + 'WCHAR' + ): self.putDerefedPointer(value) return @@ -1439,7 +1459,7 @@ class DumperBase: return True except: - # warn('NO QOBJECT: %s' % value.type) + # warn('NO QOBJECT: %s' % value.type) return False def couldBePointer(self, p): @@ -1487,7 +1507,7 @@ class DumperBase: offset = int.from_bytes(data[1:5], byteorder='little') return address + 5 + offset if primaryOpcode == jumpCode: - if data[1] != 0x25: # check for known extended opcode + if data[1] != 0x25: # check for known extended opcode return 0 # 0xff25 is a relative jump on 64bit and an absolute jump on 32 bit if self.ptrSize() == 8: @@ -1595,7 +1615,7 @@ class DumperBase: someTypeName = someTypeObj.name self.bump('metaObjectFromType') known = self.knownStaticMetaObjects.get(someTypeName, None) - if known is not None: # Is 0 or the static metaobject. + if known is not None: # Is 0 or the static metaobject. return known result = 0 @@ -1615,7 +1635,6 @@ class DumperBase: self.knownStaticMetaObjects[someTypeName] = result return result - if not self.useFancy: return 0 @@ -1623,7 +1642,7 @@ class DumperBase: typeName = typeobj.name result = self.knownStaticMetaObjects.get(typeName, None) - if result is not None: # Is 0 or the static metaobject. + if result is not None: # Is 0 or the static metaobject. self.bump('typecached') #DumperBase.warn('CACHED RESULT: %s %s 0x%x' % (self.currentIName, typeName, result)) return result @@ -1715,7 +1734,7 @@ class DumperBase: def metaString(self, metaObjectPtr, index, revision): ptrSize = self.ptrSize() stringdata = self.extractPointer(toInteger(metaObjectPtr) + ptrSize) - if revision >= 7: # Qt 5. + if revision >= 7: # Qt 5. byteArrayDataSize = 24 if ptrSize == 8 else 16 literal = stringdata + toInteger(index) * byteArrayDataSize ldata, lsize, lalloc = self.byteArrayDataHelper(literal) @@ -1724,7 +1743,7 @@ class DumperBase: return s if sys.version_info[0] == 2 else s.decode('utf8') except: return '' - else: # Qt 4. + else: # Qt 4. ldata = stringdata + index return self.extractCString(ldata).decode('utf8') @@ -1757,7 +1776,7 @@ class DumperBase: intSize = 4 ptrSize = self.ptrSize() - def putt(name, value, typeName = ' '): + def putt(name, value, typeName=' '): with SubItem(self, name): self.putValue(value) self.putType(typeName) @@ -1797,16 +1816,16 @@ class DumperBase: dd = self.extractPointer(qobjectPtr + ptrSize) if self.qtVersion() >= 0x50000: (dvtablePtr, qptr, parentPtr, childrenDPtr, flags, postedEvents, - dynMetaObjectPtr, # Up to here QObjectData. + dynMetaObjectPtr, # Up to here QObjectData. extraData, threadDataPtr, connectionListsPtr, sendersPtr, currentSenderPtr) \ - = self.split('ppppIIp' + 'ppppp', dd) + = self.split('ppppIIp' + 'ppppp', dd) else: (dvtablePtr, qptr, parentPtr, childrenDPtr, flags, postedEvents, - dynMetaObjectPtr, # Up to here QObjectData + dynMetaObjectPtr, # Up to here QObjectData objectName, extraData, threadDataPtr, connectionListsPtr, sendersPtr, currentSenderPtr) \ - = self.split('ppppIIp' + 'pppppp', dd) + = self.split('ppppIIp' + 'pppppp', dd) if qobjectPtr: qobjectType = self.createType('QObject') @@ -1820,7 +1839,7 @@ class DumperBase: self.putNumChild(0) with SubItem(self, '[children]'): self.putField('sortgroup', 8) - base = self.extractPointer(dd + 3 * ptrSize) # It's a QList + base = self.extractPointer(dd + 3 * ptrSize) # It's a QList begin = self.extractInt(base + 8) end = self.extractInt(base + 12) array = base + 16 @@ -1884,51 +1903,52 @@ class DumperBase: with Children(self): if extraData: self.putTypedPointer('[extraData]', extraData, - ns + 'QObjectPrivate::ExtraData') + ns + 'QObjectPrivate::ExtraData') with SubItem(self, '[metaObject]'): self.putAddress(metaObjectPtr) self.putNumChild(1) if self.isExpanded(): with Children(self): - self.putQObjectGutsHelper(0, 0, -1, metaObjectPtr, 'QMetaObject') + self.putQObjectGutsHelper( + 0, 0, -1, metaObjectPtr, 'QMetaObject') if False: - with SubItem(self, '[connections]'): - if connectionListsPtr: - typeName = '@QObjectConnectionListVector' - self.putItem(self.createValue(connectionListsPtr, typeName)) - else: - self.putItemCount(0) + with SubItem(self, '[connections]'): + if connectionListsPtr: + typeName = '@QObjectConnectionListVector' + self.putItem(self.createValue(connectionListsPtr, typeName)) + else: + self.putItemCount(0) if False: - with SubItem(self, '[signals]'): - self.putItemCount(signalCount) - if self.isExpanded(): - with Children(self): - j = -1 - for i in range(signalCount): - t = self.split('IIIII', dataPtr + 56 + 20 * i) - flags = t[4] - if flags != 0x06: - continue - j += 1 - with SubItem(self, j): - name = self.metaString(metaObjectPtr, t[0], revision) - self.putType(' ') - self.putValue(name) - self.putNumChild(1) - with Children(self): - putt('[nameindex]', t[0]) - #putt('[type]', 'signal') - putt('[argc]', t[1]) - putt('[parameter]', t[2]) - putt('[tag]', t[3]) - putt('[flags]', t[4]) - putt('[localindex]', str(i)) - putt('[globalindex]', str(globalOffset + i)) - #self.putQObjectConnections(dd) - + with SubItem(self, '[signals]'): + self.putItemCount(signalCount) + if self.isExpanded(): + with Children(self): + j = -1 + for i in range(signalCount): + t = self.split('IIIII', dataPtr + 56 + 20 * i) + flags = t[4] + if flags != 0x06: + continue + j += 1 + with SubItem(self, j): + name = self.metaString( + metaObjectPtr, t[0], revision) + self.putType(' ') + self.putValue(name) + self.putNumChild(1) + with Children(self): + putt('[nameindex]', t[0]) + #putt('[type]', 'signal') + putt('[argc]', t[1]) + putt('[parameter]', t[2]) + putt('[tag]', t[3]) + putt('[flags]', t[4]) + putt('[localindex]', str(i)) + putt('[globalindex]', str(globalOffset + i)) + #self.putQObjectConnections(dd) if isQMetaObject or isQObject: with SubItem(self, '[properties]'): @@ -1941,14 +1961,14 @@ class DumperBase: t = self.split('III', dataPtr + properties * 4 + 12 * i) name = self.metaString(metaObjectPtr, t[0], revision) if qobject and self.qtPropertyFunc: - # LLDB doesn't like calling it on a derived class, possibly - # due to type information living in a different shared object. - #base = self.createValue(qobjectPtr, '@QObject') - #DumperBase.warn("CALL FUNC: 0x%x" % self.qtPropertyFunc) + # LLDB doesn't like calling it on a derived class, possibly + # due to type information living in a different shared object. + #base = self.createValue(qobjectPtr, '@QObject') + #DumperBase.warn("CALL FUNC: 0x%x" % self.qtPropertyFunc) cmd = '((QVariant(*)(void*,char*))0x%x)((void*)0x%x,"%s")' \ - % (self.qtPropertyFunc, qobjectPtr, name) + % (self.qtPropertyFunc, qobjectPtr, name) try: - #DumperBase.warn('PROP CMD: %s' % cmd) + #DumperBase.warn('PROP CMD: %s' % cmd) res = self.parseAndEvaluate(cmd) #DumperBase.warn('PROP RES: %s' % res) except: @@ -1979,7 +1999,7 @@ class DumperBase: values = self.listChildrenGenerator( extraData + 2 * ptrSize, variantType.pointer()) names = self.listChildrenGenerator( - extraData + ptrSize, byteArrayType) + extraData + ptrSize, byteArrayType) for (k, v) in zip(names, values): with SubItem(self, propertyCount + dynamicPropertyCount): self.putField('key', self.encodeByteArray(k)) @@ -2000,7 +2020,7 @@ class DumperBase: superDataIterator = superDataPtr while superDataIterator: sdata = extractDataPtr(superDataIterator) - globalOffset += self.extractInt(sdata + 16) # methodCount member + globalOffset += self.extractInt(sdata + 16) # methodCount member superDataIterator = extractSuperDataPtr(superDataIterator) if isQMetaObject or isQObject: @@ -2066,7 +2086,6 @@ class DumperBase: self.putField('sortgroup', 11) self.putValue(globalOffset + localIndex) - def putQObjectConnections(self, dd): with SubItem(self, '[connections]'): ptrSize = self.ptrSize() @@ -2093,23 +2112,23 @@ class DumperBase: first = self.extractPointer(data + i * 2 * ptrSize) while first: self.putSubItem('%s' % pp, - self.createPointerValue(first, connectionType)) + self.createPointerValue(first, connectionType)) first = self.extractPointer(first + 3 * ptrSize) # We need to enforce some upper limit. pp += 1 if pp > 1000: break - def currentItemFormat(self, typeName = None): - displayFormat = self.formats.get(self.currentIName, DisplayFormat.AutomaticFormat) - if displayFormat == DisplayFormat.AutomaticFormat: + def currentItemFormat(self, typeName=None): + displayFormat = self.formats.get(self.currentIName, DisplayFormat.Automatic) + if displayFormat == DisplayFormat.Automatic: if typeName is None: typeName = self.currentType.value needle = None if typeName is None else self.stripForFormat(typeName) - displayFormat = self.typeformats.get(needle, DisplayFormat.AutomaticFormat) + displayFormat = self.typeformats.get(needle, DisplayFormat.Automatic) return displayFormat - def putSubItem(self, component, value): # -> ReportItem + def putSubItem(self, component, value): # -> ReportItem if not isinstance(value, self.Value): raise RuntimeError('WRONG VALUE TYPE IN putSubItem: %s' % type(value)) if not isinstance(value.type, self.Type): @@ -2120,7 +2139,7 @@ class DumperBase: res = self.currentValue return res # The 'short' display. - def putArrayData(self, base, n, innerType, childNumChild = None, maxNumChild = 10000): + def putArrayData(self, base, n, innerType, childNumChild=None, maxNumChild=10000): self.checkIntType(base) self.checkIntType(n) addrBase = base @@ -2134,14 +2153,14 @@ class DumperBase: self.put('addrstep="0x%x",' % innerSize) self.put('arrayencoding="%s",' % enc) if n > maxNumChild: - self.put('childrenelided="%s",' % n) # FIXME: Act on that in frontend + self.put('childrenelided="%s",' % n) # FIXME: Act on that in frontend n = maxNumChild self.put('arraydata="') self.put(self.readMemory(addrBase, n * innerSize)) self.put('",') else: with Children(self, n, innerType, childNumChild, maxNumChild, - addrBase=addrBase, addrStep=innerSize): + addrBase=addrBase, addrStep=innerSize): for i in self.childRange(): self.putSubItem(i, self.createValue(addrBase + i * innerSize, innerType)) @@ -2154,18 +2173,18 @@ class DumperBase: self.putArrayData(addr, n, self.lookupType(typeName)) self.putAddress(addr) - def putPlotDataHelper(self, base, n, innerType, maxNumChild = 1000*1000): + def putPlotDataHelper(self, base, n, innerType, maxNumChild=1000 * 1000): if n > maxNumChild: - self.putField('plotelided', n) # FIXME: Act on that in frontend + self.putField('plotelided', n) # FIXME: Act on that in frontend n = maxNumChild - if self.currentItemFormat() == DisplayFormat.ArrayPlotFormat and innerType.isSimpleType(): + if self.currentItemFormat() == DisplayFormat.ArrayPlot and innerType.isSimpleType(): enc = innerType.simpleEncoding() if enc: self.putField('editencoding', enc) self.putDisplay('plotdata:separate', self.readMemory(base, n * innerType.size())) - def putPlotData(self, base, n, innerType, maxNumChild = 1000*1000): + def putPlotData(self, base, n, innerType, maxNumChild=1000 * 1000): self.putPlotDataHelper(base, n, innerType, maxNumChild=maxNumChild) if self.isExpanded(): self.putArrayData(base, n, innerType, maxNumChild=maxNumChild) @@ -2198,7 +2217,7 @@ class DumperBase: def extractPointer(self, value): try: - if value.type.code == TypeCode.TypeCodeArray: + if value.type.code == TypeCode.Array: return value.address() except: pass @@ -2262,21 +2281,21 @@ class DumperBase: return i return len(s) - match = re.search('(\.)(\(.+?\))?(\.)', exp) + match = re.search(r'(\.)(\(.+?\))?(\.)', exp) if match: s = match.group(2) left_e = match.start(1) - left_s = 1 + left_e - searchUnbalanced(exp[left_e::-1], False) + left_s = 1 + left_e - searchUnbalanced(exp[left_e::-1], False) right_s = match.end(3) right_e = right_s + searchUnbalanced(exp[right_s:], True) - template = exp[:left_s] + '%s' + exp[right_e:] + template = exp[:left_s] + '%s' + exp[right_e:] a = exp[left_s:left_e] b = exp[right_s:right_e] try: # Allow integral expressions. - ss = self.parseAndEvaluate(s[1:len(s)-1]).integer() if s else 1 + ss = self.parseAndEvaluate(s[1:len(s) - 1]).integer() if s else 1 aa = self.parseAndEvaluate(a).integer() bb = self.parseAndEvaluate(b).integer() if aa < bb and ss > 0: @@ -2295,8 +2314,8 @@ class DumperBase: shadowed = {} for value in variables: if value.name == 'argv': - if value.type.code == TypeCode.TypeCodePointer: - if value.type.ltarget.code == TypeCode.TypeCodePointer: + if value.type.code == TypeCode.Pointer: + if value.type.ltarget.code == TypeCode.Pointer: if value.type.ltarget.ltarget.name == 'char': self.putSpecialArgv(value) continue @@ -2403,7 +2422,7 @@ class DumperBase: except: pass - def setupDumpers(self, _ = {}): + def setupDumpers(self, _={}): self.resetCaches() for mod in self.dumpermodules: @@ -2469,14 +2488,14 @@ class DumperBase: def reportInterpreterResult(self, resdict, args): print('interpreterresult=%s,token="%s"' - % (self.resultToMi(resdict), args.get('token', -1))) + % (self.resultToMi(resdict), args.get('token', -1))) def reportInterpreterAsync(self, resdict, asyncclass): print('interpreterasync=%s,asyncclass="%s"' - % (self.resultToMi(resdict), asyncclass)) + % (self.resultToMi(resdict), asyncclass)) def removeInterpreterBreakpoint(self, args): - res = self.sendInterpreterRequest('removebreakpoint', { 'id' : args['id'] }) + res = self.sendInterpreterRequest('removebreakpoint', {'id': args['id']}) return res def insertInterpreterBreakpoint(self, args): @@ -2516,12 +2535,12 @@ class DumperBase: # msg is a sequence of 'servicenamemsglenmsg' items. resdict = {} # Native payload. while len(msg): - pos0 = msg.index(' ') # End of service name - pos1 = msg.index(' ', pos0 + 1) # End of message length + pos0 = msg.index(' ') # End of service name + pos1 = msg.index(' ', pos0 + 1) # End of message length service = msg[0:pos0] - msglen = int(msg[pos0+1:pos1]) - msgend = pos1+1+msglen - payload = msg[pos1+1:msgend] + msglen = int(msg[pos0 + 1:pos1]) + msgend = pos1 + 1 + msglen + payload = msg[pos1 + 1:msgend] msg = msg[msgend:] if service == 'NativeQmlDebugger': try: @@ -2531,7 +2550,7 @@ class DumperBase: self.warn('Cannot parse native payload: %s' % payload) else: print('interpreteralien=%s' - % {'service': service, 'payload': self.hexencode(payload)}) + % {'service': service, 'payload': self.hexencode(payload)}) try: expr = 'qt_qmlDebugClearBuffer()' res = self.parseAndEvaluate(expr) @@ -2540,8 +2559,8 @@ class DumperBase: return resdict - def sendInterpreterRequest(self, command, args = {}): - encoded = json.dumps({ 'command': command, 'arguments': args }) + def sendInterpreterRequest(self, command, args={}): + encoded = json.dumps({'command': command, 'arguments': args}) hexdata = self.hexencode(encoded) expr = 'qt_qmlDebugSendDataToService("NativeQmlDebugger","%s")' % hexdata try: @@ -2586,12 +2605,12 @@ class DumperBase: if wasPending: if not bp: self.reportInterpreterResult({'bpnr': -1, 'pending': 1, - 'error': 'Pending interpreter breakpoint insertion failed.'}, args) + 'error': 'Pending interpreter breakpoint insertion failed.'}, args) return else: if not bp: self.reportInterpreterResult({'bpnr': -1, 'pending': 1, - 'warning': 'Direct interpreter breakpoint insertion failed.'}, args) + 'warning': 'Direct interpreter breakpoint insertion failed.'}, args) self.createResolvePendingBreakpointsHookBreakpoint(args) return self.reportInterpreterResult({'bpnr': bp, 'pending': 0}, args) @@ -2612,7 +2631,7 @@ class DumperBase: return functionName and functionName.find('QV4::Moth::VME::exec') >= 0 def extractInterpreterStack(self): - return self.sendInterpreterRequest('backtrace', {'limit': 10 }) + return self.sendInterpreterRequest('backtrace', {'limit': 10}) def isInt(self, thing): if isinstance(thing, int): @@ -2636,10 +2655,10 @@ class DumperBase: def putItemX(self, value): #DumperBase.warn('PUT ITEM: %s' % value.stringify()) - typeobj = value.type #unqualified() + typeobj = value.type # unqualified() typeName = typeobj.name - self.addToCache(typeobj) # Fill type cache + self.addToCache(typeobj) # Fill type cache if not value.lIsInScope: self.putSpecialValue('optimizedout') @@ -2653,19 +2672,19 @@ class DumperBase: # Try on possibly typedefed type first. if self.tryPutPrettyItem(typeName, value): - if typeobj.code == TypeCode.TypeCodePointer: + if typeobj.code == TypeCode.Pointer: self.putOriginalAddress(value.address()) else: self.putAddress(value.address()) return - if typeobj.code == TypeCode.TypeCodeTypedef: + if typeobj.code == TypeCode.Typedef: #DumperBase.warn('TYPEDEF VALUE: %s' % value.stringify()) self.putItem(value.detypedef()) self.putBetterType(typeName) return - if typeobj.code == TypeCode.TypeCodePointer: + if typeobj.code == TypeCode.Pointer: self.putFormattedPointer(value) if value.summary and self.useFancy: self.putValue(self.hexencode(value.summary), 'utf8:1:0') @@ -2673,34 +2692,35 @@ class DumperBase: self.putAddress(value.address()) - if typeobj.code == TypeCode.TypeCodeFunction: + if typeobj.code == TypeCode.Function: #DumperBase.warn('FUNCTION VALUE: %s' % value) self.putType(typeobj) self.putSymbolValue(value.pointer()) self.putNumChild(0) return - if typeobj.code == TypeCode.TypeCodeEnum: + if typeobj.code == TypeCode.Enum: #DumperBase.warn('ENUM VALUE: %s' % value.stringify()) self.putType(typeobj.name) self.putValue(value.display()) self.putNumChild(0) return - if typeobj.code == TypeCode.TypeCodeArray: + if typeobj.code == TypeCode.Array: #DumperBase.warn('ARRAY VALUE: %s' % value) self.putCStyleArray(value) return - if typeobj.code == TypeCode.TypeCodeBitfield: + if typeobj.code == TypeCode.Bitfield: #DumperBase.warn('BITFIELD VALUE: %s %d %s' % (value.name, value.lvalue, typeName)) self.putNumChild(0) dd = typeobj.ltarget.typeData().enumDisplay - self.putValue(str(value.lvalue) if dd is None else dd(value.lvalue, value.laddress, '%d')) + self.putValue(str(value.lvalue) if dd is None else dd( + value.lvalue, value.laddress, '%d')) self.putType(typeName) return - if typeobj.code == TypeCode.TypeCodeIntegral: + if typeobj.code == TypeCode.Integral: #DumperBase.warn('INTEGER: %s %s' % (value.name, value)) val = value.value() self.putNumChild(0) @@ -2708,14 +2728,14 @@ class DumperBase: self.putType(typeName) return - if typeobj.code == TypeCode.TypeCodeFloat: + if typeobj.code == TypeCode.Float: #DumperBase.warn('FLOAT VALUE: %s' % value) self.putValue(value.value()) self.putNumChild(0) self.putType(typeobj.name) return - if typeobj.code in (TypeCode.TypeCodeReference, TypeCode.TypeCodeRValueReference): + if typeobj.code in (TypeCode.Reference, TypeCode.RValueReference): #DumperBase.warn('REFERENCE VALUE: %s' % value) val = value.dereference() if val.laddress != 0: @@ -2725,13 +2745,13 @@ class DumperBase: self.putBetterType(typeName) return - if typeobj.code == TypeCode.TypeCodeComplex: + if typeobj.code == TypeCode.Complex: self.putType(typeobj) self.putValue(value.display()) self.putNumChild(0) return - if typeobj.code == TypeCode.TypeCodeFortranString: + if typeobj.code == TypeCode.FortranString: self.putValue(self.hexencode(value.data()), 'latin1') self.putNumChild(0) self.putType(typeobj) @@ -2810,19 +2830,19 @@ class DumperBase: self.typesReported[typename] = True self.typesToReport[typename] = typeobj - class Value: + class Value(): def __init__(self, dumper): self.dumper = dumper self.name = None self.type = None - self.ldata = None # Target address in case of references and pointers. - self.laddress = None # Own address. + self.ldata = None # Target address in case of references and pointers. + self.laddress = None # Own address. self.lIsInScope = True self.ldisplay = None - self.summary = None # Always hexencoded UTF-8. + self.summary = None # Always hexencoded UTF-8. self.lbitpos = None self.lbitsize = None - self.targetValue = None # For references. + self.targetValue = None # For references. self.isBaseClass = None self.nativeValue = None @@ -2858,8 +2878,8 @@ class DumperBase: def stringify(self): addr = 'None' if self.laddress is None else ('0x%x' % self.laddress) return "Value(name='%s',type=%s,bsize=%s,bpos=%s,data=%s,address=%s)" \ - % (self.name, self.type.name, self.lbitsize, self.lbitpos, - self.dumper.hexencode(self.ldata), addr) + % (self.name, self.type.name, self.lbitsize, self.lbitpos, + self.dumper.hexencode(self.ldata), addr) def displayEnum(self, form='%d', bitsize=None): intval = self.integer(bitsize) @@ -2883,19 +2903,19 @@ class DumperBase: return '' def pointer(self): - if self.type.code == TypeCode.TypeCodeTypedef: + if self.type.code == TypeCode.Typedef: return self.detypedef().pointer() return self.extractInteger(self.dumper.ptrSize() * 8, True) def integer(self, bitsize=None): - if self.type.code == TypeCode.TypeCodeTypedef: + if self.type.code == TypeCode.Typedef: return self.detypedef().integer() - elif self.type.code == TypeCode.TypeCodeBitfield: + elif self.type.code == TypeCode.Bitfield: return self.lvalue # Could be something like 'short unsigned int' unsigned = self.type.name == 'unsigned' \ - or self.type.name.startswith('unsigned ') \ - or self.type.name.find(' unsigned ') != -1 + or self.type.name.startswith('unsigned ') \ + or self.type.name.find(' unsigned ') != -1 if bitsize is None: bitsize = self.type.bitsize() return self.extractInteger(bitsize, unsigned) @@ -2903,7 +2923,7 @@ class DumperBase: def floatingPoint(self): if self.nativeValue is not None and not self.dumper.isCdb: return str(self.nativeValue) - if self.type.code == TypeCode.TypeCodeTypedef: + if self.type.code == TypeCode.Typedef: return self.detypedef().floatingPoint() if self.type.size() == 8: return self.extractSomething('d', 64) @@ -2949,17 +2969,17 @@ class DumperBase: def value(self): if self.type is not None: - if self.type.code == TypeCode.TypeCodeEnum: + if self.type.code == TypeCode.Enum: return self.displayEnum() - if self.type.code == TypeCode.TypeCodeTypedef: + if self.type.code == TypeCode.Typedef: return self.detypedef().value() - if self.type.code == TypeCode.TypeCodeIntegral: + if self.type.code == TypeCode.Integral: return self.integer() - if self.type.code == TypeCode.TypeCodeBitfield: + if self.type.code == TypeCode.Bitfield: return self.integer() - if self.type.code == TypeCode.TypeCodeFloat: + if self.type.code == TypeCode.Float: return self.floatingPoint() - if self.type.code == TypeCode.TypeCodePointer: + if self.type.code == TypeCode.Pointer: return self.pointer() return None @@ -2968,28 +2988,31 @@ class DumperBase: def findMemberByName(self, name): self.check() - if self.type.code == TypeCode.TypeCodeTypedef: + if self.type.code == TypeCode.Typedef: return self.findMemberByName(self.detypedef()) - if self.type.code in (TypeCode.TypeCodePointer, TypeCode.TypeCodeReference, TypeCode.TypeCodeRValueReference): + if self.type.code in ( + TypeCode.Pointer, + TypeCode.Reference, + TypeCode.RValueReference): res = self.dereference().findMemberByName(name) if res is not None: return res - if self.type.code == TypeCode.TypeCodeStruct: + if self.type.code == TypeCode.Struct: #DumperBase.warn('SEARCHING FOR MEMBER: %s IN %s' % (name, self.type.name)) members = self.members(True) #DumperBase.warn('MEMBERS: %s' % members) for member in members: #DumperBase.warn('CHECKING FIELD %s' % member.name) - if member.type.code == TypeCode.TypeCodeTypedef: + if member.type.code == TypeCode.Typedef: member = member.detypedef() if member.name == name: return member for member in members: - if member.type.code == TypeCode.TypeCodeTypedef: + if member.type.code == TypeCode.Typedef: member = member.detypedef() - if member.name == name: # Could be base class. + if member.name == name: # Could be base class. return member - if member.type.code == TypeCode.TypeCodeStruct: + if member.type.code == TypeCode.Struct: res = member.findMemberByName(name) if res is not None: return res @@ -2998,25 +3021,25 @@ class DumperBase: def __getitem__(self, index): #DumperBase.warn('GET ITEM %s %s' % (self, index)) self.check() - if self.type.code == TypeCode.TypeCodeTypedef: + if self.type.code == TypeCode.Typedef: #DumperBase.warn('GET ITEM STRIP TYPEDEFS TO %s' % self.type.ltarget) return self.cast(self.type.ltarget).__getitem__(index) if isinstance(index, str): - if self.type.code == TypeCode.TypeCodePointer: + if self.type.code == TypeCode.Pointer: #DumperBase.warn('GET ITEM %s DEREFERENCE TO %s' % (self, self.dereference())) return self.dereference().__getitem__(index) res = self.findMemberByName(index) if res is None: raise RuntimeError('No member named %s in type %s' - % (index, self.type.name)) + % (index, self.type.name)) return res elif isinstance(index, self.dumper.Field): field = index elif self.dumper.isInt(index): - if self.type.code == TypeCode.TypeCodeArray: + if self.type.code == TypeCode.Array: addr = self.laddress + int(index) * self.type.ltarget.size() return self.dumper.createValue(addr, self.type.ltarget) - if self.type.code == TypeCode.TypeCodePointer: + if self.type.code == TypeCode.Pointer: addr = self.pointer() + int(index) * self.type.ltarget.size() return self.dumper.createValue(addr, self.type.ltarget) return self.members(False)[index] @@ -3025,7 +3048,7 @@ class DumperBase: field.check() #DumperBase.warn('EXTRACT FIELD: %s, BASE 0x%x' % (field, self.address())) - if self.type.code == TypeCode.TypeCodePointer: + if self.type.code == TypeCode.Pointer: #DumperBase.warn('IS TYPEDEFED POINTER!') res = self.dereference() #DumperBase.warn('WAS POINTER: %s' % res) @@ -3042,9 +3065,9 @@ class DumperBase: #DumperBase.warn('EXTRACTOR SUCCEEDED: %s ' % val) return val - if self.type.code == TypeCode.TypeCodeTypedef: + if self.type.code == TypeCode.Typedef: return self.cast(self.type.ltarget).extractField(field) - if self.type.code in (TypeCode.TypeCodeReference, TypeCode.TypeCodeRValueReference): + if self.type.code in (TypeCode.Reference, TypeCode.RValueReference): return self.dereference().extractField(field) #DumperBase.warn('FIELD: %s ' % field) val = self.dumper.Value(self.dumper) @@ -3065,7 +3088,7 @@ class DumperBase: fieldOffset = fieldBitpos // 8 fieldType = field.fieldType() - if fieldType.code == TypeCode.TypeCodeBitfield: + if fieldType.code == TypeCode.Bitfield: fieldBitpos -= fieldOffset * 8 ldata = self.data() data = 0 @@ -3089,7 +3112,7 @@ class DumperBase: else: self.dumper.check(False) - if fieldType.code in (TypeCode.TypeCodeReference, TypeCode.TypeCodeRValueReference): + if fieldType.code in (TypeCode.Reference, TypeCode.RValueReference): if val.laddress is not None: val = self.dumper.createReferenceValue(val.laddress, fieldType.ltarget) val.name = field.name @@ -3104,7 +3127,7 @@ class DumperBase: # implementations. def members(self, includeBases): #DumperBase.warn("LISTING MEMBERS OF %s" % self) - if self.type.code == TypeCode.TypeCodeTypedef: + if self.type.code == TypeCode.Typedef: return self.detypedef().members(includeBases) tdata = self.type.typeData() @@ -3136,7 +3159,7 @@ class DumperBase: self.check() if self.dumper.isInt(other): stripped = self.type.stripTypedefs() - if stripped.code == TypeCode.TypeCodePointer: + if stripped.code == TypeCode.Pointer: address = self.pointer() + stripped.dereference().size() * other val = self.dumper.Value(self.dumper) val.laddress = None @@ -3149,16 +3172,16 @@ class DumperBase: self.check() if self.type.name == other.type.name: stripped = self.type.stripTypedefs() - if stripped.code == TypeCode.TypeCodePointer: + if stripped.code == TypeCode.Pointer: return (self.pointer() - other.pointer()) // stripped.dereference().size() raise RuntimeError('BAD DATA TO SUB TO: %s %s' % (self.type, other)) def dereference(self): self.check() - if self.type.code == TypeCode.TypeCodeTypedef: + if self.type.code == TypeCode.Typedef: return self.detypedef().dereference() val = self.dumper.Value(self.dumper) - if self.type.code in (TypeCode.TypeCodeReference, TypeCode.TypeCodeRValueReference): + if self.type.code in (TypeCode.Reference, TypeCode.RValueReference): val.summary = self.summary if self.nativeValue is None: val.laddress = self.pointer() @@ -3167,7 +3190,7 @@ class DumperBase: val.type = self.dumper.nativeDynamicType(val.laddress, self.type.dereference()) else: val = self.dumper.nativeValueDereferenceReference(self) - elif self.type.code == TypeCode.TypeCodePointer: + elif self.type.code == TypeCode.Pointer: if self.nativeValue is None: val.laddress = self.pointer() val.type = self.dumper.nativeDynamicType(val.laddress, self.type.dereference()) @@ -3184,7 +3207,7 @@ class DumperBase: def detypedef(self): self.check() - if self.type.code != TypeCode.TypeCodeTypedef: + if self.type.code != TypeCode.Typedef: raise RuntimeError("WRONG") val = self.copy() val.type = self.type.ltarget @@ -3223,7 +3246,7 @@ class DumperBase: self.check() return self.laddress - def data(self, size = None): + def data(self, size=None): self.check() if self.ldata is not None: if len(self.ldata) > 0: @@ -3282,6 +3305,7 @@ class DumperBase: (pp, size, fields) = self.dumper.describeStruct(pattern) #DumperBase.warn('SIZE: %s ' % size) result = struct.unpack_from(self.dumper.packCode + pp, self.data(size)) + def structFixer(field, thing): #DumperBase.warn('STRUCT MEMBER: %s' % type(thing)) if field.isStruct: @@ -3299,7 +3323,7 @@ class DumperBase: raise RuntimeError('STRUCT ERROR: %s %s' % (fields, result)) return tuple(map(structFixer, fields, result)) - def checkPointer(self, p, align = 1): + def checkPointer(self, p, align=1): ptr = p if self.isInt(p) else p.pointer() self.readRawMemory(ptr, 1) @@ -3316,8 +3340,8 @@ class DumperBase: if type_name[pos1 - 1] != ']': break - item_count = type_name[pos1+1:pos2] - return (type_name[0:pos1].strip(), type_name[pos2+1:].strip(), int(item_count)) + item_count = type_name[pos1 + 1:pos2] + return (type_name[0:pos1].strip(), type_name[pos2 + 1:].strip(), int(item_count)) def registerType(self, typeId, tdata): #DumperBase.warn('REGISTER TYPE: %s' % typeId) @@ -3330,13 +3354,13 @@ class DumperBase: #DumperBase.warn('REGISTER ALIAS %s FOR %s' % (aliasId, existingTypeId)) self.typeData[aliasId] = self.typeData[existingTypeId] - class TypeData: + class TypeData(): def __init__(self, dumper): self.dumper = dumper - self.lfields = None # None or Value -> list of member Values - self.lalignment = None # Function returning alignment of this struct + self.lfields = None # None or Value -> list of member Values + self.lalignment = None # Function returning alignment of this struct self.lbitsize = None - self.ltarget = None # Inner type for arrays + self.ltarget = None # Inner type for arrays self.templateArguments = [] self.code = None self.name = None @@ -3359,7 +3383,7 @@ class DumperBase: tdata.moduleName = self.moduleName return tdata - class Type: + class Type(): def __init__(self, dumper, typeId): self.typeId = typeId self.dumper = dumper @@ -3413,7 +3437,7 @@ class DumperBase: if tdata is None: return 'Type(id="%s")' % self.typeId return 'Type(name="%s",bsize=%s,code=%s)' \ - % (tdata.name, tdata.lbitsize, tdata.code) + % (tdata.name, tdata.lbitsize, tdata.code) def __getitem__(self, index): if self.dumper.isInt(index): @@ -3424,7 +3448,7 @@ class DumperBase: tdata = self.typeData() if tdata is None: return None - if tdata.code != TypeCode.TypeCodeStruct: + if tdata.code != TypeCode.Struct: return None try: vtbl = self.dumper.extractPointer(address) @@ -3448,12 +3472,13 @@ class DumperBase: def check(self): tdata = self.typeData() if tdata is None: - raise RuntimeError('TYPE WITHOUT DATA: %s ALL: %s' % (self.typeId, self.dumper.typeData.keys())) + raise RuntimeError('TYPE WITHOUT DATA: %s ALL: %s' % + (self.typeId, self.dumper.typeData.keys())) if tdata.name is None: raise RuntimeError('TYPE WITHOUT NAME: %s' % self.typeId) def dereference(self): - if self.code == TypeCode.TypeCodeTypedef: + if self.code == TypeCode.Typedef: return self.ltarget.dereference() self.check() return self.ltarget @@ -3485,34 +3510,34 @@ class DumperBase: def simpleEncoding(self): res = { - 'bool' : 'int:1', - 'char' : 'int:1', - 'signed char' : 'int:1', - 'unsigned char' : 'uint:1', - 'short' : 'int:2', - 'unsigned short' : 'uint:2', - 'int' : 'int:4', - 'unsigned int' : 'uint:4', - 'long long' : 'int:8', - 'unsigned long long' : 'uint:8', + 'bool': 'int:1', + 'char': 'int:1', + 'signed char': 'int:1', + 'unsigned char': 'uint:1', + 'short': 'int:2', + 'unsigned short': 'uint:2', + 'int': 'int:4', + 'unsigned int': 'uint:4', + 'long long': 'int:8', + 'unsigned long long': 'uint:8', 'float': 'float:4', 'double': 'float:8' }.get(self.name, None) return res def isSimpleType(self): - return self.code in (TypeCode.TypeCodeIntegral, TypeCode.TypeCodeFloat, TypeCode.TypeCodeEnum) + return self.code in (TypeCode.Integral, TypeCode.Float, TypeCode.Enum) def alignment(self): tdata = self.typeData() - if tdata.code == TypeCode.TypeCodeTypedef: + if tdata.code == TypeCode.Typedef: return tdata.ltarget.alignment() - if tdata.code in (TypeCode.TypeCodeIntegral, TypeCode.TypeCodeFloat, TypeCode.TypeCodeEnum): + if tdata.code in (TypeCode.Integral, TypeCode.Float, TypeCode.Enum): if tdata.name in ('double', 'long long', 'unsigned long long'): # Crude approximation. return 8 if self.dumper.isWindowsTarget() else self.dumper.ptrSize() return self.size() - if tdata.code in (TypeCode.TypeCodePointer, TypeCode.TypeCodeReference, TypeCode.TypeCodeRValueReference): + if tdata.code in (TypeCode.Pointer, TypeCode.Reference, TypeCode.RValueReference): return self.dumper.ptrSize() if tdata.lalignment is not None: #if isinstance(tdata.lalignment, function): # Does not work that way. @@ -3528,7 +3553,7 @@ class DumperBase: return self.typeData().ltarget def stripTypedefs(self): - if isinstance(self, self.dumper.Type) and self.code != TypeCode.TypeCodeTypedef: + if isinstance(self, self.dumper.Type) and self.code != TypeCode.Typedef: #DumperBase.warn('NO TYPEDEF: %s' % self) return self return self.ltarget @@ -3545,7 +3570,7 @@ class DumperBase: raise RuntimeError('DONT KNOW SIZE: %s' % self) def isMovableType(self): - if self.code in (TypeCode.TypeCodePointer, TypeCode.TypeCodeIntegral, TypeCode.TypeCodeFloat): + if self.code in (TypeCode.Pointer, TypeCode.Integral, TypeCode.Float): return True strippedName = self.dumper.stripNamespaceFromType(self.name) if strippedName in ( @@ -3559,7 +3584,7 @@ class DumperBase: 'QUrl', 'QVariant', 'QXmlStreamAttribute', 'QXmlStreamNamespaceDeclaration', 'QXmlStreamNotationDeclaration', 'QXmlStreamEntityDeclaration' - ): + ): return True if strippedName == 'QStringList': return self.dumper.qtVersion() >= 0x050000 @@ -3568,14 +3593,14 @@ class DumperBase: return False class Field(collections.namedtuple('Field', - ['dumper', 'name', 'type', 'bitsize', 'bitpos', - 'extractor', 'isBase', 'isStruct', 'isArtificial' ])): + ['dumper', 'name', 'type', 'bitsize', 'bitpos', + 'extractor', 'isBase', 'isStruct', 'isArtificial'])): def __new__(cls, dumper, name=None, type=None, bitsize=None, bitpos=None, extractor=None, isBase=False, isStruct=False, isArtificial=False): return super(DumperBase.Field, cls).__new__( - cls, dumper, name, type, bitsize, bitpos, - extractor, isBase, isStruct, isArtificial) + cls, dumper, name, type, bitsize, bitpos, + extractor, isBase, isStruct, isArtificial) __slots__ = () @@ -3586,7 +3611,7 @@ class DumperBase: #return 'Field(name="%s")' % self.name typename = None if self.type is None else self.type.stringify() return 'Field(name="%s",type=%s,bitpos=%s,bitsize=%s)' \ - % (self.name, typename, self.bitpos, self.bitsize) + % (self.name, typename, self.bitpos, self.bitsize) def check(self): pass @@ -3617,10 +3642,10 @@ class DumperBase: def createPointerValue(self, targetAddress, targetTypish): if not isinstance(targetTypish, self.Type) and not isinstance(targetTypish, str): raise RuntimeError('Expected type in createPointerValue(), got %s' - % type(targetTypish)) + % type(targetTypish)) if not self.isInt(targetAddress): raise RuntimeError('Expected integral address value in createPointerValue(), got %s' - % type(targetTypish)) + % type(targetTypish)) val = self.Value(self) val.ldata = self.toPointerData(targetAddress) targetType = self.createType(targetTypish).dynamicType(targetAddress) @@ -3630,10 +3655,10 @@ class DumperBase: def createReferenceValue(self, targetAddress, targetType): if not isinstance(targetType, self.Type): raise RuntimeError('Expected type in createReferenceValue(), got %s' - % type(targetType)) + % type(targetType)) if not self.isInt(targetAddress): raise RuntimeError('Expected integral address value in createReferenceValue(), got %s' - % type(targetType)) + % type(targetType)) val = self.Value(self) val.ldata = self.toPointerData(targetAddress) targetType = targetType.dynamicType(targetAddress) @@ -3643,13 +3668,13 @@ class DumperBase: def createPointerType(self, targetType): if not isinstance(targetType, self.Type): raise RuntimeError('Expected type in createPointerType(), got %s' - % type(targetType)) + % type(targetType)) typeId = targetType.typeId + ' *' tdata = self.TypeData(self) tdata.name = targetType.name + '*' tdata.typeId = typeId tdata.lbitsize = 8 * self.ptrSize() - tdata.code = TypeCode.TypeCodePointer + tdata.code = TypeCode.Pointer tdata.ltarget = targetType self.registerType(typeId, tdata) return self.Type(self, typeId) @@ -3657,12 +3682,12 @@ class DumperBase: def createReferenceType(self, targetType): if not isinstance(targetType, self.Type): raise RuntimeError('Expected type in createReferenceType(), got %s' - % type(targetType)) + % type(targetType)) typeId = targetType.typeId + ' &' tdata = self.TypeData(self) tdata.name = targetType.name + ' &' tdata.typeId = typeId - tdata.code = TypeCode.TypeCodeReference + tdata.code = TypeCode.Reference tdata.ltarget = targetType tdata.lbitsize = 8 * self.ptrSize() # Needed for Gdb13393 test. #tdata.lbitsize = None @@ -3672,12 +3697,12 @@ class DumperBase: def createRValueReferenceType(self, targetType): if not isinstance(targetType, self.Type): raise RuntimeError('Expected type in createRValueReferenceType(), got %s' - % type(targetType)) + % type(targetType)) typeId = targetType.typeId + ' &&' tdata = self.TypeData(self) tdata.name = targetType.name + ' &&' tdata.typeId = typeId - tdata.code = TypeCode.TypeCodeRValueReference + tdata.code = TypeCode.RValueReference tdata.ltarget = targetType tdata.lbitsize = None self.registerType(typeId, tdata) @@ -3686,7 +3711,7 @@ class DumperBase: def createArrayType(self, targetType, count): if not isinstance(targetType, self.Type): raise RuntimeError('Expected type in createArrayType(), got %s' - % type(targetType)) + % type(targetType)) targetTypeId = targetType.typeId if targetTypeId.endswith(']'): @@ -3700,7 +3725,7 @@ class DumperBase: tdata = self.TypeData(self) tdata.name = type_name tdata.typeId = type_id - tdata.code = TypeCode.TypeCodeArray + tdata.code = TypeCode.Array tdata.ltarget = targetType tdata.lbitsize = targetType.lbitsize * count self.registerType(type_id, tdata) @@ -3709,30 +3734,30 @@ class DumperBase: def createBitfieldType(self, targetType, bitsize): if not isinstance(targetType, self.Type): raise RuntimeError('Expected type in createBitfieldType(), got %s' - % type(targetType)) + % type(targetType)) typeId = '%s:%d' % (targetType.typeId, bitsize) tdata = self.TypeData(self) tdata.name = '%s : %d' % (targetType.typeId, bitsize) tdata.typeId = typeId - tdata.code = TypeCode.TypeCodeBitfield + tdata.code = TypeCode.Bitfield tdata.ltarget = targetType tdata.lbitsize = bitsize self.registerType(typeId, tdata) return self.Type(self, typeId) - def createTypedefedType(self, targetType, typeName, typeId = None): + def createTypedefedType(self, targetType, typeName, typeId=None): if typeId is None: typeId = typeName if not isinstance(targetType, self.Type): raise RuntimeError('Expected type in createTypedefType(), got %s' - % type(targetType)) + % type(targetType)) # Happens for C-style struct in GDB: typedef { int x; } struct S1; if targetType.typeId == typeId: return targetType tdata = self.TypeData(self) tdata.name = typeName tdata.typeId = typeId - tdata.code = TypeCode.TypeCodeTypedef + tdata.code = TypeCode.Typedef tdata.ltarget = targetType tdata.lbitsize = targetType.lbitsize #tdata.lfields = targetType.lfields @@ -3740,7 +3765,7 @@ class DumperBase: self.registerType(typeId, tdata) return self.Type(self, typeId) - def createType(self, typish, size = None): + def createType(self, typish, size=None): if isinstance(typish, self.Type): #typish.check() return typish @@ -3779,7 +3804,6 @@ class DumperBase: if size is not None: typish = ns + typish - tdata = self.typeData.get(typish, None) if tdata is not None: return self.Type(self, typish) @@ -3840,7 +3864,7 @@ class DumperBase: def createVectorItem(self, data, innerTypish): return self.createContainerItem(data, innerTypish, 'QVector') - class StructBuilder: + class StructBuilder(): def __init__(self, dumper): self.dumper = dumper self.pattern = '' @@ -3849,8 +3873,8 @@ class DumperBase: self.autoPadNext = False self.maxAlign = 1 - def addField(self, fieldSize, fieldCode = None, fieldIsStruct = False, - fieldName = None, fieldType = None, fieldAlign = 1): + def addField(self, fieldSize, fieldCode=None, fieldIsStruct=False, + fieldName=None, fieldType=None, fieldAlign=1): if fieldType is not None: fieldType = self.dumper.createType(fieldType) @@ -3864,7 +3888,7 @@ class DumperBase: padding = (fieldAlign - (self.currentBitsize >> 3)) % fieldAlign #DumperBase.warn('AUTO PADDING AT %s BITS BY %s BYTES' % (self.currentBitsize, padding)) field = self.dumper.Field(self.dumper, bitpos=self.currentBitsize, - bitsize=padding*8) + bitsize=padding * 8) self.pattern += '%ds' % padding self.currentBitsize += padding * 8 self.fields.append(field) @@ -3896,34 +3920,34 @@ class DumperBase: readingTypeName = False fieldType = self.createType(typeName) fieldAlign = fieldType.alignment() - builder.addField(n, fieldIsStruct = True, - fieldType = fieldType, fieldAlign = fieldAlign) + builder.addField(n, fieldIsStruct=True, + fieldType=fieldType, fieldAlign=fieldAlign) typeName = None n = None else: typeName += c - elif c == 't': # size_t - builder.addField(ptrSize, self.ptrCode(), fieldAlign = ptrSize) - elif c == 'p': # Pointer as int - builder.addField(ptrSize, self.ptrCode(), fieldAlign = ptrSize) - elif c == 'P': # Pointer as Value - builder.addField(ptrSize, '%ss' % ptrSize, fieldAlign = ptrSize) + elif c == 't': # size_t + builder.addField(ptrSize, self.ptrCode(), fieldAlign=ptrSize) + elif c == 'p': # Pointer as int + builder.addField(ptrSize, self.ptrCode(), fieldAlign=ptrSize) + elif c == 'P': # Pointer as Value + builder.addField(ptrSize, '%ss' % ptrSize, fieldAlign=ptrSize) elif c in ('d'): - builder.addField(8, c, fieldAlign = ptrSize) # fieldType = 'double' ? + builder.addField(8, c, fieldAlign=ptrSize) # fieldType = 'double' ? elif c in ('q', 'Q'): - builder.addField(8, c, fieldAlign = ptrSize) + builder.addField(8, c, fieldAlign=ptrSize) elif c in ('i', 'I', 'f'): - builder.addField(4, c, fieldAlign = 4) + builder.addField(4, c, fieldAlign=4) elif c in ('h', 'H'): - builder.addField(2, c, fieldAlign = 2) + builder.addField(2, c, fieldAlign=2) elif c in ('b', 'B', 'c'): - builder.addField(1, c, fieldAlign = 1) + builder.addField(1, c, fieldAlign=1) elif c >= '0' and c <= '9': if n is None: n = '' n += c elif c == 's': - builder.addField(int(n), fieldAlign = 1) + builder.addField(int(n), fieldAlign=1) n = None elif c == '{': readingTypeName = True diff --git a/share/qtcreator/debugger/gdbbridge.py b/share/qtcreator/debugger/gdbbridge.py index 55ad02afcd5..4d2e9680cce 100644 --- a/share/qtcreator/debugger/gdbbridge.py +++ b/share/qtcreator/debugger/gdbbridge.py @@ -35,7 +35,6 @@ import re import sys import struct import tempfile -import types from dumper import DumperBase, Children, toInteger, TopLevelItem from utils import TypeCode @@ -46,6 +45,7 @@ from utils import TypeCode # ####################################################################### + def safePrint(output): try: print(output) @@ -61,18 +61,19 @@ def safePrint(output): out += c print(out) + def registerCommand(name, func): class Command(gdb.Command): def __init__(self): super(Command, self).__init__(name, gdb.COMMAND_OBSCURE) + def invoke(self, args, from_tty): safePrint(func(args)) Command() - ####################################################################### # # Convenience @@ -83,18 +84,24 @@ def registerCommand(name, func): class PPCommand(gdb.Command): def __init__(self): super(PPCommand, self).__init__('pp', gdb.COMMAND_OBSCURE) + def invoke(self, args, from_tty): print(theCliDumper.fetchVariable(args)) + PPCommand() # Just convenience for 'python print gdb.parse_and_eval(...)' + + class PPPCommand(gdb.Command): def __init__(self): super(PPPCommand, self).__init__('ppp', gdb.COMMAND_OBSCURE) + def invoke(self, args, from_tty): print(gdb.parse_and_eval(args)) + PPPCommand() @@ -109,14 +116,17 @@ def scanStack(p, n): p += f.type.sizeof return r + class ScanStackCommand(gdb.Command): def __init__(self): super(ScanStackCommand, self).__init__('scanStack', gdb.COMMAND_OBSCURE) + def invoke(self, args, from_tty): if len(args) == 0: args = 20 safePrint(scanStack(gdb.parse_and_eval('$sp'), int(args))) + ScanStackCommand() @@ -126,7 +136,7 @@ ScanStackCommand() # ####################################################################### -class PlainDumper: +class PlainDumper(): def __init__(self, printer): self.printer = printer self.typeCache = {} @@ -143,7 +153,7 @@ class PlainDumper: d.putValue(d.hexencode(val), 'utf8:1:0') elif sys.version_info[0] <= 2 and isinstance(val, unicode): d.putValue(val) - elif val is not None: # Assuming LazyString + elif val is not None: # Assuming LazyString d.putCharArrayValue(val.address, val.length, val.type.target().sizeof) @@ -162,6 +172,7 @@ class PlainDumper: break d.putNumChild(1) + def importPlainDumpers(args): if args == 'off': try: @@ -172,11 +183,11 @@ def importPlainDumpers(args): else: theDumper.importPlainDumpers() + registerCommand('importPlainDumpers', importPlainDumpers) - -class OutputSaver: +class OutputSaver(): def __init__(self, d): self.d = d @@ -185,7 +196,7 @@ class OutputSaver: self.d.output = '' def __exit__(self, exType, exValue, exTraceBack): - if self.d.passExceptions and not exType is None: + if self.d.passExceptions and exType is not None: self.d.showException('OUTPUTSAVER', exType, exValue, exTraceBack) self.d.output = self.savedOutput else: @@ -194,7 +205,6 @@ class OutputSaver: return False - ####################################################################### # # The Dumper Class @@ -220,9 +230,9 @@ class Dumper(DumperBase): #DumperBase.warn('FROM FRAME VALUE: %s' % nativeValue.address) val = nativeValue try: - val = nativeValue.cast(nativeValue.dynamic_type) + val = nativeValue.cast(nativeValue.dynamic_type) except: - pass + pass return self.fromNativeValue(val) def fromNativeValue(self, nativeValue): @@ -249,7 +259,7 @@ class Dumper(DumperBase): # is surprisingly expensive. val.nativeValue = nativeValue #DumperBase.warn('CREATED PTR 1: %s' % val) - if not nativeValue.address is None: + if nativeValue.address is not None: val.laddress = toInteger(nativeValue.address) #DumperBase.warn('CREATED PTR 2: %s' % val) return val @@ -272,7 +282,7 @@ class Dumper(DumperBase): val = self.Value(self) val.nativeValue = nativeValue - if not nativeValue.address is None: + if nativeValue.address is not None: val.laddress = toInteger(nativeValue.address) else: size = nativeType.sizeof @@ -355,35 +365,35 @@ class Dumper(DumperBase): tdata.typeId = typeId tdata.lbitsize = nativeType.sizeof * 8 tdata.code = { - #gdb.TYPE_CODE_TYPEDEF : TypeCodeTypedef, # Handled above. - gdb.TYPE_CODE_METHOD : TypeCode.TypeCodeFunction, - gdb.TYPE_CODE_VOID : TypeCode.TypeCodeVoid, - gdb.TYPE_CODE_FUNC : TypeCode.TypeCodeFunction, - gdb.TYPE_CODE_METHODPTR : TypeCode.TypeCodeFunction, - gdb.TYPE_CODE_MEMBERPTR : TypeCode.TypeCodeFunction, - #gdb.TYPE_CODE_PTR : TypeCode.TypeCodePointer, # Handled above. - #gdb.TYPE_CODE_REF : TypeCode.TypeCodeReference, # Handled above. - gdb.TYPE_CODE_BOOL : TypeCode.TypeCodeIntegral, - gdb.TYPE_CODE_CHAR : TypeCode.TypeCodeIntegral, - gdb.TYPE_CODE_INT : TypeCode.TypeCodeIntegral, - gdb.TYPE_CODE_FLT : TypeCode.TypeCodeFloat, - gdb.TYPE_CODE_ENUM : TypeCode.TypeCodeEnum, - #gdb.TYPE_CODE_ARRAY : TypeCode.TypeCodeArray, - gdb.TYPE_CODE_STRUCT : TypeCode.TypeCodeStruct, - gdb.TYPE_CODE_UNION : TypeCode.TypeCodeStruct, - gdb.TYPE_CODE_COMPLEX : TypeCode.TypeCodeComplex, - gdb.TYPE_CODE_STRING : TypeCode.TypeCodeFortranString, + #gdb.TYPE_CODE_TYPEDEF : TypeCode.Typedef, # Handled above. + gdb.TYPE_CODE_METHOD: TypeCode.Function, + gdb.TYPE_CODE_VOID: TypeCode.Void, + gdb.TYPE_CODE_FUNC: TypeCode.Function, + gdb.TYPE_CODE_METHODPTR: TypeCode.Function, + gdb.TYPE_CODE_MEMBERPTR: TypeCode.Function, + #gdb.TYPE_CODE_PTR : TypeCode.Pointer, # Handled above. + #gdb.TYPE_CODE_REF : TypeCode.Reference, # Handled above. + gdb.TYPE_CODE_BOOL: TypeCode.Integral, + gdb.TYPE_CODE_CHAR: TypeCode.Integral, + gdb.TYPE_CODE_INT: TypeCode.Integral, + gdb.TYPE_CODE_FLT: TypeCode.Float, + gdb.TYPE_CODE_ENUM: TypeCode.Enum, + #gdb.TYPE_CODE_ARRAY : TypeCode.Array, + gdb.TYPE_CODE_STRUCT: TypeCode.Struct, + gdb.TYPE_CODE_UNION: TypeCode.Struct, + gdb.TYPE_CODE_COMPLEX: TypeCode.Complex, + gdb.TYPE_CODE_STRING: TypeCode.FortranString, }[code] - if tdata.code == TypeCode.TypeCodeEnum: - tdata.enumDisplay = lambda intval, addr, form : \ + if tdata.code == TypeCode.Enum: + tdata.enumDisplay = lambda intval, addr, form: \ self.nativeTypeEnumDisplay(nativeType, intval, form) - if tdata.code == TypeCode.TypeCodeStruct: - tdata.lalignment = lambda : \ + if tdata.code == TypeCode.Struct: + tdata.lalignment = lambda: \ self.nativeStructAlignment(nativeType) - tdata.lfields = lambda value : \ + tdata.lfields = lambda value: \ self.listMembers(value, nativeType) tdata.templateArguments = self.listTemplateParameters(nativeType) - self.registerType(typeId, tdata) # Fix up fields and template args + self.registerType(typeId, tdata) # Fix up fields and template args # warn('CREATE TYPE: %s' % typeId) #else: # warn('REUSE TYPE: %s' % typeId) @@ -417,7 +427,7 @@ class Dumper(DumperBase): enumerators.append((field.name, field.enumval)) # No match was found, try to return as flags - enumerators.sort(key = lambda x: x[1]) + enumerators.sort(key=lambda x: x[1]) flags = [] v = intval found = False @@ -460,16 +470,14 @@ class Dumper(DumperBase): align = handleItem(f.type, align) return align - #except: # # Happens in the BoostList dumper for a 'const bool' # # item named 'constant_time_size'. There isn't anything we can do # # in this case. - # pass + # pass #yield value.extractField(field) - def memberFromNativeFieldAndValue(self, nativeField, nativeValue, fieldName, value): nativeMember = self.nativeMemberFromField(nativeValue, nativeField) if nativeMember is None: @@ -554,9 +562,9 @@ class Dumper(DumperBase): extractor = None else: extractor = lambda value, \ - capturedNativeField = nativeField, \ - capturedNativeValue = nativeValue, \ - capturedFieldName = fieldName : \ + capturedNativeField = nativeField, \ + capturedNativeValue = nativeValue, \ + capturedFieldName = fieldName: \ self.memberFromNativeFieldAndValue(capturedNativeField, capturedNativeValue, capturedFieldName, @@ -564,10 +572,8 @@ class Dumper(DumperBase): #DumperBase.warn("FOUND NATIVE FIELD: %s bitpos: %s" % (fieldName, bitpos)) return self.Field(dumper=self, name=fieldName, isBase=nativeField.is_base_class, - bitsize=bitsize, bitpos=bitpos, type=fieldType, - extractor=extractor) - - + bitsize=bitsize, bitpos=bitpos, type=fieldType, + extractor=extractor) def listLocals(self, partialVar): frame = gdb.selected_frame() @@ -590,67 +596,67 @@ class Dumper(DumperBase): break for symbol in block: - # Filter out labels etc. - if symbol.is_variable or symbol.is_argument: - name = symbol.print_name + # Filter out labels etc. + if symbol.is_variable or symbol.is_argument: + name = symbol.print_name - if name in ('__in_chrg', '__PRETTY_FUNCTION__'): - continue + if name in ('__in_chrg', '__PRETTY_FUNCTION__'): + continue - if not partialVar is None and partialVar != name: - continue + if partialVar is not None and partialVar != name: + continue - # 'NotImplementedError: Symbol type not yet supported in - # Python scripts.' - #DumperBase.warn('SYMBOL %s (%s, %s)): ' % (symbol, name, symbol.name)) - if self.passExceptions and not self.isTesting: - nativeValue = frame.read_var(name, block) - value = self.fromFrameValue(nativeValue) - value.name = name - #DumperBase.warn('READ 0: %s' % value.stringify()) - items.append(value) - continue + # 'NotImplementedError: Symbol type not yet supported in + # Python scripts.' + #DumperBase.warn('SYMBOL %s (%s, %s)): ' % (symbol, name, symbol.name)) + if self.passExceptions and not self.isTesting: + nativeValue = frame.read_var(name, block) + value = self.fromFrameValue(nativeValue) + value.name = name + #DumperBase.warn('READ 0: %s' % value.stringify()) + items.append(value) + continue - try: - # Same as above, but for production. - nativeValue = frame.read_var(name, block) - value = self.fromFrameValue(nativeValue) - value.name = name - #DumperBase.warn('READ 1: %s' % value.stringify()) - items.append(value) - continue - except: - pass + try: + # Same as above, but for production. + nativeValue = frame.read_var(name, block) + value = self.fromFrameValue(nativeValue) + value.name = name + #DumperBase.warn('READ 1: %s' % value.stringify()) + items.append(value) + continue + except: + pass - try: - #DumperBase.warn('READ 2: %s' % item.value) - value = self.fromFrameValue(frame.read_var(name)) - value.name = name - items.append(value) - continue - except: - # RuntimeError: happens for - # void foo() { std::string s; std::wstring w; } - # ValueError: happens for (as of 2010/11/4) - # a local struct as found e.g. in - # gcc sources in gcc.c, int execute() - pass + try: + #DumperBase.warn('READ 2: %s' % item.value) + value = self.fromFrameValue(frame.read_var(name)) + value.name = name + items.append(value) + continue + except: + # RuntimeError: happens for + # void foo() { std::string s; std::wstring w; } + # ValueError: happens for (as of 2010/11/4) + # a local struct as found e.g. in + # gcc sources in gcc.c, int execute() + pass - try: - #DumperBase.warn('READ 3: %s %s' % (name, item.value)) - #DumperBase.warn('ITEM 3: %s' % item.value) - value = self.fromFrameValue(gdb.parse_and_eval(name)) - value.name = name - items.append(value) - except: - # Can happen in inlined code (see last line of - # RowPainter::paintChars(): 'RuntimeError: - # No symbol '__val' in current context.\n' - pass + try: + #DumperBase.warn('READ 3: %s %s' % (name, item.value)) + #DumperBase.warn('ITEM 3: %s' % item.value) + value = self.fromFrameValue(gdb.parse_and_eval(name)) + value.name = name + items.append(value) + except: + # Can happen in inlined code (see last line of + # RowPainter::paintChars(): 'RuntimeError: + # No symbol '__val' in current context.\n' + pass # The outermost block in a function has the function member # FIXME: check whether this is guaranteed. - if not block.function is None: + if block.function is not None: break block = block.superblock @@ -670,7 +676,7 @@ class Dumper(DumperBase): self.resetStats() self.prepare(args) - self.isBigEndian = gdb.execute('show endian', to_string = True).find('big endian') > 0 + self.isBigEndian = gdb.execute('show endian', to_string=True).find('big endian') > 0 self.packCode = '>' if self.isBigEndian else '<' (ok, res) = self.tryFetchInterpreterVariables(args) @@ -757,7 +763,7 @@ class Dumper(DumperBase): #exp = '((class %s*)%s)->%s(%s)' % (typeName, value.laddress, function, arg) addr = value.address() if addr is None: - addr = self.pokeValue(value) + addr = self.pokeValue(value) #DumperBase.warn('PTR: %s -> %s(%s)' % (value, function, addr)) exp = '((%s*)0x%x)->%s(%s)' % (typeName, addr, function, arg) #DumperBase.warn('CALL: %s' % exp) @@ -777,9 +783,9 @@ class Dumper(DumperBase): def makeStdString(init): # Works only for small allocators, but they are usually empty. - gdb.execute('set $d=(std::string*)calloc(sizeof(std::string), 2)'); + gdb.execute('set $d=(std::string*)calloc(sizeof(std::string), 2)') gdb.execute('call($d->basic_string("' + init + - '",*(std::allocator*)(1+$d)))') + '",*(std::allocator*)(1+$d)))') value = gdb.parse_and_eval('$d').dereference() return value @@ -791,7 +797,7 @@ class Dumper(DumperBase): data = value.data() h = self.hexencode(data) #DumperBase.warn('DATA: %s' % h) - string = ''.join('\\x' + h[2*i:2*i+2] for i in range(size)) + string = ''.join('\\x' + h[2 * i:2 * i + 2] for i in range(size)) exp = '(%s*)memcpy(calloc(%d, 1), "%s", %d)' \ % (value.type.name, size, string, size) #DumperBase.warn('EXP: %s' % exp) @@ -886,7 +892,7 @@ class Dumper(DumperBase): try: version = self.qtVersionString() - (major, minor, patch) = version[version.find('"')+1:version.rfind('"')].split('.') + (major, minor, patch) = version[version.find('"') + 1:version.rfind('"')].split('.') qtversion = 0x10000 * int(major) + 0x100 * int(minor) + int(patch) self.qtVersion = lambda: qtversion return qtversion @@ -896,6 +902,7 @@ class Dumper(DumperBase): def createSpecialBreakpoints(self, args): self.specialBreakpoints = [] + def newSpecial(spec): # GDB < 8.1 does not have the 'qualified' parameter here, # GDB >= 8.1 applies some generous pattern matching, hitting @@ -903,7 +910,7 @@ class Dumper(DumperBase): class Pre81SpecialBreakpoint(gdb.Breakpoint): def __init__(self, spec): super(Pre81SpecialBreakpoint, self).__init__(spec, - gdb.BP_BREAKPOINT, internal=True) + gdb.BP_BREAKPOINT, internal=True) self.spec = spec def stop(self): @@ -913,7 +920,9 @@ class Dumper(DumperBase): class SpecialBreakpoint(gdb.Breakpoint): def __init__(self, spec): super(SpecialBreakpoint, self).__init__(spec, - gdb.BP_BREAKPOINT, internal=True, qualified=True) + gdb.BP_BREAKPOINT, + internal=True, + qualified=True) self.spec = spec def stop(self): @@ -999,7 +1008,6 @@ class Dumper(DumperBase): # oldthread.switch() #return out + ']' - def importPlainDumper(self, printer): name = printer.name.replace('::', '__') self.qqDumpers[name] = PlainDumper(printer) @@ -1024,9 +1032,9 @@ class Dumper(DumperBase): def handleNewObjectFile(self, objfile): name = objfile.filename if self.isWindowsTarget(): - qtCoreMatch = re.match('.*Qt5?Core[^/.]*d?\.dll', name) + qtCoreMatch = re.match(r'.*Qt5?Core[^/.]*d?\.dll', name) else: - qtCoreMatch = re.match('.*/libQt5?Core[^/.]*\.so', name) + qtCoreMatch = re.match(r'.*/libQt5?Core[^/.]*\.so', name) if qtCoreMatch is not None: self.addDebugLibs(objfile) @@ -1043,18 +1051,17 @@ class Dumper(DumperBase): except: pass - def handleQtCoreLoaded(self, objfile): fd, tmppath = tempfile.mkstemp() os.close(fd) cmd = 'maint print msymbols %s "%s"' % (tmppath, objfile.filename) try: - symbols = gdb.execute(cmd, to_string = True) + symbols = gdb.execute(cmd, to_string=True) except: # command syntax depends on gdb version - below is gdb 8+ cmd = 'maint print msymbols -objfile "%s" -- %s' % (objfile.filename, tmppath) try: - symbols = gdb.execute(cmd, to_string = True) + symbols = gdb.execute(cmd, to_string=True) except: pass ns = '' @@ -1063,14 +1070,14 @@ class Dumper(DumperBase): if line.find('msgHandlerGrabbed ') >= 0: # [11] b 0x7ffff683c000 _ZN4MynsL17msgHandlerGrabbedE # section .tbss Myns::msgHandlerGrabbed qlogging.cpp - ns = re.split('_ZN?(\d*)(\w*)L17msgHandlerGrabbedE? ', line)[2] + ns = re.split(r'_ZN?(\d*)(\w*)L17msgHandlerGrabbedE? ', line)[2] if len(ns): ns += '::' break if line.find('currentThreadData ') >= 0: # [ 0] b 0x7ffff67d3000 _ZN2UUL17currentThreadDataE # section .tbss UU::currentThreadData qthread_unix.cpp\\n - ns = re.split('_ZN?(\d*)(\w*)L17currentThreadDataE? ', line)[2] + ns = re.split(r'_ZN?(\d*)(\w*)L17currentThreadDataE? ', line)[2] if len(ns): ns += '::' break @@ -1179,14 +1186,14 @@ class Dumper(DumperBase): def lookupNativeType(self, typeName): nativeType = self.lookupNativeTypeHelper(typeName) - if not nativeType is None: + if nativeType is not None: self.check(isinstance(nativeType, gdb.Type)) return nativeType def lookupNativeTypeHelper(self, typeName): typeobj = self.typeCache.get(typeName) #DumperBase.warn('LOOKUP 1: %s -> %s' % (typeName, typeobj)) - if not typeobj is None: + if typeobj is not None: return typeobj if typeName == 'void': @@ -1212,7 +1219,7 @@ class Dumper(DumperBase): ts = typeName ts = ts.replace('{anonymous}', '(anonymous namespace)') typeobj = self.lookupNativeType(ts) - if not typeobj is None: + if typeobj is not None: self.typeCache[typeName] = typeobj self.typesToReport[typeName] = typeobj return typeobj @@ -1248,7 +1255,7 @@ class Dumper(DumperBase): if ts.endswith('*'): typeobj = self.lookupNativeType(ts[0:-1]) - if not typeobj is None: + if typeobj is not None: typeobj = typeobj.pointer() self.typeCache[typeName] = typeobj self.typesToReport[typeName] = typeobj @@ -1271,7 +1278,7 @@ class Dumper(DumperBase): #DumperBase.warn("LOOKING UP '%s' FAILED" % ts) pass - if not typeobj is None: + if typeobj is not None: #DumperBase.warn('CACHING: %s' % typeobj) self.typeCache[typeName] = typeobj self.typesToReport[typeName] = typeobj @@ -1292,7 +1299,7 @@ class Dumper(DumperBase): extraQml = int(args.get('extraqml', '0')) limit = int(args['limit']) if limit <= 0: - limit = 10000 + limit = 10000 self.prepare(args) self.output = '' @@ -1316,8 +1323,8 @@ class Dumper(DumperBase): value = symbol.value(frame) typeobj = value.type if typeobj.code == gdb.TYPE_CODE_PTR: - dereftype = typeobj.target().unqualified() - if dereftype.name == needle: + dereftype = typeobj.target().unqualified() + if dereftype.name == needle: addr = toInteger(value) expr = pat % (ns, addr) res = str(gdb.parse_and_eval(expr)) @@ -1347,7 +1354,7 @@ class Dumper(DumperBase): if sal: line = sal.line symtab = sal.symtab - if not symtab is None: + if symtab is not None: objfile = fromNativePath(symtab.objfile.filename) fullname = symtab.fullname() if fullname is None: @@ -1366,22 +1373,22 @@ class Dumper(DumperBase): context = interpreterFrame.get('context', 0) self.put(('frame={function="%s",file="%s",' - 'line="%s",language="%s",context="%s"}') - % (function, self.hexencode(fileName), lineNumber, language, context)) + 'line="%s",language="%s",context="%s"}') + % (function, self.hexencode(fileName), lineNumber, language, context)) if False and self.isInternalInterpreterFrame(functionName): frame = frame.older() self.put(('frame={address="0x%x",function="%s",' - 'file="%s",line="%s",' - 'module="%s",language="c",usable="0"}') % - (pc, functionName, fileName, line, objfile)) + 'file="%s",line="%s",' + 'module="%s",language="c",usable="0"}') % + (pc, functionName, fileName, line, objfile)) i += 1 frame = frame.older() continue self.put(('frame={level="%s",address="0x%x",function="%s",' - 'file="%s",line="%s",module="%s",language="c"}') % - (i, pc, functionName, fileName, line, objfile)) + 'file="%s",line="%s",module="%s",language="c"}') % + (i, pc, functionName, fileName, line, objfile)) frame = frame.older() i += 1 @@ -1406,7 +1413,7 @@ class Dumper(DumperBase): def exitGdb(self, _): gdb.execute('quit') - def reportResult(self, result, args = {}): + def reportResult(self, result, args={}): print('result={token="%s",%s}' % (args.get("token", 0), result)) def profile1(self, args): @@ -1420,8 +1427,7 @@ class Dumper(DumperBase): def profile2(self, args): import timeit print(timeit.repeat('theDumper.fetchVariables(%s)' % args, - 'from __main__ import theDumper', number=10)) - + 'from __main__ import theDumper', number=10)) class CliDumper(Dumper): @@ -1473,6 +1479,7 @@ theCliDumper = CliDumper() def threadnames(arg): return theDumper.threadnames(int(arg)) + registerCommand('threadnames', threadnames) ####################################################################### @@ -1481,6 +1488,7 @@ registerCommand('threadnames', threadnames) # ####################################################################### + class InterpreterMessageBreakpoint(gdb.Breakpoint): def __init__(self): spec = 'qt_qmlDebugMessageAvailable' @@ -1501,6 +1509,7 @@ class InterpreterMessageBreakpoint(gdb.Breakpoint): def new_objfile_handler(event): return theDumper.handleNewObjectFile(event.new_objfile) + gdb.events.new_objfile.connect(new_objfile_handler) diff --git a/share/qtcreator/debugger/lldbbridge.py b/share/qtcreator/debugger/lldbbridge.py index 5e049aeb246..b9806054516 100644 --- a/share/qtcreator/debugger/lldbbridge.py +++ b/share/qtcreator/debugger/lldbbridge.py @@ -52,6 +52,7 @@ from dumper import DumperBase, SubItem, Children, TopLevelItem qqWatchpointOffset = 10000 + def fileNameAsString(file): return str(file) if file.IsValid() else '' @@ -60,8 +61,9 @@ def check(exp): if not exp: raise RuntimeError('Check failed') + class Dumper(DumperBase): - def __init__(self, debugger = None): + def __init__(self, debugger=None): DumperBase.__init__(self) lldb.theDumper = self @@ -169,14 +171,14 @@ class Dumper(DumperBase): elif code == lldb.eTypeClassTypedef: nativeTargetType = nativeType.GetUnqualifiedType() if hasattr(nativeTargetType, 'GetCanonicalType'): - nativeTargetType = nativeTargetType.GetCanonicalType() + nativeTargetType = nativeTargetType.GetCanonicalType() val = self.fromNativeValue(nativeValue.Cast(nativeTargetType)) val.type = self.fromNativeType(nativeType) #DumperBase.warn('CREATED TYPEDEF: %s' % val) else: val = self.Value(self) address = nativeValue.GetLoadAddress() - if not address is None: + if address is not None: val.laddress = address if True: data = nativeValue.GetData() @@ -270,27 +272,27 @@ class Dumper(DumperBase): fieldBitpos = None isBitfield = False - if isBitfield: # Bit fields + if isBitfield: # Bit fields fieldType = self.createBitfieldType( self.createType(self.typeName(nativeFieldType)), fieldBitsize) yield self.Field(self, name=fieldName, type=fieldType, bitsize=fieldBitsize, bitpos=fieldBitpos) - elif fieldName is None: # Anon members + elif fieldName is None: # Anon members anonNumber += 1 fieldName = '#%s' % anonNumber fakeMember = fakeValue.GetChildAtIndex(i) fakeMemberAddress = fakeMember.GetLoadAddress() offset = fakeMemberAddress - fakeAddress yield self.Field(self, name=fieldName, type=self.fromNativeType(nativeFieldType), - bitsize=fieldBitsize, bitpos=8*offset) + bitsize=fieldBitsize, bitpos=8 * offset) elif fieldName in baseNames: # Simple bases member = self.fromNativeValue(fakeValue.GetChildAtIndex(i)) member.isBaseClass = True yield member - else: # Normal named members + else: # Normal named members member = self.fromNativeValue(fakeValue.GetChildAtIndex(i)) member.name = nativeField.GetName() yield member @@ -389,7 +391,7 @@ class Dumper(DumperBase): #DumperBase.warn('TYPEDEF') nativeTargetType = nativeType.GetUnqualifiedType() if hasattr(nativeTargetType, 'GetCanonicalType'): - nativeTargetType = nativeTargetType.GetCanonicalType() + nativeTargetType = nativeTargetType.GetCanonicalType() targetType = self.fromNativeType(nativeTargetType) return self.createTypedefedType(targetType, nativeType.GetName()) @@ -398,10 +400,10 @@ class Dumper(DumperBase): if code in (lldb.eTypeClassArray, lldb.eTypeClassVector): #DumperBase.warn('ARRAY: %s' % nativeType.GetName()) - if hasattr(nativeType, 'GetArrayElementType'): # New in 3.8(?) / 350.x + if hasattr(nativeType, 'GetArrayElementType'): # New in 3.8(?) / 350.x nativeTargetType = nativeType.GetArrayElementType() if not nativeTargetType.IsValid(): - if hasattr(nativeType, 'GetVectorElementType'): # New in 3.8(?) / 350.x + if hasattr(nativeType, 'GetVectorElementType'): # New in 3.8(?) / 350.x #DumperBase.warn('BAD: %s ' % nativeTargetType.get_fields_array()) nativeTargetType = nativeType.GetVectorElementType() count = nativeType.GetByteSize() // nativeTargetType.GetByteSize() @@ -414,9 +416,9 @@ class Dumper(DumperBase): targetType = self.fromNativeType(nativeTargetType) tdata = targetType.typeData().copy() tdata.name = targetTypeName - targetType.typeData = lambda : tdata + targetType.typeData = lambda: tdata return self.createArrayType(targetType, count) - if hasattr(nativeType, 'GetVectorElementType'): # New in 3.8(?) / 350.x + if hasattr(nativeType, 'GetVectorElementType'): # New in 3.8(?) / 350.x nativeTargetType = nativeType.GetVectorElementType() count = nativeType.GetByteSize() // nativeTargetType.GetByteSize() targetType = self.fromNativeType(nativeTargetType) @@ -434,34 +436,34 @@ class Dumper(DumperBase): tdata.lbitsize = nativeType.GetByteSize() * 8 if code == lldb.eTypeClassBuiltin: if utils.isFloatingPointTypeName(typeName): - tdata.code = TypeCode.TypeCodeFloat + tdata.code = TypeCode.Float elif utils.isIntegralTypeName(typeName): - tdata.code = TypeCode.TypeCodeIntegral + tdata.code = TypeCode.Integral elif typeName in ('__int128', 'unsigned __int128'): - tdata.code = TypeCode.TypeCodeIntegral + tdata.code = TypeCode.Integral elif typeName == 'void': - tdata.code = TypeCode.TypeCodeVoid + tdata.code = TypeCode.Void else: self.warn('UNKNOWN TYPE KEY: %s: %s' % (typeName, code)) elif code == lldb.eTypeClassEnumeration: - tdata.code = TypeCode.TypeCodeEnum - tdata.enumDisplay = lambda intval, addr, form : \ + tdata.code = TypeCode.Enum + tdata.enumDisplay = lambda intval, addr, form: \ self.nativeTypeEnumDisplay(nativeType, intval, form) elif code in (lldb.eTypeClassComplexInteger, lldb.eTypeClassComplexFloat): - tdata.code = TypeCode.TypeCodeComplex + tdata.code = TypeCode.Complex elif code in (lldb.eTypeClassClass, lldb.eTypeClassStruct, lldb.eTypeClassUnion): - tdata.code = TypeCode.TypeCodeStruct - tdata.lalignment = lambda : \ + tdata.code = TypeCode.Struct + tdata.lalignment = lambda: \ self.nativeStructAlignment(nativeType) - tdata.lfields = lambda value : \ + tdata.lfields = lambda value: \ self.listMembers(value, nativeType) tdata.templateArguments = self.listTemplateParametersHelper(nativeType) elif code == lldb.eTypeClassFunction: - tdata.code = TypeCode.TypeCodeFunction + tdata.code = TypeCode.Function elif code == lldb.eTypeClassMemberPointer: - tdata.code = TypeCode.TypeCodeMemberPointer + tdata.code = TypeCode.MemberPointer - self.registerType(typeId, tdata) # Fix up fields and template args + self.registerType(typeId, tdata) # Fix up fields and template args # warn('CREATE TYPE: %s' % typeId) #else: # warn('REUSE TYPE: %s' % typeId) @@ -489,7 +491,8 @@ class Dumper(DumperBase): # eTemplateArgumentKindExpression, # eTemplateArgumentKindPack if kind == lldb.eTemplateArgumentKindType: - innerType = nativeType.GetTemplateArgumentType(i).GetUnqualifiedType().GetCanonicalType() + innerType = nativeType.GetTemplateArgumentType( + i).GetUnqualifiedType().GetCanonicalType() targs.append(self.fromNativeType(innerType)) #elif kind == lldb.eTemplateArgumentKindIntegral: # innerType = nativeType.GetTemplateArgumentType(i).GetUnqualifiedType().GetCanonicalType() @@ -510,7 +513,7 @@ class Dumper(DumperBase): # targs.append(value) else: #DumperBase.warn('UNHANDLED TEMPLATE TYPE : %s' % kind) - targs.append(stringArgs[i]) # Best we can do. + targs.append(stringArgs[i]) # Best we can do. #DumperBase.warn('TARGS: %s %s' % (nativeType.GetName(), [str(x) for x in targs])) return targs @@ -562,7 +565,7 @@ class Dumper(DumperBase): return form % intval def nativeDynamicTypeName(self, address, baseType): - return None # FIXME: Seems sufficient, no idea why. + return None # FIXME: Seems sufficient, no idea why. addr = self.target.ResolveLoadAddress(address) ctx = self.target.ResolveSymbolContextForAddress(addr, 0) sym = ctx.GetSymbol() @@ -573,20 +576,20 @@ class Dumper(DumperBase): # See db.StateType return ( 'invalid', - 'unloaded', # Process is object is valid, but not currently loaded - 'connected', # Process is connected to remote debug services, - # but not launched or attached to anything yet - 'attaching', # Process is currently trying to attach - 'launching', # Process is in the process of launching - 'stopped', # Process or thread is stopped and can be examined. - 'running', # Process or thread is running and can't be examined. - 'stepping', # Process or thread is in the process of stepping - # and can not be examined. - 'crashed', # Process or thread has crashed and can be examined. - 'detached', # Process has been detached and can't be examined. - 'exited', # Process has exited and can't be examined. - 'suspended' # Process or thread is in a suspended state as far - )[s] + 'unloaded', # Process is object is valid, but not currently loaded + 'connected', # Process is connected to remote debug services, + # but not launched or attached to anything yet + 'attaching', # Process is currently trying to attach + 'launching', # Process is in the process of launching + 'stopped', # Process or thread is stopped and can be examined. + 'running', # Process or thread is running and can't be examined. + 'stepping', # Process or thread is in the process of stepping + # and can not be examined. + 'crashed', # Process or thread has crashed and can be examined. + 'detached', # Process has been detached and can't be examined. + 'exited', # Process has exited and can't be examined. + 'suspended' # Process or thread is in a suspended state as far + )[s] except: return 'unknown(%s)' % s @@ -604,7 +607,7 @@ class Dumper(DumperBase): 'plancomplete', 'threadexiting', 'instrumentation', - )[s] + )[s] except: return 'unknown(%s)' % s @@ -708,8 +711,8 @@ class Dumper(DumperBase): if version.count('.') != 2: continue - version.replace("'", '"') # Both seem possible - version = version[version.find('"')+1:version.rfind('"')] + version.replace("'", '"') # Both seem possible + version = version[version.find('"') + 1:version.rfind('"')] (major, minor, patch) = version.split('.') qtVersion = 0x10000 * int(major) + 0x100 * int(minor) + int(patch) @@ -753,7 +756,7 @@ class Dumper(DumperBase): def lookupNativeType(self, name): #DumperBase.warn('LOOKUP TYPE NAME: %s' % name) typeobj = self.typeCache.get(name) - if not typeobj is None: + if typeobj is not None: #DumperBase.warn('CACHED: %s' % name) return typeobj typeobj = self.target.FindFirstType(name) @@ -845,7 +848,7 @@ class Dumper(DumperBase): self.startMode_ = args.get('startmode', 1) self.breakOnMain_ = args.get('breakonmain', 0) self.useTerminal_ = args.get('useterminal', 0) - pargs = self.hexdecode(args.get('processargs', '')) + pargs = self.hexdecode(args.get('processargs', '')) self.processArgs_ = pargs.split('\0') if len(pargs) else [] self.environment_ = args.get('environment', []) self.environment_ = list(map(lambda x: self.hexdecode(x), self.environment_)) @@ -858,7 +861,7 @@ class Dumper(DumperBase): if self.workingDirectory_ == '': try: self.workingDirectory_ = os.getcwd() - except: # Could have been deleted in the mean time. + except: # Could have been deleted in the mean time. pass self.ignoreStops = 0 @@ -884,7 +887,7 @@ class Dumper(DumperBase): state = 1 if self.target.IsValid() else 0 self.reportResult('success="%s",msg="%s",exe="%s"' - % (state, error, self.executable_), args) + % (state, error, self.executable_), args) def runEngine(self, args): if self.runEngineAttempted: @@ -927,7 +930,7 @@ class Dumper(DumperBase): # better to mirror that and wait for the spontaneous stop. self.reportState('enginerunandinferiorrunok') elif self.startMode_ == DebuggerStartMode.AttachCore: - coreFile = args.get('coreFile', ''); + coreFile = args.get('coreFile', '') self.process = self.target.LoadCore(coreFile) if self.process.IsValid(): self.reportState('enginerunokandinferiorunrunnable') @@ -952,8 +955,8 @@ class Dumper(DumperBase): broadcaster.AddListener(listener, lldb.SBProcess.eBroadcastBitStateChanged) listener.StartListeningForEvents(broadcaster, lldb.SBProcess.eBroadcastBitStateChanged) broadcaster.AddListener(listener, lldb.SBTarget.eBroadcastBitBreakpointChanged) - listener.StartListeningForEvents(broadcaster, lldb.SBTarget.eBroadcastBitBreakpointChanged) - + listener.StartListeningForEvents( + broadcaster, lldb.SBTarget.eBroadcastBitBreakpointChanged) def loop(self): event = lldb.SBEvent() @@ -968,7 +971,6 @@ class Dumper(DumperBase): #if listener.WaitForEventForBroadcaster(0, broadcaster, event): # self.handleEvent(event) - def describeError(self, error): desc = lldb.SBStream() error.GetDescription(desc) @@ -1092,8 +1094,8 @@ class Dumper(DumperBase): lineNumber = interpreterFrame.get('line', 0) context = interpreterFrame.get('context', 0) result += ('frame={function="%s",file="%s",' - 'line="%s",language="%s",context="%s"}' - % (function, fileName, lineNumber, language, context)) + 'line="%s",language="%s",context="%s"}' + % (function, fileName, lineNumber, language, context)) fileName = fileNameAsString(lineEntry.file) result += '{pc="0x%x"' % pc @@ -1118,11 +1120,9 @@ class Dumper(DumperBase): # logview pane feature. self.report('token(\"%s\")' % args["token"]) - def reportBreakpointUpdate(self, bp): self.report('breakpointmodified={%s}' % self.describeBreakpoint(bp)) - def readRawMemory(self, address, size): if size == 0: return bytes() @@ -1203,7 +1203,7 @@ class Dumper(DumperBase): #else: if True: values = list(frame.GetVariables(True, True, False, True)) - values.reverse() # To get shadowed vars numbered backwards. + values.reverse() # To get shadowed vars numbered backwards. variables = [] for val in values: @@ -1225,7 +1225,7 @@ class Dumper(DumperBase): self.put('],partial="%d"' % isPartial) self.reportResult(self.output, args) - def fetchRegisters(self, args = None): + def fetchRegisters(self, args=None): if self.process is None: result = 'process="none"' else: @@ -1253,7 +1253,7 @@ class Dumper(DumperBase): self.reportResult('output="%s"' % result.GetOutput(), args) return # Try again with register write xmm0 "{0x00 ... 0x02}" syntax: - vec = ' '.join(["0x" + value[i:i+2] for i in range(2, len(value), 2)]) + vec = ' '.join(["0x" + value[i:i + 2] for i in range(2, len(value), 2)]) success = interp.HandleCommand('register write %s "{%s}"' % (name, vec), result) if success: self.reportResult('output="%s"' % result.GetOutput(), args) @@ -1295,7 +1295,6 @@ class Dumper(DumperBase): self.process.Kill() self.reportResult('', args) - def handleBreakpointEvent(self, event): eventType = lldb.SBBreakpoint.GetBreakpointEventTypeFromEvent(event) # handle only the resolved locations for now.. @@ -1304,7 +1303,6 @@ class Dumper(DumperBase): if bp is not None: self.reportBreakpointUpdate(bp) - def handleEvent(self, event): if lldb.SBBreakpoint.EventIsBreakpointEvent(event): self.handleBreakpointEvent(event) @@ -1321,16 +1319,17 @@ class Dumper(DumperBase): flavor = event.GetDataFlavor() state = lldb.SBProcess.GetStateFromEvent(event) bp = lldb.SBBreakpoint.GetBreakpointFromEvent(event) - skipEventReporting = eventType in (lldb.SBProcess.eBroadcastBitSTDOUT, lldb.SBProcess.eBroadcastBitSTDERR) + skipEventReporting = eventType in ( + lldb.SBProcess.eBroadcastBitSTDOUT, lldb.SBProcess.eBroadcastBitSTDERR) self.report('event={type="%s",data="%s",msg="%s",flavor="%s",state="%s",bp="%s"}' - % (eventType, out.GetData(), msg, flavor, self.stateName(state), bp)) + % (eventType, out.GetData(), msg, flavor, self.stateName(state), bp)) if state == lldb.eStateExited: self.eventState = state if not self.isShuttingDown_: self.reportState("inferiorexited") self.report('exited={status="%s",desc="%s"}' - % (self.process.GetExitStatus(), self.process.GetExitDescription())) + % (self.process.GetExitStatus(), self.process.GetExitDescription())) elif state != self.eventState and not skipEventReporting: self.eventState = state if state == lldb.eStateStopped: @@ -1347,7 +1346,7 @@ class Dumper(DumperBase): resolver() self.report("AUTO-CONTINUE AFTER RESOLVING") self.reportState("inferiorstopok") - self.process.Continue(); + self.process.Continue() return if functionName == "::qt_qmlDebugMessageAvailable()": self.report("ASYNC MESSAGE FROM SERVICE") @@ -1355,7 +1354,7 @@ class Dumper(DumperBase): if not res: self.report("EVENT NEEDS NO STOP") self.reportState("stopped") - self.process.Continue(); + self.process.Continue() return if self.isInterrupting_: self.isInterrupting_ = False @@ -1368,13 +1367,13 @@ class Dumper(DumperBase): else: self.reportState(self.stateName(state)) - if eventType == lldb.SBProcess.eBroadcastBitStateChanged: # 1 + if eventType == lldb.SBProcess.eBroadcastBitStateChanged: # 1 state = self.process.GetState() if state == lldb.eStateStopped: stoppedThread = self.firstStoppedThread() if stoppedThread: self.process.SetSelectedThread(stoppedThread) - elif eventType == lldb.SBProcess.eBroadcastBitInterrupt: # 2 + elif eventType == lldb.SBProcess.eBroadcastBitInterrupt: # 2 pass elif eventType == lldb.SBProcess.eBroadcastBitSTDOUT: # FIXME: Size? @@ -1391,9 +1390,9 @@ class Dumper(DumperBase): def describeBreakpoint(self, bp): isWatch = isinstance(bp, lldb.SBWatchpoint) if isWatch: - result = 'lldbid="%s"' % (qqWatchpointOffset + bp.GetID()) + result = 'lldbid="%s"' % (qqWatchpointOffset + bp.GetID()) else: - result = 'lldbid="%s"' % bp.GetID() + result = 'lldbid="%s"' % bp.GetID() result += ',valid="%s"' % (1 if bp.IsValid() else 0) result += ',hitcount="%s"' % bp.GetHitCount() if bp.IsValid(): @@ -1469,7 +1468,7 @@ class Dumper(DumperBase): value = frame.FindVariable(args['expression']) error = lldb.SBError() bp = self.target.WatchAddress(value.GetLoadAddress(), - value.GetByteSize(), False, True, error) + value.GetByteSize(), False, True, error) except: bp = self.target.BreakpointCreateByName(None) else: @@ -1528,7 +1527,7 @@ class Dumper(DumperBase): enabled = loc.IsEnabled() res = True self.reportResult('success="%s",enabled="%s",locid="%s"' - % (int(res), int(enabled), locId), args) + % (int(res), int(enabled), locId), args) def removeBreakpoint(self, args): lldbId = int(args['lldbid']) @@ -1608,7 +1607,7 @@ class Dumper(DumperBase): self.currentThread().StepInstruction(False) self.reportResult('', args) - def executeStepOut(self, args = {}): + def executeStepOut(self, args={}): self.currentThread().StepOut() self.reportResult('', args) @@ -1622,7 +1621,7 @@ class Dumper(DumperBase): if bp.GetNumLocations() == 0: self.target.BreakpointDelete(bp.GetID()) self.reportResult(self.describeStatus('No target location found.') - + self.describeLocation(frame), args) + + self.describeLocation(frame), args) return bp.SetOneShot(True) self.reportResult('', args) @@ -1647,7 +1646,7 @@ class Dumper(DumperBase): bp = self.target.BreakpointCreateByAddress(addr) else: bp = self.target.BreakpointCreateByLocation( - str(args['file']), int(args['line'])) + str(args['file']), int(args['line'])) if bp.GetNumLocations() == 0: self.target.BreakpointDelete(bp.GetID()) status = 'No target location found.' @@ -1663,7 +1662,7 @@ class Dumper(DumperBase): result = lldb.SBCommandReturnObject() self.debugger.GetCommandInterpreter().HandleCommand('break list', result) self.report('success="%d",output="%s",error="%s"' - % (result.Succeeded(), result.GetOutput(), result.GetError())) + % (result.Succeeded(), result.GetOutput(), result.GetError())) def activateFrame(self, args): self.reportToken(args) @@ -1675,7 +1674,7 @@ class Dumper(DumperBase): self.process.SetSelectedThreadByID(int(args['id'])) self.reportResult('', args) - def fetchFullBacktrace(self, _ = None): + def fetchFullBacktrace(self, _=None): command = 'thread backtrace all' result = lldb.SBCommandReturnObject() self.debugger.GetCommandInterpreter().HandleCommand(command, result) @@ -1748,7 +1747,7 @@ class Dumper(DumperBase): result += ',hunk="%s"}' % hunk result += '{address="%s"' % loadAddr result += ',data="%s %s"' % (insn.GetMnemonic(self.target), - insn.GetOperands(self.target)) + insn.GetOperands(self.target)) result += ',function="%s"' % functionName rawData = insn.GetData(self.target).uint8s result += ',rawdata="%s"' % ' '.join(["%02x" % x for x in rawData]) @@ -1854,7 +1853,7 @@ class Tester(Dumper): error = lldb.SBError() launchInfo = lldb.SBLaunchInfo([]) launchInfo.SetWorkingDirectory(os.getcwd()) - environmentList = [key + '=' + value for key,value in os.environ.items()] + environmentList = [key + '=' + value for key, value in os.environ.items()] launchInfo.SetEnvironmentEntries(environmentList, False) self.process = self.target.Launch(launchInfo, error) @@ -1868,9 +1867,9 @@ class Tester(Dumper): if listener.WaitForEvent(100, event): #DumperBase.warn('EVENT: %s' % event) state = lldb.SBProcess.GetStateFromEvent(event) - if state == lldb.eStateExited: # 10 + if state == lldb.eStateExited: # 10 break - if state == lldb.eStateStopped: # 5 + if state == lldb.eStateStopped: # 5 stoppedThread = None for i in range(0, self.process.GetNumThreads()): thread = self.process.GetThreadAtIndex(i) @@ -1904,14 +1903,16 @@ class Tester(Dumper): # ------------------------------ For use in LLDB ------------------------------ + from pprint import pprint __module__ = sys.modules[__name__] DEBUG = False if not hasattr(__module__, 'DEBUG') else DEBUG -class LogMixin: + +class LogMixin(): @staticmethod - def log(message = '', log_caller = False, frame = 1, args = ''): + def log(message='', log_caller=False, frame=1, args=''): if not DEBUG: return if log_caller: @@ -1925,13 +1926,15 @@ class LogMixin: print(message) @staticmethod - def log_fn(arg_str = ''): - LogMixin.log(log_caller = True, frame = 2, args = arg_str) + def log_fn(arg_str=''): + LogMixin.log(log_caller=True, frame=2, args=arg_str) + class DummyDebugger(object): def __getattr__(self, attr): raise AttributeError("Debugger should not be needed to create summaries") + class SummaryDumper(Dumper, LogMixin): _instance = None _lock = threading.RLock() @@ -1971,9 +1974,9 @@ class SummaryDumper(Dumper, LogMixin): Dumper.__init__(self, DummyDebugger()) self.setVariableFetchingOptions({ - 'fancy' : True, - 'qobjectnames' : True, - 'passexceptions' : True + 'fancy': True, + 'qobjectnames': True, + 'passexceptions': True }) self.dumpermodules = ['qttypes'] @@ -1981,19 +1984,19 @@ class SummaryDumper(Dumper, LogMixin): self.output = '' def report(self, stuff): - return # Don't mess up lldb output + return # Don't mess up lldb output def lookupNativeTypeInAllModules(self, name): self.warn('Failed to resolve type %s' % name) return None - def dump_summary(self, valobj, expanded = False): + def dump_summary(self, valobj, expanded=False): try: from pygdbmi import gdbmiparser except ImportError: print("Qt summary provider requires the pygdbmi module, " - "please install using 'sudo /usr/bin/easy_install pygdbmi', " - "and then restart Xcode.") + "please install using 'sudo /usr/bin/easy_install pygdbmi', " + "and then restart Xcode.") lldb.debugger.HandleCommand('type category delete Qt') return None @@ -2021,14 +2024,15 @@ class SummaryDumper(Dumper, LogMixin): return summary + class SummaryProvider(LogMixin): DEFAULT_SUMMARY = '' VOID_PTR_TYPE = None @staticmethod - def provide_summary(valobj, internal_dict, options = None): - if not __name__ in internal_dict: + def provide_summary(valobj, internal_dict, options=None): + if __name__ not in internal_dict: # When disabling the import of the Qt summary providers, the # summary functions are still registered with LLDB, and we will # get callbacks to provide summaries, but at this point the child @@ -2048,7 +2052,7 @@ class SummaryProvider(LogMixin): return provider.get_summary(options) - def __init__(self, valobj, expand = False): + def __init__(self, valobj, expand=False): # Prevent recursive evaluation during logging, etc valobj.SetPreferSyntheticValue(False) @@ -2088,29 +2092,29 @@ class SummaryProvider(LogMixin): if encoding: special_encodings = { - "empty" : "", - "minimumitemcount" : "" % summaryValue, - "undefined" : "", - "null" : "", - "itemcount" : "<%s items>" % summaryValue, - "notaccessible" : "", - "optimizedout" : "", - "nullreference" : "", - "emptystructure" : "", - "uninitialized" : "", - "invalid" : "", - "notcallable" : "", - "outofscope" : "" + "empty": "", + "minimumitemcount": "" % summaryValue, + "undefined": "", + "null": "", + "itemcount": "<%s items>" % summaryValue, + "notaccessible": "", + "optimizedout": "", + "nullreference": "", + "emptystructure": "", + "uninitialized": "", + "invalid": "", + "notcallable": "", + "outofscope": "" } if encoding in special_encodings: return special_encodings[encoding] text_encodings = [ 'latin1', - # 'local8bit', + # 'local8bit', 'utf8', 'utf16', - # 'ucs4' + # 'ucs4' ] if encoding in text_encodings: @@ -2122,8 +2126,15 @@ class SummaryProvider(LogMixin): return "" % (summaryValue, encoding) # FIXME: Support these - other_encodings = ['int', 'uint', 'float', 'juliandate', 'juliandateandmillisecondssincemidnight', - 'millisecondssincemidnight', 'ipv6addressandhexscopeid', 'datetimeinternal'] + other_encodings = [ + 'int', + 'uint', + 'float', + 'juliandate', + 'juliandateandmillisecondssincemidnight', + 'millisecondssincemidnight', + 'ipv6addressandhexscopeid', + 'datetimeinternal'] summaryValue += " " % encoding @@ -2136,9 +2147,10 @@ class SummaryProvider(LogMixin): return summaryValue.strip() + class SyntheticChildrenProvider(SummaryProvider): def __init__(self, valobj, dict): - SummaryProvider.__init__(self, valobj, expand = True) + SummaryProvider.__init__(self, valobj, expand=True) self.summary = None self.synthetic_children = [] @@ -2147,7 +2159,7 @@ class SyntheticChildrenProvider(SummaryProvider): def num_children(self): self.log("native: %d synthetic: %d" % - (self.num_native_children(), len(self.synthetic_children)), True) + (self.num_native_children(), len(self.synthetic_children)), True) return self._num_children() def _num_children(self): @@ -2181,7 +2193,7 @@ class SyntheticChildrenProvider(SummaryProvider): return value - def create_value(self, child, name = ''): + def create_value(self, child, name=''): child_type = child.get('type', self.summary.get('childtype')) value = None @@ -2196,8 +2208,8 @@ class SyntheticChildrenProvider(SummaryProvider): # Create as void* so that the value is fully initialized before # we trigger our own summary/child providers recursively. - value = self.valobj.synthetic_child_from_address(name, address, - SummaryProvider.VOID_PTR_TYPE).Cast(value_type) + value = self.valobj.synthetic_child_from_address( + name, address, SummaryProvider.VOID_PTR_TYPE).Cast(value_type) else: self.log("Don't know how to create value for child %s" % child) # FIXME: Figure out if we ever will hit this case, and deal with it @@ -2219,7 +2231,7 @@ class SyntheticChildrenProvider(SummaryProvider): dereference_child = None for child in self.summary['children']: - if not child or not type(child) is dict: + if not child or not isinstance(child, dict): continue # Skip base classes, they are built-in children @@ -2254,8 +2266,9 @@ class SyntheticChildrenProvider(SummaryProvider): # the debugger UI, even if dereferencing the pointer works fine. # We fall back to the special child reported by the Qt dumper. if not self.valobj.GetNumChildren() and dereference_child: - self.valobj = self.create_value(dereference_child) - self.update() + self.valobj = self.create_value(dereference_child) + self.update() + def __lldb_init_module(debugger, internal_dict): # Module is being imported in an LLDB session @@ -2266,25 +2279,25 @@ def __lldb_init_module(debugger, internal_dict): # Concrete types summary_function = "%s.%s.%s" % (__name__, 'SummaryProvider', 'provide_summary') types = map(lambda x: x.replace('__', '::'), dumper.qqDumpers) - debugger.HandleCommand("type summary add -F %s -w %s %s" \ - % (summary_function, type_category, ' '.join(types))) + debugger.HandleCommand("type summary add -F %s -w %s %s" + % (summary_function, type_category, ' '.join(types))) regex_types = list(map(lambda x: "'" + x + "'", dumper.qqDumpersEx.keys())) if regex_types: - debugger.HandleCommand("type summary add -x -F %s -w %s %s" \ - % (summary_function, type_category, ' '.join(regex_types))) + debugger.HandleCommand("type summary add -x -F %s -w %s %s" + % (summary_function, type_category, ' '.join(regex_types))) # Global catch-all for Qt classes - debugger.HandleCommand("type summary add -x '^Q.*$' -F %s -w %s" \ - % (summary_function, type_category)) + debugger.HandleCommand("type summary add -x '^Q.*$' -F %s -w %s" + % (summary_function, type_category)) # Named summary ('frame variable foo --summary Qt') - debugger.HandleCommand("type summary add --name Qt -F %s -w %s" \ - % (summary_function, type_category)) + debugger.HandleCommand("type summary add --name Qt -F %s -w %s" + % (summary_function, type_category)) # Synthetic children - debugger.HandleCommand("type synthetic add -x '^Q.*$' -l %s -w %s" \ - % ("lldbbridge.SyntheticChildrenProvider", type_category)) + debugger.HandleCommand("type synthetic add -x '^Q.*$' -l %s -w %s" + % ("lldbbridge.SyntheticChildrenProvider", type_category)) debugger.HandleCommand('type category enable %s' % type_category) diff --git a/share/qtcreator/debugger/misctypes.py b/share/qtcreator/debugger/misctypes.py index 9889e5ca97b..7ce5739cc43 100644 --- a/share/qtcreator/debugger/misctypes.py +++ b/share/qtcreator/debugger/misctypes.py @@ -33,39 +33,46 @@ import re # ####################################################################### + def qdump____m128(d, value): d.putEmptyValue() if d.isExpanded(): d.putArrayData(value.address(), 4, d.lookupType('float')) + def qdump____m256(d, value): d.putEmptyValue() if d.isExpanded(): d.putArrayData(value.address(), 8, d.lookupType('float')) + def qdump____m512(d, value): d.putEmptyValue() if d.isExpanded(): d.putArrayData(value.address(), 16, d.lookupType('float')) + def qdump____m128d(d, value): d.putEmptyValue() if d.isExpanded(): d.putArrayData(value.address(), 2, d.lookupType('double')) + def qdump____m256d(d, value): d.putEmptyValue() if d.isExpanded(): d.putArrayData(value.address(), 4, d.lookupType('double')) + def qdump____m512d(d, value): d.putEmptyValue() if d.isExpanded(): d.putArrayData(value.address(), 8, d.lookupType('double')) + def qdump____m128i(d, value): data = d.hexencode(value.data(16)) - d.putValue(':'.join('%04x' % int(data[i:i+4], 16) for i in range(0, 32, 4))) + d.putValue(':'.join('%04x' % int(data[i:i + 4], 16) for i in range(0, 32, 4))) if d.isExpanded(): with Children(d): addr = value.address() @@ -74,9 +81,10 @@ def qdump____m128i(d, value): d.putArrayItem('uint32x4', addr, 4, 'unsigned int') d.putArrayItem('uint64x2', addr, 2, 'unsigned long long') + def qdump____m256i(d, value): data = d.hexencode(value.data(32)) - d.putValue(':'.join('%04x' % int(data[i:i+4], 16) for i in range(0, 64, 4))) + d.putValue(':'.join('%04x' % int(data[i:i + 4], 16) for i in range(0, 64, 4))) if d.isExpanded(): with Children(d): addr = value.address() @@ -85,10 +93,11 @@ def qdump____m256i(d, value): d.putArrayItem('uint32x8', addr, 8, 'unsigned int') d.putArrayItem('uint64x4', addr, 4, 'unsigned long long') + def qdump____m512i(d, value): data = d.hexencode(value.data(64)) - d.putValue(':'.join('%04x' % int(data[i:i+4], 16) for i in range(0, 64, 4)) - + ', ' + ':'.join('%04x' % int(data[i:i+4], 16) for i in range(64, 128, 4))) + d.putValue(':'.join('%04x' % int(data[i:i + 4], 16) for i in range(0, 64, 4)) + + ', ' + ':'.join('%04x' % int(data[i:i + 4], 16) for i in range(64, 128, 4))) if d.isExpanded(): with Children(d): d.putArrayItem('uint32x16', value.address(), 16, 'unsigned int') @@ -100,8 +109,10 @@ def qdump____m512i(d, value): # ####################################################################### + def qform__std__array(): - return [DisplayFormat.ArrayPlotFormat] + return [DisplayFormat.ArrayPlot] + def qdump__gsl__span(d, value): size, pointer = value.split('pp') @@ -109,6 +120,7 @@ def qdump__gsl__span(d, value): if d.isExpanded(): d.putPlotData(pointer, size, value.type[0]) + def qdump__gsl__byte(d, value): d.putNumChild(0) d.putValue(value.integer()) @@ -122,6 +134,7 @@ def qdump__gsl__byte(d, value): #def qform__Eigen__Matrix(): # return 'Transposed' + def qdump__Eigen__Matrix(d, value): innerType = value.type[0] argRow = value.type[1] @@ -185,9 +198,10 @@ def qdump__NimStringDesc(d, value): d.putBetterType('string') d.putCharArrayHelper(data, size, d.createType('char'), 'utf8') -def qdump__NimGenericSequence__(d, value, regex = '^TY[\d]+$'): + +def qdump__NimGenericSequence__(d, value, regex=r'^TY[\d]+$'): code = value.type.stripTypedefs().code - if code == TypeCode.TypeCodeStruct: + if code == TypeCode.Struct: size, reserved = d.split('pp', value) data = value.address() + 2 * d.ptrSize() typeobj = value['data'].type.dereference() @@ -198,6 +212,7 @@ def qdump__NimGenericSequence__(d, value, regex = '^TY[\d]+$'): d.putEmptyValue() d.putPlainChildren(value) + def qdump__TNimNode(d, value): name = value['name'].pointer() d.putSimpleCharArray(name) if name != 0 else d.putEmptyValue() @@ -222,6 +237,7 @@ def qdump__TNimNode(d, value): def cleanDType(type): return str(type).replace('uns long long', 'string') + def qdump_Array(d, value): n = value['length'] p = value['ptr'] @@ -251,7 +267,7 @@ def qdump_AArray(d, value): d.putEmptyValue() if d.isExpanded(): with Children(d, 1): - d.putSubItem('ptr', p) + d.putSubItem('ptr', p) ####################################################################### @@ -264,7 +280,7 @@ if False: def qdump__tree_entry(d, value): d.putValue('len: %s, offset: %s, type: %s' % - (value['blocklength'], value['offset'], value['type'])) + (value['blocklength'], value['offset'], value['type'])) d.putNumChild(0) def qdump__tree(d, value): @@ -273,42 +289,42 @@ if False: base = value['base'].pointer() d.putItemCount(count) if d.isExpanded(): - with Children(d): - with SubItem(d, 'tree'): - d.putEmptyValue() - d.putNoType() - if d.isExpanded(): - with Children(d): - for i in range(count): - d.putSubItem(Item(entries[i], iname)) - with SubItem(d, 'data'): - d.putEmptyValue() - d.putNoType() - if d.isExpanded(): - with Children(d): - for i in range(count): - with SubItem(d, i): - entry = entries[i] - mpitype = str(entry['type']) - d.putType(mpitype) - length = int(entry['blocklength']) - offset = int(entry['offset']) - d.putValue('%s items at %s' % (length, offset)) - if mpitype == 'MPI_INT': - innerType = 'int' - elif mpitype == 'MPI_CHAR': - innerType = 'char' - elif mpitype == 'MPI_DOUBLE': - innerType = 'double' - else: - length = 0 - d.putNumChild(length) - if d.isExpanded(): - with Children(d): - t = d.lookupType(innerType).pointer() - p = (base + offset).cast(t) - for j in range(length): - d.putSubItem(j, p.dereference()) + with Children(d): + with SubItem(d, 'tree'): + d.putEmptyValue() + d.putNoType() + if d.isExpanded(): + with Children(d): + for i in range(count): + d.putSubItem(Item(entries[i], iname)) + with SubItem(d, 'data'): + d.putEmptyValue() + d.putNoType() + if d.isExpanded(): + with Children(d): + for i in range(count): + with SubItem(d, i): + entry = entries[i] + mpitype = str(entry['type']) + d.putType(mpitype) + length = int(entry['blocklength']) + offset = int(entry['offset']) + d.putValue('%s items at %s' % (length, offset)) + if mpitype == 'MPI_INT': + innerType = 'int' + elif mpitype == 'MPI_CHAR': + innerType = 'char' + elif mpitype == 'MPI_DOUBLE': + innerType = 'double' + else: + length = 0 + d.putNumChild(length) + if d.isExpanded(): + with Children(d): + t = d.lookupType(innerType).pointer() + p = (base + offset).cast(t) + for j in range(length): + d.putSubItem(j, p.dereference()) ####################################################################### @@ -322,6 +338,7 @@ def qdump__KDSoapValue1(d, value): d.putStringValue(inner['m_name']) d.putPlainChildren(inner) + def qdump__KDSoapValue(d, value): p = (value.cast(d.lookupType('char*')) + 4).dereference().cast(d.lookupType('QString')) d.putStringValue(p) @@ -528,6 +545,7 @@ def qdump__PyVarObject(d, value): def qdump__QtcDumperTest_FieldAccessByIndex(d, value): d.putValue(value["d"][2].integer()) + def qdump__QtcDumperTest_PointerArray(d, value): foos = value["foos"] d.putItemCount(10) @@ -536,6 +554,7 @@ def qdump__QtcDumperTest_PointerArray(d, value): for i in d.childRange(): d.putSubItem(i, foos[i]) + def qdump__QtcDumperTest_BufArray(d, value): maxItems = 1000 buffer = value['buffer'] @@ -549,11 +568,12 @@ def qdump__QtcDumperTest_BufArray(d, value): for i in d.childRange(): d.putSubItem(i, (buffer + (i * objsize)).dereference().cast(valueType)) + def qdump__QtcDumperTest_List__NodeX(d, value): typename = value.type.unqualified().name pos0 = typename.find('<') pos1 = typename.find('>') - tName = typename[pos0+1:pos1] + tName = typename[pos0 + 1:pos1] d.putBetterType('QtcDumperTest_List<' + tName + '>::Node') d.putNumChild(1) if d.isExpanded(): @@ -563,6 +583,7 @@ def qdump__QtcDumperTest_List__NodeX(d, value): d.putFields(value) #d.putPlainChildren(value) + def qdump__QtcDumperTest_List(d, value): innerType = value.type[0] d.putNumChild(1) @@ -574,6 +595,7 @@ def qdump__QtcDumperTest_List(d, value): d.putFields(value) #d.putPlainChildren(value) + def qdump__QtcDumperTest_String(d, value): with Children(d): first = d.hexdecode(d.putSubItem('first', value['first']).value) diff --git a/share/qtcreator/debugger/opencvtypes.py b/share/qtcreator/debugger/opencvtypes.py index 7a62af7041f..1f74476a742 100644 --- a/share/qtcreator/debugger/opencvtypes.py +++ b/share/qtcreator/debugger/opencvtypes.py @@ -26,16 +26,19 @@ from dumper import Children, SubItem from utils import TypeCode, DisplayFormat + def qdump__cv__Size_(d, value): d.putValue('(%s, %s)' % (value[0].display(), value[1].display())) d.putPlainChildren(value) + def qform__cv__Mat(): - return [DisplayFormat.SeparateFormat] + return [DisplayFormat.Separate] + def qdump__cv__Mat(d, value): (flag, dims, rows, cols, data, refcount, datastart, dataend, - datalimit, allocator, size, stepp) \ + datalimit, allocator, size, stepp) \ = value.split('iiiipppppppp') steps = d.split('p' * dims, stepp) innerSize = 0 if dims == 0 else steps[dims - 1] @@ -44,7 +47,7 @@ def qdump__cv__Mat(d, value): d.putPlainChildren(value) return - if d.currentItemFormat() == DisplayFormat.SeparateFormat: + if d.currentItemFormat() == DisplayFormat.Separate: rs = steps[0] * innerSize cs = cols * innerSize dform = 'arraydata:separate:int:%d::2:%d:%d' % (innerSize, cols, rows) @@ -54,7 +57,7 @@ def qdump__cv__Mat(d, value): d.putValue('(%s x %s)' % (rows, cols)) if d.isExpanded(): with Children(d): - innerType = d.createType(TypeCode.TypeCodeIntegral, innerSize) + innerType = d.createType(TypeCode.Integral, innerSize) for i in range(rows): for j in range(cols): with SubItem(d, None): diff --git a/share/qtcreator/debugger/pdbbridge.py b/share/qtcreator/debugger/pdbbridge.py index 4c77d41ce5b..463e8a97ff6 100644 --- a/share/qtcreator/debugger/pdbbridge.py +++ b/share/qtcreator/debugger/pdbbridge.py @@ -41,7 +41,7 @@ class QuitException(Exception): pass -class QtcInternalBreakpoint: +class QtcInternalBreakpoint(): """Breakpoint class. Breakpoints are indexed by number through bpbynumber and by the file,line tuple using bplist. The former points to a @@ -52,9 +52,9 @@ class QtcInternalBreakpoint: next = 1 # Next bp to be assigned bplist = {} # indexed by (file, lineno) tuple - bpbynumber = [None] # Each entry is None or an instance of Bpt - # index 0 is unused, except for marking an - # effective break .... see effective() + bpbynumber = [None] # Each entry is None or an instance of Bpt + # index 0 is unused, except for marking an + # effective break .... see effective() def __init__(self, filepath, line, temporary=False, cond=None, funcname=None): self.funcname = funcname @@ -115,7 +115,7 @@ def checkfuncname(b, frame): # The function is entered for the 1st time. b.func_first_executable_line = frame.f_lineno - if b.func_first_executable_line != frame.f_lineno: + if b.func_first_executable_line != frame.f_lineno: # But we are not at the first line number: don't break. return False return True @@ -193,7 +193,7 @@ class _rstr(str): return self -class QtcInternalDumper: +class QtcInternalDumper(): identchars = string.ascii_letters + string.digits + '_' lastcmd = '' use_rawinput = 1 @@ -387,7 +387,7 @@ class QtcInternalDumper: # (CT) stopframe may now also be None, see dispatch_call. # (CT) the former test for None is therefore removed from here. if self.skip and \ - self.is_skipped_module(frame.f_globals.get('__name__')): + self.is_skipped_module(frame.f_globals.get('__name__')): return False if frame is self.stopframe: if self.stoplineno == -1: @@ -696,7 +696,7 @@ class QtcInternalDumper: return None, None, line i, length = 0, len(line) while i < length and line[i] in self.identchars: - i = i+1 + i = i + 1 cmd, arg = line[:i], line[i:].strip() return cmd, arg, line @@ -745,10 +745,10 @@ class QtcInternalDumper: import __main__ # __main__.__dict__.clear() - __main__.__dict__.update({'__name__' : '__main__', - '__file__' : mainpyfile, - # '__builtins__': __builtins__, - }) + __main__.__dict__.update({'__name__': '__main__', + '__file__': mainpyfile, + #'__builtins__': __builtins__, + }) # When bdb sets tracing, a number of call and line events happens # BEFORE debugger even reaches user's code (and the exact sequence of @@ -966,7 +966,7 @@ class QtcInternalDumper: comma = arg.find(',') if comma > 0: # parse stuff after comma: 'condition' - cond = arg[comma+1:].lstrip() + cond = arg[comma + 1:].lstrip() arg = arg[:comma].rstrip() # parse stuff before comma: [filename:]lineno | function colon = arg.rfind(':') @@ -979,7 +979,7 @@ class QtcInternalDumper: return else: filename = f - arg = arg[colon+1:].lstrip() + arg = arg[colon + 1:].lstrip() try: lineno = int(arg) except ValueError: @@ -1212,7 +1212,7 @@ class QtcInternalDumper: # Make sure it works for 'clear C:\foo\bar.py:12' i = arg.rfind(':') filename = arg[:i] - arg = arg[i+1:] + arg = arg[i + 1:] try: lineno = int(arg) except ValueError: diff --git a/share/qtcreator/debugger/qttypes.py b/share/qtcreator/debugger/qttypes.py index 34d592ede7a..f28abcd8edb 100644 --- a/share/qtcreator/debugger/qttypes.py +++ b/share/qtcreator/debugger/qttypes.py @@ -28,6 +28,7 @@ import re from dumper import Children, SubItem, UnnamedSubItem, toInteger from utils import DisplayFormat + def qdump__QAtomicInt(d, value): d.putValue(value.integer()) d.putNumChild(0) @@ -44,33 +45,36 @@ def qdump__QAtomicPointer(d, value): def qform__QByteArray(): - return [DisplayFormat.Latin1StringFormat, DisplayFormat.SeparateLatin1StringFormat, - DisplayFormat.Utf8StringFormat, DisplayFormat.SeparateUtf8StringFormat ] + return [DisplayFormat.Latin1String, DisplayFormat.SeparateLatin1String, + DisplayFormat.Utf8String, DisplayFormat.SeparateUtf8String] + def qedit__QByteArray(d, value, data): d.call('void', value, 'resize', str(len(data))) (base, size, alloc) = d.stringData(value) d.setValues(base, 'char', [ord(c) for c in data]) + def qdump__QByteArray(d, value): data, size, alloc = d.byteArrayData(value) d.check(alloc == 0 or (0 <= size and size <= alloc and alloc <= 100000000)) d.putNumChild(size) elided, p = d.encodeByteArrayHelper(d.extractPointer(value), d.displayStringLimit) displayFormat = d.currentItemFormat() - if displayFormat == DisplayFormat.AutomaticFormat or displayFormat == DisplayFormat.Latin1StringFormat: + if displayFormat == DisplayFormat.Automatic or displayFormat == DisplayFormat.Latin1String: d.putValue(p, 'latin1', elided=elided) - elif displayFormat == DisplayFormat.SeparateLatin1StringFormat: + elif displayFormat == DisplayFormat.SeparateLatin1String: d.putValue(p, 'latin1', elided=elided) d.putDisplay('latin1:separate', d.encodeByteArray(value, limit=100000)) - elif displayFormat == DisplayFormat.Utf8StringFormat: + elif displayFormat == DisplayFormat.Utf8String: d.putValue(p, 'utf8', elided=elided) - elif displayFormat == DisplayFormat.SeparateUtf8StringFormat: + elif displayFormat == DisplayFormat.SeparateUtf8String: d.putValue(p, 'utf8', elided=elided) d.putDisplay('utf8:separate', d.encodeByteArray(value, limit=100000)) if d.isExpanded(): d.putArrayData(data, size, d.charType()) + def qdump__QArrayData(d, value): data, size, alloc = d.byteArrayDataHelper(value.address()) d.check(alloc == 0 or (0 <= size and size <= alloc and alloc <= 100000000)) @@ -78,6 +82,7 @@ def qdump__QArrayData(d, value): d.putNumChild(1) d.putPlainChildren(value) + def qdump__QByteArrayData(d, value): qdump__QArrayData(d, value) @@ -103,14 +108,15 @@ def qdump__QChar(d, value): def qform_X_QAbstractItemModel(): - return [DisplayFormat.SimpleFormat, DisplayFormat.EnhancedFormat] + return [DisplayFormat.Simple, DisplayFormat.Enhanced] + def qdump_X_QAbstractItemModel(d, value): displayFormat = d.currentItemFormat() - if displayFormat == DisplayFormat.SimpleFormat: + if displayFormat == DisplayFormat.Simple: d.putPlainChildren(value) return - #displayFormat == EnhancedFormat: + #displayFormat == Enhanced: # Create a default-constructed QModelIndex on the stack. try: ri = d.pokeValue(d.qtNamespace() + 'QModelIndex', '-1, -1, 0, 0') @@ -131,17 +137,19 @@ def qdump_X_QAbstractItemModel(d, value): with SubItem(d, i): d.putName('[%s, %s]' % (row, column)) mi = d.parseAndEvaluate('%s.index(%d,%d,%s)' - % (this_, row, column, ri_)) + % (this_, row, column, ri_)) d.putItem(mi) i = i + 1 #gdb.execute('call free($ri)') + def qform_X_QModelIndex(): - return [DisplayFormat.SimpleFormat, DisplayFormat.EnhancedFormat] + return [DisplayFormat.Simple, DisplayFormat.Enhanced] + def qdump_X_QModelIndex(d, value): displayFormat = d.currentItemFormat() - if displayFormat == DisplayFormat.SimpleFormat: + if displayFormat == DisplayFormat.Simple: d.putPlainChildren(value) return r = value['r'] @@ -187,44 +195,47 @@ def qdump_X_QModelIndex(d, value): with UnnamedSubItem(d, i): d.putName('[%s, %s]' % (row, column)) mi2 = d.parseAndEvaluate('%s.index(%d,%d,%s)' - % (mm_, row, column, mi_)) + % (mm_, row, column, mi_)) d.putItem(mi2) i = i + 1 d.putCallItem('parent', '@QModelIndex', value, 'parent') #gdb.execute('call free($mi)') + def qdump__Qt__ItemDataRole(d, value): d.putEnumValue(value.integer(), { - 0 : "Qt::DisplayRole", - 1 : "Qt::DecorationRole", - 2 : "Qt::EditRole", - 3 : "Qt::ToolTipRole", - 4 : "Qt::StatusTipRole", - 5 : "Qt::WhatsThisRole", - 6 : "Qt::FontRole", - 7 : "Qt::TextAlignmentRole", + 0: "Qt::DisplayRole", + 1: "Qt::DecorationRole", + 2: "Qt::EditRole", + 3: "Qt::ToolTipRole", + 4: "Qt::StatusTipRole", + 5: "Qt::WhatsThisRole", + 6: "Qt::FontRole", + 7: "Qt::TextAlignmentRole", # obsolete: 8 : "Qt::BackgroundColorRole", - 8 : "Qt::BackgroundRole", + 8: "Qt::BackgroundRole", # obsolete: 9 : "Qt::TextColorRole", - 9 : "Qt::ForegroundRole", - 10 : "Qt::CheckStateRole", - 11 : "Qt::AccessibleTextRole", - 12 : "Qt::AccessibleDescriptionRole", - 13 : "Qt::SizeHintRole", - 14 : "Qt::InitialSortOrderRole", + 9: "Qt::ForegroundRole", + 10: "Qt::CheckStateRole", + 11: "Qt::AccessibleTextRole", + 12: "Qt::AccessibleDescriptionRole", + 13: "Qt::SizeHintRole", + 14: "Qt::InitialSortOrderRole", # 27-31 Qt4 ItemDataRoles - 27 : "Qt::DisplayPropertyRole", - 28 : "Qt::DecorationPropertyRole", - 29 : "Qt::ToolTipPropertyRole", - 30 : "Qt::StatusTipPropertyRole", - 31 : "Qt::WhatsThisPropertyRole", - 0x100 : "Qt::UserRole" + 27: "Qt::DisplayPropertyRole", + 28: "Qt::DecorationPropertyRole", + 29: "Qt::ToolTipPropertyRole", + 30: "Qt::StatusTipPropertyRole", + 31: "Qt::WhatsThisPropertyRole", + 0x100: "Qt::UserRole" }) + def qdump__QStandardItemData(d, value): role, pad, val = value.split('{@Qt::ItemDataRole}@{QVariant}') d.putPairContents(role.value(), (role, val), 'role', 'value') + def qdump__QStandardItem(d, value): vtable, dptr = value.split('pp') # There used to be a virtual destructor that got removed in @@ -240,7 +251,7 @@ def qdump__QStandardItem(d, value): d.putSubItem('[model]', d.createValue(model, '@QStandardItemModel')) d.putSubItem('[values]', d.createVectorItem(values, '@QStandardItemData')) d.putSubItem('[children]', d.createVectorItem(children, - d.createPointerType(value.type))) + d.createPointerType(value.type))) def qdump__QDate(d, value): @@ -252,13 +263,13 @@ def qdump__QDate(d, value): with Children(d): if d.canCallLocale(): d.putCallItem('toString', '@QString', value, 'toString', - d.enumExpression('DateFormat', 'TextDate')) + d.enumExpression('DateFormat', 'TextDate')) d.putCallItem('(ISO)', '@QString', value, 'toString', - d.enumExpression('DateFormat', 'ISODate')) + d.enumExpression('DateFormat', 'ISODate')) d.putCallItem('(SystemLocale)', '@QString', value, 'toString', - d.enumExpression('DateFormat', 'SystemLocaleDate')) + d.enumExpression('DateFormat', 'SystemLocaleDate')) d.putCallItem('(Locale)', '@QString', value, 'toString', - d.enumExpression('DateFormat', 'LocaleDate')) + d.enumExpression('DateFormat', 'LocaleDate')) d.putFields(value) else: d.putValue('(invalid)') @@ -275,14 +286,14 @@ def qdump__QTime(d, value): if d.isExpanded(): with Children(d): d.putCallItem('toString', '@QString', value, 'toString', - d.enumExpression('DateFormat', 'TextDate')) + d.enumExpression('DateFormat', 'TextDate')) d.putCallItem('(ISO)', '@QString', value, 'toString', - d.enumExpression('DateFormat', 'ISODate')) + d.enumExpression('DateFormat', 'ISODate')) if d.canCallLocale(): d.putCallItem('(SystemLocale)', '@QString', value, 'toString', - d.enumExpression('DateFormat', 'SystemLocaleDate')) + d.enumExpression('DateFormat', 'SystemLocaleDate')) d.putCallItem('(Locale)', '@QString', value, 'toString', - d.enumExpression('DateFormat', 'LocaleDate')) + d.enumExpression('DateFormat', 'LocaleDate')) d.putFields(value) @@ -292,7 +303,7 @@ def qdump__QTimeZone(d, value): d.putValue('(null)') d.putNumChild(0) return - idAddr = base + 2 * d.ptrSize() # [QSharedData] + [vptr] + idAddr = base + 2 * d.ptrSize() # [QSharedData] + [vptr] d.putByteArrayValue(idAddr) d.putPlainChildren(value['d']) @@ -325,7 +336,14 @@ def qdump__QDateTime(d, value): spec = (status & 0x30) >> 4 isValid = True - d.putValue('%s/%s/%s/%s/%s/%s' % (msecs, spec, offsetFromUtc, timeZone, status, tiVersion), + d.putValue( + '%s/%s/%s/%s/%s/%s' % + (msecs, + spec, + offsetFromUtc, + timeZone, + status, + tiVersion), 'datetimeinternal') else: if d.isWindowsTarget(): @@ -341,7 +359,7 @@ def qdump__QDateTime(d, value): timeZoneOffset = 20 if is32bit else 24 statusOffset = 24 if is32bit else 32 status = d.extractInt(base + statusOffset) - if int(status & 0x0c == 0x0c): # ValidDate and ValidTime + if int(status & 0x0c == 0x0c): # ValidDate and ValidTime isValid = True msecs = d.extractInt64(base + msecsOffset) spec = d.extractInt(base + specOffset) @@ -350,10 +368,10 @@ def qdump__QDateTime(d, value): if tzp == 0: tz = '' else: - idBase = tzp + 2 * d.ptrSize() # [QSharedData] + [vptr] + idBase = tzp + 2 * d.ptrSize() # [QSharedData] + [vptr] elided, tz = d.encodeByteArrayHelper(d.extractPointer(idBase), limit=100) d.putValue('%s/%s/%s/%s/%s/%s' % (msecs, spec, offset, tz, status, 0), - 'datetimeinternal') + 'datetimeinternal') else: # This relies on the Qt4/Qt5 internal structure layout: # {sharedref(4), date(8), time(4+x)} @@ -364,7 +382,7 @@ def qdump__QDateTime(d, value): # - [QTime time;] # - - uint mds; # - Spec spec; - dateSize = 8 if qtVersion >= 0x050000 else 4 # Qt5: qint64, Qt4 uint + dateSize = 8 if qtVersion >= 0x050000 else 4 # Qt5: qint64, Qt4 uint # 4 byte padding after 4 byte QAtomicInt if we are on 64 bit and QDate is 64 bit refPlusPadding = 8 if qtVersion >= 0x050000 and d.ptrSize() == 8 else 4 dateBase = base + refPlusPadding @@ -386,17 +404,17 @@ def qdump__QDateTime(d, value): d.putCallItem('toTime_t', 'unsigned int', value, 'toTime_t') if d.canCallLocale(): d.putCallItem('toString', '@QString', value, 'toString', - d.enumExpression('DateFormat', 'TextDate')) + d.enumExpression('DateFormat', 'TextDate')) d.putCallItem('(ISO)', '@QString', value, 'toString', - d.enumExpression('DateFormat', 'ISODate')) + d.enumExpression('DateFormat', 'ISODate')) d.putCallItem('toUTC', '@QDateTime', value, 'toTimeSpec', - d.enumExpression('TimeSpec', 'UTC')) + d.enumExpression('TimeSpec', 'UTC')) d.putCallItem('(SystemLocale)', '@QString', value, 'toString', - d.enumExpression('DateFormat', 'SystemLocaleDate')) + d.enumExpression('DateFormat', 'SystemLocaleDate')) d.putCallItem('(Locale)', '@QString', value, 'toString', - d.enumExpression('DateFormat', 'LocaleDate')) + d.enumExpression('DateFormat', 'LocaleDate')) d.putCallItem('toLocalTime', '@QDateTime', value, 'toTimeSpec', - d.enumExpression('TimeSpec', 'LocalTime')) + d.enumExpression('TimeSpec', 'LocalTime')) d.putFields(value) @@ -507,6 +525,7 @@ def qdump__QEvent(d, value): # Show the rest of the class fields as usual. d.putFields(value) + def qdump__QKeyEvent(d, value): # QEvent fields # virtual table pointer @@ -611,7 +630,7 @@ def qdump__QFile(d, value): if d.isMsvcTarget(): offset = 164 if is32bit else 224 else: - offset = 160 if is32bit else 224 + offset = 160 if is32bit else 224 else: offset = 156 if is32bit else 224 elif qtVersion >= 0x050700: @@ -752,12 +771,13 @@ def qdump__QFileInfo(d, value): def qdump__QFixed(d, value): v = value.split('i')[0] - d.putValue('%s/64 = %s' % (v, v/64.0)) + d.putValue('%s/64 = %s' % (v, v / 64.0)) d.putNumChild(0) def qform__QFiniteStack(): - return [DisplayFormat.ArrayPlotFormat] + return [DisplayFormat.ArrayPlot] + def qdump__QFiniteStack(d, value): array, alloc, size = value.split('pii') @@ -775,14 +795,17 @@ def qdump__QFlags(d, value): def qform__QHash(): - return [DisplayFormat.CompactMapFormat] + return [DisplayFormat.CompactMap] + def qdump__QHash(d, value): qdumpHelper_QHash(d, value, value.type[0], value.type[1]) + def qdump__QVariantHash(d, value): qdumpHelper_QHash(d, value, d.createType('QString'), d.createType('QVariant')) + def qdumpHelper_QHash(d, value, keyType, valueType): def hashDataFirstNode(): b = buckets @@ -835,11 +858,13 @@ def qdumpHelper_QHash(d, value, keyType, valueType): def qform__QHashNode(): - return [DisplayFormat.CompactMapFormat] + return [DisplayFormat.CompactMap] + def qdump__QHashNode(d, value): d.putPairItem(None, value) + def qHashIteratorHelper(d, value): typeName = value.type.name hashTypeName = typeName[0:typeName.rfind('::')] @@ -861,9 +886,11 @@ def qHashIteratorHelper(d, value): d.putSubItem('key', key) d.putSubItem('value', val) + def qdump__QHash__const_iterator(d, value): qHashIteratorHelper(d, value) + def qdump__QHash__iterator(d, value): qHashIteratorHelper(d, value) @@ -887,19 +914,19 @@ def qdump__QHostAddress(d, value): else: (ipString, scopeId, a4, pad, a6, protocol, isParsed) \ = d.split('{QString}{QString}{quint32}I16sI{bool}', dd) - elif qtVersion >= 0x050600: # 5.6.0 at f3aabb42 + elif qtVersion >= 0x050600: # 5.6.0 at f3aabb42 if d.ptrSize() == 8 or d.isWindowsTarget(): (ipString, scopeId, a4, pad, a6, protocol, isParsed) \ = d.split('{QString}{QString}{quint32}I16sI{bool}', dd) else: (ipString, scopeId, a4, a6, protocol, isParsed) \ = d.split('{QString}{QString}{quint32}16sI{bool}', dd) - elif qtVersion >= 0x050000: # 5.2.0 at 62feb088 + elif qtVersion >= 0x050000: # 5.2.0 at 62feb088 (ipString, scopeId, a4, a6, protocol, isParsed) \ = d.split('{QString}{QString}{quint32}16sI{bool}', dd) - else: # 4.8.7 at b05d05f + else: # 4.8.7 at b05d05f (a4, a6, protocol, pad, ipString, isParsed, pad, scopeId) \ - = d.split('{quint32}16sB@{QString}{bool}@{QString}', dd) + = d.split('{quint32}16sB@{QString}{bool}@{QString}', dd) if mayNeedParse: ipStringData, ipStringSize, ipStringAlloc = d.stringData(ipString) @@ -912,7 +939,7 @@ def qdump__QHostAddress(d, value): if protocol == 1: # value.d.d->a6 data = d.hexencode(a6) - address = ':'.join('%x' % int(data[i:i+4], 16) for i in range(0, 32, 4)) + address = ':'.join('%x' % int(data[i:i + 4], 16) for i in range(0, 32, 4)) d.putValue(address) elif protocol == 0: # value.d.d->a @@ -921,7 +948,7 @@ def qdump__QHostAddress(d, value): a, n3 = divmod(a, 256) a, n2 = divmod(a, 256) a, n1 = divmod(a, 256) - d.putValue('%d.%d.%d.%d' % (n1, n2, n3, n4)); + d.putValue('%d.%d.%d.%d' % (n1, n2, n3, n4)) else: d.putValue('' % protocol) @@ -938,18 +965,22 @@ def qdump__QHostAddress(d, value): def qdump__QIPv6Address(d, value): raw = d.split('16s', value)[0] data = d.hexencode(raw) - d.putValue(':'.join('%x' % int(data[i:i+4], 16) for i in range(0, 32, 4))) + d.putValue(':'.join('%x' % int(data[i:i + 4], 16) for i in range(0, 32, 4))) d.putArrayData(value.address(), 16, d.lookupType('unsigned char')) + def qform__QList(): - return [DisplayFormat.DirectQListStorageFormat, DisplayFormat.IndirectQListStorageFormat] + return [DisplayFormat.DirectQListStorage, DisplayFormat.IndirectQListStorage] + def qdump__QList(d, value): return qdumpHelper_QList(d, value, value.type[0]) + def qdump__QVariantList(d, value): qdumpHelper_QList(d, value, d.createType('QVariant')) + def qdumpHelper_QList(d, value, innerType): base = d.extractPointer(value) (ref, alloc, begin, end) = d.split('IIII', base) @@ -972,9 +1003,9 @@ def qdumpHelper_QList(d, value, innerType): # in the frontend. # So as first approximation only do the 'isLarge' check: displayFormat = d.currentItemFormat() - if displayFormat == DisplayFormat.DirectQListStorageFormat: + if displayFormat == DisplayFormat.DirectQListStorage: isInternal = True - elif displayFormat == DisplayFormat.IndirectQListStorageFormat: + elif displayFormat == DisplayFormat.IndirectQListStorage: isInternal = False else: isInternal = innerSize <= stepSize and innerType.isMovableType() @@ -994,14 +1025,16 @@ def qdumpHelper_QList(d, value, innerType): x = d.createValue(p, innerType) d.putSubItem(i, x) + def qform__QImage(): - return [DisplayFormat.SimpleFormat, DisplayFormat.SeparateFormat] + return [DisplayFormat.Simple, DisplayFormat.Separate] + def qdump__QImage(d, value): if d.qtVersion() < 0x050000: - (vtbl, painters, imageData) = value.split('ppp'); + (vtbl, painters, imageData) = value.split('ppp') else: - (vtbl, painters, reserved, imageData) = value.split('pppp'); + (vtbl, painters, reserved, imageData) = value.split('pppp') if imageData == 0: d.putValue('(invalid)') @@ -1024,17 +1057,17 @@ def qdump__QImage(d, value): d.putType('void *') displayFormat = d.currentItemFormat() - if displayFormat == DisplayFormat.SeparateFormat: + if displayFormat == DisplayFormat.Separate: d.putDisplay('imagedata:separate', '%08x%08x%08x%08x' % (width, height, nbytes, iformat) - + d.readMemory(bits, nbytes)) + + d.readMemory(bits, nbytes)) def qdump__QLinkedList(d, value): dd = d.extractPointer(value) ptrSize = d.ptrSize() - n = d.extractInt(dd + 4 + 2 * ptrSize); - ref = d.extractInt(dd + 2 * ptrSize); - d.check(0 <= n and n <= 100*1000*1000) + n = d.extractInt(dd + 4 + 2 * ptrSize) + ref = d.extractInt(dd + 2 * ptrSize) + d.check(0 <= n and n <= 100 * 1000 * 1000) d.check(-1 <= ref and ref <= 1000) d.putItemCount(n) if d.isExpanded(): @@ -1045,10 +1078,12 @@ def qdump__QLinkedList(d, value): d.putSubItem(i, d.createValue(pp + 2 * ptrSize, innerType)) pp = d.extractPointer(pp) + qqLocalesCount = None + def qdump__QLocale(d, value): - if d.isMsvcTarget(): # as long as this dumper relies on calling functions skip it for cdb + if d.isMsvcTarget(): # as long as this dumper relies on calling functions skip it for cdb return # Check for uninitialized 'index' variable. Retrieve size of @@ -1079,11 +1114,11 @@ def qdump__QLocale(d, value): dd = value.extractPointer() (data, ref, numberOptions) = d.split('pi4s', dd) (languageId, scriptId, countryId, - decimal, group, listt, percent, zero, - minus, plus, exponential) \ + decimal, group, listt, percent, zero, + minus, plus, exponential) \ = d.split('2s{short}2s' - + '{QChar}{QChar}{short}{QChar}{QChar}' - + '{QChar}{QChar}{QChar}', data) + + '{QChar}{QChar}{short}{QChar}{QChar}' + + '{QChar}{QChar}{QChar}', data) d.putStringValue(d.call('const char *', value, 'name')) d.putNumChild(1) if d.isExpanded(): @@ -1100,11 +1135,11 @@ def qdump__QLocale(d, value): d.putSubItem('negativeSign', minus) d.putSubItem('positiveSign', plus) d.putCallItem('measurementSystem', '@QLocale::MeasurementSystem', - value, 'measurementSystem') + value, 'measurementSystem') d.putCallItem('timeFormat_(short)', '@QString', - value, 'timeFormat', ns + 'QLocale::ShortFormat') + value, 'timeFormat', ns + 'QLocale::ShortFormat') d.putCallItem('timeFormat_(long)', '@QString', - value, 'timeFormat', ns + 'QLocale::LongFormat') + value, 'timeFormat', ns + 'QLocale::LongFormat') d.putFields(value) @@ -1121,7 +1156,7 @@ def qdumpHelper_Qt4_QMap(d, value, keyType, valueType): dd = value.extractPointer() (dummy, it, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, ref, toplevel, n) = d.split('p' * 13 + 'iii', dd) - d.check(0 <= n and n <= 100*1000*1000) + d.check(0 <= n and n <= 100 * 1000 * 1000) d.checkRef(ref) d.putItemCount(n) if d.isExpanded(): @@ -1141,7 +1176,7 @@ def qdumpHelper_Qt4_QMap(d, value, keyType, valueType): def qdumpHelper_Qt5_QMap(d, value, keyType, valueType): dptr = d.extractPointer(value) (ref, n) = d.split('ii', dptr) - d.check(0 <= n and n <= 100*1000*1000) + d.check(0 <= n and n <= 100 * 1000 * 1000) d.check(-1 <= ref and ref < 100000) d.putItemCount(n) @@ -1167,41 +1202,52 @@ def qdumpHelper_Qt5_QMap(d, value, keyType, valueType): def qform__QMap(): - return [DisplayFormat.CompactMapFormat] + return [DisplayFormat.CompactMap] + def qdump__QMap(d, value): qdumpHelper_QMap(d, value, value.type[0], value.type[1]) + def qdumpHelper_QMap(d, value, keyType, valueType): if d.qtVersion() < 0x50000: qdumpHelper_Qt4_QMap(d, value, keyType, valueType) else: qdumpHelper_Qt5_QMap(d, value, keyType, valueType) + def qform__QMultiMap(): - return [DisplayFormat.CompactMapFormat] + return [DisplayFormat.CompactMap] + def qdump__QMultiMap(d, value): qdump__QMap(d, value) + def qform__QVariantMap(): - return [DisplayFormat.CompactMapFormat] + return [DisplayFormat.CompactMap] + def qdump__QVariantMap(d, value): qdumpHelper_QMap(d, value, d.createType('QString'), d.createType('QVariant')) + def qdump__QMetaMethod(d, value): d.putQMetaStuff(value, 'QMetaMethod') + def qdump__QMetaEnum(d, value): d.putQMetaStuff(value, 'QMetaEnum') + def qdump__QMetaProperty(d, value): d.putQMetaStuff(value, 'QMetaProperty') + def qdump__QMetaClassInfo(d, value): d.putQMetaStuff(value, 'QMetaClassInfo') + def qdump__QMetaObject(d, value): d.putEmptyValue() d.putNumChild(1) @@ -1212,35 +1258,36 @@ def qdump__QMetaObject(d, value): if False: - def qdump__QObjectPrivate__ConnectionList(d, value): - d.putNumChild(1) - if d.isExpanded(): - i = 0 - with Children(d): - first, last = value.split('pp') - currentConnection = first - connectionType = d.createType('@QObjectPrivate::Connection') - while currentConnection and currentConnection != last: - sender, receiver, slotObj, nextConnectionList, nextp, prev = \ - d.split('pppppp', currentConnection) - d.putSubItem(i, d.createValue(currentConnection, connectionType)) - currentConnection = nextp - i += 1 - d.putFields(value) - d.putItemCount(i) - else: - d.putSpecialValue('minimumitemcount', 0) + def qdump__QObjectPrivate__ConnectionList(d, value): + d.putNumChild(1) + if d.isExpanded(): + i = 0 + with Children(d): + first, last = value.split('pp') + currentConnection = first + connectionType = d.createType('@QObjectPrivate::Connection') + while currentConnection and currentConnection != last: + sender, receiver, slotObj, nextConnectionList, nextp, prev = \ + d.split('pppppp', currentConnection) + d.putSubItem(i, d.createValue(currentConnection, connectionType)) + currentConnection = nextp + i += 1 + d.putFields(value) + d.putItemCount(i) + else: + d.putSpecialValue('minimumitemcount', 0) def qdump__QProcEnvKey(d, value): d.putByteArrayValue(value) d.putPlainChildren(value) + def qdump__QPixmap(d, value): if d.qtVersion() < 0x050000: - (vtbl, painters, dataPtr) = value.split('ppp'); + (vtbl, painters, dataPtr) = value.split('ppp') else: - (vtbl, painters, reserved, dataPtr) = s = d.split('pppp', value); + (vtbl, painters, reserved, dataPtr) = s = d.split('pppp', value) if dataPtr == 0: d.putValue('(invalid)') else: @@ -1265,14 +1312,14 @@ def qdump__QPointF(d, value): def qdump__QRect(d, value): - pp = lambda l: ('+' if l >= 0 else '') + str(l) + def pp(l): return ('+' if l >= 0 else '') + str(l) (x1, y1, x2, y2) = d.split('iiii', value) d.putValue('%sx%s%s%s' % (x2 - x1 + 1, y2 - y1 + 1, pp(x1), pp(y1))) d.putPlainChildren(value) def qdump__QRectF(d, value): - pp = lambda l: ('+' if l >= 0 else '') + str(l) + def pp(l): return ('+' if l >= 0 else '') + str(l) (x, y, w, h) = value.split('dddd') d.putValue('%sx%s%s%s' % (w, h, pp(x), pp(y))) d.putPlainChildren(value) @@ -1287,7 +1334,7 @@ def qdump__QRegExp(d, value): if d.isExpanded(): with Children(d): try: - d.call('void', value, 'capturedTexts') # Warm up internal cache. + d.call('void', value, 'capturedTexts') # Warm up internal cache. except: # Might fail (LLDB, Core files, ...), still cache might be warm. pass @@ -1303,7 +1350,7 @@ def qdump__QRegion(d, value): d.putSpecialValue('empty') d.putNumChild(0) else: - if d.qtVersion() >= 0x050400: # Padding removed in ee324e4ed + if d.qtVersion() >= 0x050400: # Padding removed in ee324e4ed (ref, pad, rgn) = d.split('i@p', regionDataPtr) (numRects, innerArea, rects, extents, innerRect) = \ d.split('iiP{QRect}{QRect}', rgn) @@ -1422,11 +1469,11 @@ def qdump__QSharedDataPointer(d, value): d.putItem(d_ptr.dereference()) - def qdump__QSize(d, value): d.putValue('(%s, %s)' % value.split('ii')) d.putPlainChildren(value) + def qdump__QSizeF(d, value): d.putValue('(%s, %s)' % value.split('dd')) d.putPlainChildren(value) @@ -1434,17 +1481,18 @@ def qdump__QSizeF(d, value): def qdump__QSizePolicy__Policy(d, value): d.putEnumValue(value.integer(), { - 0 : 'QSizePolicy::Fixed', - 1 : 'QSizePolicy::GrowFlag', - 2 : 'QSizePolicy::ExpandFlag', - 3 : 'QSizePolicy::MinimumExpanding (GrowFlag|ExpandFlag)', - 4 : 'QSizePolicy::ShrinkFlag', - 5 : 'QSizePolicy::Preferred (GrowFlag|ShrinkFlag)', - 7 : 'QSizePolicy::Expanding (GrowFlag|ShrinkFlag|ExpandFlag)', - 8 : 'QSizePolicy::IgnoreFlag', - 13 : 'QSizePolicy::Ignored (ShrinkFlag|GrowFlag|IgnoreFlag)', + 0: 'QSizePolicy::Fixed', + 1: 'QSizePolicy::GrowFlag', + 2: 'QSizePolicy::ExpandFlag', + 3: 'QSizePolicy::MinimumExpanding (GrowFlag|ExpandFlag)', + 4: 'QSizePolicy::ShrinkFlag', + 5: 'QSizePolicy::Preferred (GrowFlag|ShrinkFlag)', + 7: 'QSizePolicy::Expanding (GrowFlag|ShrinkFlag|ExpandFlag)', + 8: 'QSizePolicy::IgnoreFlag', + 13: 'QSizePolicy::Ignored (ShrinkFlag|GrowFlag|IgnoreFlag)', }) + def qdump__QSizePolicy(d, value): bits = value.integer() d.putEmptyValue(-99) @@ -1458,21 +1506,25 @@ def qdump__QSizePolicy(d, value): def qform__QStack(): - return [DisplayFormat.ArrayPlotFormat] + return [DisplayFormat.ArrayPlot] + def qdump__QStack(d, value): qdump__QVector(d, value) + def qdump__QPolygonF(d, value): data, size, alloc = d.vectorDataHelper(d.extractPointer(value)) d.putItemCount(size) d.putPlotData(data, size, d.createType('QPointF')) + def qdump__QPolygon(d, value): data, size, alloc = d.vectorDataHelper(d.extractPointer(value)) d.putItemCount(size) d.putPlotData(data, size, d.createType('QPoint')) + def qdump__QGraphicsPolygonItem(d, value): (vtbl, dptr) = value.split('pp') # Assume sizeof(QGraphicsPolygonItemPrivate) == 400 @@ -1486,36 +1538,42 @@ def qdump__QGraphicsPolygonItem(d, value): d.putItemCount(size) d.putPlotData(data, size, d.createType('QPointF')) + def qedit__QString(d, value, data): d.call('void', value, 'resize', str(len(data))) (base, size, alloc) = d.stringData(value) d.setValues(base, 'short', [ord(c) for c in data]) + def qform__QString(): - return [DisplayFormat.SimpleFormat, DisplayFormat.SeparateFormat] + return [DisplayFormat.Simple, DisplayFormat.Separate] + def qdump__QString(d, value): d.putStringValue(value) (data, size, alloc) = d.stringData(value) d.putNumChild(size) displayFormat = d.currentItemFormat() - if displayFormat == DisplayFormat.SeparateFormat: + if displayFormat == DisplayFormat.Separate: d.putDisplay('utf16:separate', d.encodeString(value, limit=100000)) if d.isExpanded(): d.putArrayData(data, size, d.createType('QChar')) + def qdump__QStaticStringData(d, value): size = value.type[0] (ref, size, alloc, pad, offset, data) = value.split('iii@p%ss' % (2 * size)) d.putValue(d.hexencode(data), 'utf16') d.putPlainChildren(value) + def qdump__QTypedArrayData(d, value): if value.type[0].name == 'unsigned short': qdump__QStringData(d, value) else: qdump__QArrayData(d, value) + def qdump__QStringData(d, value): (ref, size, alloc, pad, offset) = value.split('III@p') elided, shown = d.computeLimit(size, d.displayStringLimit) @@ -1524,10 +1582,12 @@ def qdump__QStringData(d, value): d.putNumChild(1) d.putPlainChildren(value) + def qdump__QHashedString(d, value): qdump__QString(d, value) d.putBetterType(value.type) + def qdump__QQmlRefCount(d, value): d.putItem(value['refCount']) d.putBetterType(value.type) @@ -1536,7 +1596,7 @@ def qdump__QQmlRefCount(d, value): def qdump__QStringRef(d, value): (stringptr, pos, size) = value.split('pii') if stringptr == 0: - d.putValue('(null)'); + d.putValue('(null)') d.putNumChild(0) return (data, ssize, alloc) = d.stringData(d.createValue(stringptr, 'QString')) @@ -1596,7 +1656,8 @@ def qdump__QTextDocument(d, value): def qform__QUrl(): - return [DisplayFormat.SimpleFormat, DisplayFormat.SeparateFormat] + return [DisplayFormat.Simple, DisplayFormat.Separate] + def qdump__QUrl(d, value): privAddress = d.extractPointer(value) @@ -1607,18 +1668,18 @@ def qdump__QUrl(d, value): return if d.qtVersion() < 0x050000: - d.call('void', value, 'port') # Warm up internal cache. + d.call('void', value, 'port') # Warm up internal cache. d.call('void', value, 'path') st = '{QString}' ba = '{QByteArray}' (ref, dummy, - scheme, userName, password, host, path, # QString - query, # QByteArray - fragment, # QString - encodedOriginal, encodedUserName, encodedPassword, - encodedPath, encodedFragment, # QByteArray - port) \ - = d.split('i@' + st*5 + ba + st + ba*5 + 'i', privAddress) + scheme, userName, password, host, path, # QString + query, # QByteArray + fragment, # QString + encodedOriginal, encodedUserName, encodedPassword, + encodedPath, encodedFragment, # QByteArray + port) \ + = d.split('i@' + st * 5 + ba + st + ba * 5 + 'i', privAddress) else: (ref, port, scheme, userName, password, host, path, query, fragment) \ = d.split('ii' + '{QString}' * 7, privAddress) @@ -1629,7 +1690,7 @@ def qdump__QUrl(d, value): url = d.encodeString(scheme) url += '3a002f002f00' # '://' if len(userNameEnc): - url += userNameEnc + '4000' # '@' + url += userNameEnc + '4000' # '@' url += hostEnc if port >= 0: url += '3a00' + ''.join(['%02x00' % ord(c) for c in str(port)]) @@ -1637,7 +1698,7 @@ def qdump__QUrl(d, value): d.putValue(url, 'utf16') displayFormat = d.currentItemFormat() - if displayFormat == DisplayFormat.SeparateFormat: + if displayFormat == DisplayFormat.Separate: d.putDisplay('utf16:separate', url) d.putNumChild(1) @@ -1666,36 +1727,43 @@ def qdumpHelper_QVariant_0(d, value): d.putBetterType('%sQVariant (invalid)' % d.qtNamespace()) d.putValue('(invalid)') + def qdumpHelper_QVariant_1(d, value): # QVariant::Bool d.putBetterType('%sQVariant (bool)' % d.qtNamespace()) d.putValue('true' if value.to('b') else 'false') + def qdumpHelper_QVariant_2(d, value): # QVariant::Int d.putBetterType('%sQVariant (int)' % d.qtNamespace()) d.putValue(value.to('i')) + def qdumpHelper_QVariant_3(d, value): # uint d.putBetterType('%sQVariant (uint)' % d.qtNamespace()) d.putValue(value.to('I')) + def qdumpHelper_QVariant_4(d, value): # qlonglong d.putBetterType('%sQVariant (qlonglong)' % d.qtNamespace()) d.putValue(value.to('q')) + def qdumpHelper_QVariant_5(d, value): # qulonglong d.putBetterType('%sQVariant (qulonglong)' % d.qtNamespace()) d.putValue(value.to('Q')) + def qdumpHelper_QVariant_6(d, value): # QVariant::Double d.putBetterType('%sQVariant (double)' % d.qtNamespace()) d.putValue(value.to('d')) + qdumpHelper_QVariants_A = [ qdumpHelper_QVariant_0, qdumpHelper_QVariant_1, @@ -1708,35 +1776,37 @@ qdumpHelper_QVariants_A = [ qdumpHelper_QVariants_B = [ - 'QChar', # 7 - 'QVariantMap', # 8 - 'QVariantList',# 9 - 'QString', # 10 - 'QStringList', # 11 - 'QByteArray', # 12 - 'QBitArray', # 13 - 'QDate', # 14 - 'QTime', # 15 - 'QDateTime', # 16 - 'QUrl', # 17 - 'QLocale', # 18 - 'QRect', # 19 - 'QRectF', # 20 - 'QSize', # 21 - 'QSizeF', # 22 - 'QLine', # 23 - 'QLineF', # 24 - 'QPoint', # 25 - 'QPointF', # 26 - 'QRegExp', # 27 - 'QVariantHash',# 28 + 'QChar', # 7 + 'QVariantMap', # 8 + 'QVariantList', # 9 + 'QString', # 10 + 'QStringList', # 11 + 'QByteArray', # 12 + 'QBitArray', # 13 + 'QDate', # 14 + 'QTime', # 15 + 'QDateTime', # 16 + 'QUrl', # 17 + 'QLocale', # 18 + 'QRect', # 19 + 'QRectF', # 20 + 'QSize', # 21 + 'QSizeF', # 22 + 'QLine', # 23 + 'QLineF', # 24 + 'QPoint', # 25 + 'QPointF', # 26 + 'QRegExp', # 27 + 'QVariantHash', # 28 ] + def qdumpHelper_QVariant_31(d, value): # QVariant::VoidStar d.putBetterType('%sQVariant (void *)' % d.qtNamespace()) d.putValue('0x%x' % d.extractPointer(value)) + def qdumpHelper_QVariant_32(d, value): # QVariant::Long d.putBetterType('%sQVariant (long)' % d.qtNamespace()) @@ -1745,16 +1815,19 @@ def qdumpHelper_QVariant_32(d, value): else: d.putValue('%s' % d.extractInt64(value)) # sic! + def qdumpHelper_QVariant_33(d, value): # QVariant::Short d.putBetterType('%sQVariant (short)' % d.qtNamespace()) d.putValue('%s' % d.extractShort(value)) + def qdumpHelper_QVariant_34(d, value): # QVariant::Char d.putBetterType('%sQVariant (char)' % d.qtNamespace()) d.putValue('%s' % d.extractByte(value)) + def qdumpHelper_QVariant_35(d, value): # QVariant::ULong d.putBetterType('%sQVariant (unsigned long)' % d.qtNamespace()) @@ -1763,21 +1836,25 @@ def qdumpHelper_QVariant_35(d, value): else: d.putValue('%s' % d.extractUInt64(value)) # sic! + def qdumpHelper_QVariant_36(d, value): # QVariant::UShort d.putBetterType('%sQVariant (unsigned short)' % d.qtNamespace()) d.putValue('%s' % d.extractUShort(value)) + def qdumpHelper_QVariant_37(d, value): # QVariant::UChar d.putBetterType('%sQVariant (unsigned char)' % d.qtNamespace()) d.putValue('%s' % d.extractByte(value)) + def qdumpHelper_QVariant_38(d, value): # QVariant::Float d.putBetterType('%sQVariant (float)' % d.qtNamespace()) d.putValue(value.to('f')) + qdumpHelper_QVariants_D = [ qdumpHelper_QVariant_31, qdumpHelper_QVariant_32, @@ -1805,20 +1882,21 @@ qdumpHelper_QVariants_E = [ qdumpHelper_QVariants_F = [ # Qt 5. In Qt 4 add one. - 'QKeySequence',# 75 - 'QPen', # 76 - 'QTextLength', # 77 - 'QTextFormat', # 78 + 'QKeySequence', # 75 + 'QPen', # 76 + 'QTextLength', # 77 + 'QTextFormat', # 78 'X', - 'QTransform', # 80 - 'QMatrix4x4', # 81 - 'QVector2D', # 82 - 'QVector3D', # 83 - 'QVector4D', # 84 - 'QQuaternion', # 85 - 'QPolygonF' # 86 + 'QTransform', # 80 + 'QMatrix4x4', # 81 + 'QVector2D', # 82 + 'QVector3D', # 83 + 'QVector4D', # 84 + 'QQuaternion', # 85 + 'QPolygonF' # 86 ] + def qdump__QVariant(d, value): (data, typeStuff) = d.split('8sI', value) variantType = typeStuff & 0x3fffffff @@ -1842,7 +1920,7 @@ def qdump__QVariant(d, value): d.putBetterType('%sQVariant (void *)' % d.qtNamespace()) d.putValue('0x%x' % value.extractPointer()) else: - if variantType == 135: # Float + if variantType == 135: # Float blob = value else: p = d.extractPointer(value) @@ -1885,7 +1963,6 @@ def qdump__QVariant(d, value): return innert - # User types. ns = d.qtNamespace() d.putEmptyValue(-99) @@ -1926,7 +2003,7 @@ def qdump__QVariant(d, value): val.laddress = value.laddress d.putSubItem('data', val) - if not innerType is None: + if innerType is not None: d.putBetterType('%sQVariant (%s)' % (ns, innerType)) return None @@ -1939,7 +2016,7 @@ def qedit__QVector(d, value, data): def qform__QVector(): - return [DisplayFormat.ArrayPlotFormat] + return [DisplayFormat.ArrayPlot] def qdump__QVector(d, value): @@ -1949,13 +2026,14 @@ def qdump__QVector(d, value): d.putItemCount(size) d.putPlotData(data, size, value.type[0]) + if False: - def qdump__QObjectConnectionList(d, value): - dd = d.extractPointer(value) - data, size, alloc = d.vectorDataHelper(dd) - d.check(0 <= size and size <= alloc and alloc <= 1000 * 1000 * 1000) - d.putItemCount(size) - d.putPlotData(data, size, d.createType('@QObjectPrivate::ConnectionList')) + def qdump__QObjectConnectionList(d, value): + dd = d.extractPointer(value) + data, size, alloc = d.vectorDataHelper(dd) + d.check(0 <= size and size <= alloc and alloc <= 1000 * 1000 * 1000) + d.putItemCount(size) + d.putPlotData(data, size, d.createType('@QObjectPrivate::ConnectionList')) def qdump__QVarLengthArray(d, value): @@ -1968,16 +2046,19 @@ def qdump__QVarLengthArray(d, value): def qdump__QSharedPointer(d, value): qdump_QWeakPointerHelper(d, value, False) + def qdump__QWeakPointer(d, value): qdump_QWeakPointerHelper(d, value, True) + def qdump__QPointer(d, value): # actually, we'd use value['wp'] instead of value, but since we # only split() on the result and the (sub-)object address is the # same it does not matter but saves some cycles. qdump_QWeakPointerHelper(d, value, True, value.type[0]) -def qdump_QWeakPointerHelper(d, value, isWeak, innerType = None): + +def qdump_QWeakPointerHelper(d, value, isWeak, innerType=None): if isWeak: (d_ptr, val) = value.split('pp') else: @@ -1997,7 +2078,7 @@ def qdump_QWeakPointerHelper(d, value, isWeak, innerType = None): (vptr, weakref, strongref) = d.split('pii', d_ptr) d.check(strongref >= -1) d.check(strongref <= weakref) - d.check(weakref <= 10*1000*1000) + d.check(weakref <= 10 * 1000 * 1000) if innerType is None: innerType = value.type[0] @@ -2019,6 +2100,7 @@ def qdump__QXmlAttributes__Attribute(d, value): d.putSubItem('localname', localname) d.putSubItem('value', val) + def qdump__QXmlAttributes(d, value): (vptr, atts) = value.split('pP') innerType = d.createType(d.qtNamespace() + 'QXmlAttributes::Attribute', 4 * d.ptrSize()) @@ -2053,7 +2135,7 @@ def qdump__QXmlStreamAttribute(d, value): ####################################################################### def extractQmlData(d, value): - #if value.type.code == TypeCode.TypeCodePointer: + #if value.type.code == TypeCode.Pointer: # value = value.dereference() base = value.split('p')[0] #mmdata = d.split('Q', base)[0] @@ -2066,6 +2148,7 @@ def extractQmlData(d, value): #DumperBase.warn('TYOE DATA: %s' % typeName) return d.createValue(base, typeName) + def qdump__QV4__Heap__Base(d, value): mm_data = value.extractPointer() d.putValue('[%s]' % mm_data) @@ -2078,6 +2161,7 @@ def qdump__QV4__Heap__Base(d, value): with SubItem(d, 'nextFree'): d.putItem(d.createValue(mm_data & (~3), value.type)) + def qdump__QV4__Heap__String(d, value): # Note: There's also the 'Identifier' case. And the largestSubLength != 0 case. (baseClass, textOrLeft, idOrRight, subtype, stringHash, largestSub, length, mm) \ @@ -2088,6 +2172,7 @@ def qdump__QV4__Heap__String(d, value): with Children(d): d.putFields(value) + def qmlPutHeapChildren(d, value): d.putItem(extractQmlData(d, value)) @@ -2095,6 +2180,7 @@ def qmlPutHeapChildren(d, value): def qdump__QV4__Object(d, value): qmlPutHeapChildren(d, value) + def qdump__QV4__FunctionObject(d, value): #qmlPutHeapChildren(d, value) d.putEmptyValue() @@ -2105,21 +2191,27 @@ def qdump__QV4__FunctionObject(d, value): d.putCallItem('sourceLocation', '@QQmlSourceLocation', value, 'sourceLocation') + def qdump__QV4__CompilationUnit(d, value): qmlPutHeapChildren(d, value) + def qdump__QV4__CallContext(d, value): qmlPutHeapChildren(d, value) + def qdump__QV4__ScriptFunction(d, value): qmlPutHeapChildren(d, value) + def qdump__QV4__SimpleScriptFunction(d, value): qdump__QV4__FunctionObject(d, value) + def qdump__QV4__ExecutionContext(d, value): qmlPutHeapChildren(d, value) + def qdump__QQmlSourceLocation(d, value): (sourceFile, line, col) = value.split('pHH') (data, size, alloc) = d.stringData(value) @@ -2141,10 +2233,12 @@ def qdump__QQmlSourceLocation(d, value): def qdump__QV4__String(d, value): qmlPutHeapChildren(d, value) + def qdump__QV4__Identifier(d, value): d.putStringValue(value) d.putPlainChildren(value) + def qdump__QV4__PropertyHash(d, value): data = value.extractPointer() (ref, alloc, size, numBits, entries) = d.split('iiiip', data) @@ -2161,14 +2255,17 @@ def qdump__QV4__PropertyHash(d, value): d.putItemCount(n) d.putPlainChildren(value) + def qdump__QV4__InternalClass__Transition(d, value): identifier = d.createValue(value.extractPointer(), d.qtNamespace() + 'QV4::Identifier') d.putStringValue(identifier) d.putPlainChildren(value) + def qdump__QV4__InternalClassTransition(d, value): qdump__QV4__InternalClass__Transition(d, value) + def qdump__QV4__SharedInternalClassData(d, value): (ref, alloc, size, pad, data) = value.split('iIIip') val = d.createValue(data, value.type[0]) @@ -2181,6 +2278,7 @@ def qdump__QV4__SharedInternalClassData(d, value): d.putIntItem('refcount', ref) d.putValue(short.value, short.encoding) + def qdump__QV4__IdentifierTable(d, value): (engine, alloc, size, numBits, pad, entries) = value.split('piiiip') n = 0 @@ -2198,24 +2296,24 @@ def qdump__QV4__IdentifierTable(d, value): if False: # 32 bit. - QV4_Masks_SilentNaNBit = 0x00040000 - QV4_Masks_NaN_Mask = 0x7ff80000 - QV4_Masks_NotDouble_Mask = 0x7ffa0000 - QV4_Masks_Type_Mask = 0xffffc000 - QV4_Masks_Immediate_Mask = QV4_Masks_NotDouble_Mask | 0x00004000 | QV4_Masks_SilentNaNBit - QV4_Masks_IsNullOrUndefined_Mask = QV4_Masks_Immediate_Mask | 0x08000 + QV4_Masks_SilentNaNBit = 0x00040000 + QV4_Masks_NaN_Mask = 0x7ff80000 + QV4_Masks_NotDouble_Mask = 0x7ffa0000 + QV4_Masks_Type_Mask = 0xffffc000 + QV4_Masks_Immediate_Mask = QV4_Masks_NotDouble_Mask | 0x00004000 | QV4_Masks_SilentNaNBit + QV4_Masks_IsNullOrUndefined_Mask = QV4_Masks_Immediate_Mask | 0x08000 QV4_Masks_Tag_Shift = 32 - QV4_ValueType_Undefined_Type = QV4_Masks_Immediate_Mask | 0x00000 - QV4_ValueType_Null_Type = QV4_Masks_Immediate_Mask | 0x10000 - QV4_ValueType_Boolean_Type = QV4_Masks_Immediate_Mask | 0x08000 - QV4_ValueType_Integer_Type = QV4_Masks_Immediate_Mask | 0x18000 - QV4_ValueType_Managed_Type = QV4_Masks_NotDouble_Mask | 0x00000 | QV4_Masks_SilentNaNBit - QV4_ValueType_Empty_Type = QV4_Masks_NotDouble_Mask | 0x18000 | QV4_Masks_SilentNaNBit + QV4_ValueType_Undefined_Type = QV4_Masks_Immediate_Mask | 0x00000 + QV4_ValueType_Null_Type = QV4_Masks_Immediate_Mask | 0x10000 + QV4_ValueType_Boolean_Type = QV4_Masks_Immediate_Mask | 0x08000 + QV4_ValueType_Integer_Type = QV4_Masks_Immediate_Mask | 0x18000 + QV4_ValueType_Managed_Type = QV4_Masks_NotDouble_Mask | 0x00000 | QV4_Masks_SilentNaNBit + QV4_ValueType_Empty_Type = QV4_Masks_NotDouble_Mask | 0x18000 | QV4_Masks_SilentNaNBit - QV4_ConvertibleToInt = QV4_Masks_Immediate_Mask | 0x1 + QV4_ConvertibleToInt = QV4_Masks_Immediate_Mask | 0x1 - QV4_ValueTypeInternal_Null_Type_Internal = QV4_ValueType_Null_Type | QV4_ConvertibleToInt + QV4_ValueTypeInternal_Null_Type_Internal = QV4_ValueType_Null_Type | QV4_ConvertibleToInt QV4_ValueTypeInternal_Boolean_Type_Internal = QV4_ValueType_Boolean_Type | QV4_ConvertibleToInt QV4_ValueTypeInternal_Integer_Type_Internal = QV4_ValueType_Integer_Type | QV4_ConvertibleToInt @@ -2226,19 +2324,22 @@ def QV4_getValue(d, jsval): # (Dumper, QJSValue *jsval) -> QV4::Value * return 0 return dd + def QV4_getVariant(d, jsval): # (Dumper, QJSValue *jsval) -> QVariant * dd = d.split('Q', jsval)[0] if dd & 1: return dd & ~3 return 0 -def QV4_valueForData(d, jsval): # (Dumper, QJSValue *jsval) -> QV4::Value * + +def QV4_valueForData(d, jsval): # (Dumper, QJSValue *jsval) -> QV4::Value * v = QV4_getValue(d, jsval) if v: return v d.warn('Not implemented: VARIANT') return 0 + def QV4_putObjectValue(d, objectPtr): ns = d.qtNamespace() base = d.extractPointer(objectPtr) @@ -2249,7 +2350,7 @@ def QV4_putObjectValue(d, objectPtr): with Children(d): with SubItem(d, '[raw]'): d.putValue('[0x%x]' % objectPtr) - d.putType(' '); + d.putType(' ') d.putNumChild(0) d.putIntItem('inlineMemberOffset', inlineMemberOffset) d.putIntItem('inlineMemberSize', inlineMemberSize) @@ -2260,6 +2361,7 @@ def QV4_putObjectValue(d, objectPtr): d.putSubItem('OBJ', d.createValue(objectPtr, ns + 'QV4::Object')) #d.putFields(value) + def qdump__QV4_Object(d, value): ns = d.qtNamespace() d.putEmptyValue() @@ -2271,12 +2373,14 @@ def qdump__QV4_Object(d, value): memberData, arrayData) = d.split('IIpppp', base) d.putValue('PTR: 0x%x' % objectPtr) + def qdump__QV4__Value(d, value): - if d.ptrSize() == 4: + if d.ptrSize() == 4: qdump_32__QV4__Value(d, value) else: qdump_64__QV4__Value(d, value) + def qdump_32__QV4__Value(d, value): # QV4_Masks_SilentNaNBit = 0x00040000 # QV4_Masks_NaN_Mask = 0x7ff80000 @@ -2286,16 +2390,16 @@ def qdump_32__QV4__Value(d, value): v = value.split('Q')[0] tag = v >> 32 val = v & 0xffffffff - if (tag & 0x7fff2000) == 0x7fff2000: # Int + if (tag & 0x7fff2000) == 0x7fff2000: # Int d.putValue(val) d.putBetterType('%sQV4::Value (int32)' % ns) - elif (tag & 0x7fff4000) == 0x7fff4000: # Bool + elif (tag & 0x7fff4000) == 0x7fff4000: # Bool d.putValue(val) d.putBetterType('%sQV4::Value (bool)' % ns) - elif (tag & 0x7fff0000) == 0x7fff0000: # Null + elif (tag & 0x7fff0000) == 0x7fff0000: # Null d.putValue(val) d.putBetterType('%sQV4::Value (null)' % ns) - elif (tag & 0x7ffa0000) != 0x7ffa0000: # Double + elif (tag & 0x7ffa0000) != 0x7ffa0000: # Double d.putValue(value.split('d')[0]) d.putBetterType('%sQV4::Value (double)' % ns) elif tag == 0x7ffa0000: @@ -2311,15 +2415,15 @@ def qdump_32__QV4__Value(d, value): with Children(d): with SubItem(d, '[raw]'): d.putValue('[0x%x]' % v) - d.putType(' '); + d.putType(' ') d.putNumChild(0) with SubItem(d, '[val]'): d.putValue('[0x%x]' % val) - d.putType(' '); + d.putType(' ') d.putNumChild(0) with SubItem(d, '[tag]'): d.putValue('[0x%x]' % tag) - d.putType(' '); + d.putType(' ') d.putNumChild(0) #with SubItem(d, '[vtable]'): # d.putItem(d.createValue(vtable, ns + 'QV4::VTable')) @@ -2327,56 +2431,57 @@ def qdump_32__QV4__Value(d, value): # d.putNumChild(0) d.putFields(value) + def qdump_64__QV4__Value(d, value): dti = d.qtDeclarativeTypeInfoVersion() new = dti is not None and dti >= 2 if new: - QV4_NaNEncodeMask = 0xfffc000000000000 - QV4_Masks_Immediate_Mask = 0x00020000 # bit 49 + QV4_NaNEncodeMask = 0xfffc000000000000 + QV4_Masks_Immediate_Mask = 0x00020000 # bit 49 - QV4_ValueTypeInternal_Empty_Type_Internal = QV4_Masks_Immediate_Mask | 0 - QV4_ConvertibleToInt = QV4_Masks_Immediate_Mask | 0x10000 # bit 48 - QV4_ValueTypeInternal_Null_Type_Internal = QV4_ConvertibleToInt | 0x08000 - QV4_ValueTypeInternal_Boolean_Type_Internal = QV4_ConvertibleToInt | 0x04000 - QV4_ValueTypeInternal_Integer_Type_Internal = QV4_ConvertibleToInt | 0x02000 + QV4_ValueTypeInternal_Empty_Type_Internal = QV4_Masks_Immediate_Mask | 0 + QV4_ConvertibleToInt = QV4_Masks_Immediate_Mask | 0x10000 # bit 48 + QV4_ValueTypeInternal_Null_Type_Internal = QV4_ConvertibleToInt | 0x08000 + QV4_ValueTypeInternal_Boolean_Type_Internal = QV4_ConvertibleToInt | 0x04000 + QV4_ValueTypeInternal_Integer_Type_Internal = QV4_ConvertibleToInt | 0x02000 - QV4_ValueType_Undefined_Type = 0 # Dummy to make generic code below pass. + QV4_ValueType_Undefined_Type = 0 # Dummy to make generic code below pass. else: - QV4_NaNEncodeMask = 0xffff800000000000 - QV4_Masks_Immediate_Mask = 0x00018000 + QV4_NaNEncodeMask = 0xffff800000000000 + QV4_Masks_Immediate_Mask = 0x00018000 - QV4_IsInt32Mask = 0x0002000000000000 - QV4_IsDoubleMask = 0xfffc000000000000 - QV4_IsNumberMask = QV4_IsInt32Mask | QV4_IsDoubleMask - QV4_IsNullOrUndefinedMask = 0x0000800000000000 - QV4_IsNullOrBooleanMask = 0x0001000000000000 + QV4_IsInt32Mask = 0x0002000000000000 + QV4_IsDoubleMask = 0xfffc000000000000 + QV4_IsNumberMask = QV4_IsInt32Mask | QV4_IsDoubleMask + QV4_IsNullOrUndefinedMask = 0x0000800000000000 + QV4_IsNullOrBooleanMask = 0x0001000000000000 - QV4_Masks_NaN_Mask = 0x7ff80000 - QV4_Masks_Type_Mask = 0xffff8000 - QV4_Masks_IsDouble_Mask = 0xfffc0000 - QV4_Masks_IsNullOrUndefined_Mask = 0x00008000 - QV4_Masks_IsNullOrBoolean_Mask = 0x00010000 + QV4_Masks_NaN_Mask = 0x7ff80000 + QV4_Masks_Type_Mask = 0xffff8000 + QV4_Masks_IsDouble_Mask = 0xfffc0000 + QV4_Masks_IsNullOrUndefined_Mask = 0x00008000 + QV4_Masks_IsNullOrBoolean_Mask = 0x00010000 - QV4_ValueType_Undefined_Type = QV4_Masks_IsNullOrUndefined_Mask - QV4_ValueType_Null_Type = QV4_Masks_IsNullOrUndefined_Mask \ - | QV4_Masks_IsNullOrBoolean_Mask - QV4_ValueType_Boolean_Type = QV4_Masks_IsNullOrBoolean_Mask - QV4_ValueType_Integer_Type = 0x20000 | QV4_Masks_IsNullOrBoolean_Mask - QV4_ValueType_Managed_Type = 0 - QV4_ValueType_Empty_Type = QV4_ValueType_Undefined_Type | 0x4000 + QV4_ValueType_Undefined_Type = QV4_Masks_IsNullOrUndefined_Mask + QV4_ValueType_Null_Type = QV4_Masks_IsNullOrUndefined_Mask \ + | QV4_Masks_IsNullOrBoolean_Mask + QV4_ValueType_Boolean_Type = QV4_Masks_IsNullOrBoolean_Mask + QV4_ValueType_Integer_Type = 0x20000 | QV4_Masks_IsNullOrBoolean_Mask + QV4_ValueType_Managed_Type = 0 + QV4_ValueType_Empty_Type = QV4_ValueType_Undefined_Type | 0x4000 - QV4_ValueTypeInternal_Null_Type_Internal = QV4_ValueType_Null_Type - QV4_ValueTypeInternal_Boolean_Type_Internal = QV4_ValueType_Boolean_Type - QV4_ValueTypeInternal_Integer_Type_Internal = QV4_ValueType_Integer_Type + QV4_ValueTypeInternal_Null_Type_Internal = QV4_ValueType_Null_Type + QV4_ValueTypeInternal_Boolean_Type_Internal = QV4_ValueType_Boolean_Type + QV4_ValueTypeInternal_Integer_Type_Internal = QV4_ValueType_Integer_Type - QV4_PointerMask = 0xfffffffffffffffd + QV4_PointerMask = 0xfffffffffffffffd - QV4_Masks_Tag_Shift = 32 - QV4_IsDouble_Shift = 64-14 - QV4_IsNumber_Shift = 64-15 - QV4_IsConvertibleToInt_Shift = 64-16 - QV4_IsManaged_Shift = 64-17 + QV4_Masks_Tag_Shift = 32 + QV4_IsDouble_Shift = 64 - 14 + QV4_IsNumber_Shift = 64 - 15 + QV4_IsConvertibleToInt_Shift = 64 - 16 + QV4_IsManaged_Shift = 64 - 17 v = value.split('Q')[0] tag = v >> QV4_Masks_Tag_Shift @@ -2414,13 +2519,13 @@ def qdump_64__QV4__Value(d, value): else: (parentv, flags, pad, className) = d.split('pIIp', vtable) #vtable = value['m']['vtable'] - if flags & 2: # isString' + if flags & 2: # isString' d.putBetterType('%sQV4::Value (string)' % ns) qdump__QV4__Heap__String(d, d.createValue(v, ns + 'QV4::Heap::String')) #d.putStringValue(d.extractPointer(value) + 2 * d.ptrSize()) #d.putValue('ptr: 0x%x' % d.extractPointer(value)) return - elif flags & 4: # isObject + elif flags & 4: # isObject d.putBetterType('%sQV4::Value (object)' % ns) #QV4_putObjectValue(d, d.extractPointer(value) + 2 * d.ptrSize()) arrayVTable = d.symbolAddress(ns + 'QV4::ArrayObject::static_vtbl') @@ -2428,7 +2533,7 @@ def qdump_64__QV4__Value(d, value): d.putNumChild(1) d.putItem(d.createValue(d.extractPointer(value) + 2 * d.ptrSize(), ns + 'QV4::Object')) return - elif flags & 8: # isFunction + elif flags & 8: # isFunction d.putBetterType('%sQV4::Value (function)' % ns) d.putEmptyValue() else: @@ -2439,14 +2544,15 @@ def qdump_64__QV4__Value(d, value): with Children(d): with SubItem(d, '[raw]'): d.putValue('[0x%x]' % v) - d.putType(' '); + d.putType(' ') d.putNumChild(0) with SubItem(d, '[vtable]'): d.putItem(d.createValue(vtable, ns + 'QV4::VTable')) - d.putType(' '); + d.putType(' ') d.putNumChild(0) d.putFields(value) + def qdump__QV__PropertyHashData(d, value): (ref, alloc, size, numBits, entries) = value.split('IIIIp') d.putItemCount(size) @@ -2454,6 +2560,7 @@ def qdump__QV__PropertyHashData(d, value): with Children(d): d.putFields(value) + def qdump__QV__PropertyHash(d, value): qdump__QV__PropertyHashData(d, d.createValue(d.extractPointer(), value.type.name + 'Data')) @@ -2467,6 +2574,7 @@ def qdump__QV4__Scoped(d, value): # d.putSubItem('[]', d.createValue(value.extractPointer(), innerType)) # d.putFields(value) + def qdump__QV4__ScopedString(d, value): innerType = value.type[0] qdump__QV4__String(d, d.createValue(value.extractPointer(), innerType)) @@ -2478,6 +2586,7 @@ def qdump__QJSValue(d, value): else: qdump_64__QJSValue(d, value) + def qdump_32__QJSValue(d, value): ns = d.qtNamespace() dd = value.split('I')[0] @@ -2498,10 +2607,11 @@ def qdump_32__QJSValue(d, value): with Children(d): with SubItem(d, '[raw]'): d.putValue('[0x%x]' % dd) - d.putType(' '); + d.putType(' ') d.putNumChild(0) d.putFields(value) + def qdump_64__QJSValue(d, value): ns = d.qtNamespace() dd = value.split('Q')[0] @@ -2520,10 +2630,11 @@ def qdump_64__QJSValue(d, value): with Children(d): with SubItem(d, '[raw]'): d.putValue('[0x%x]' % dd) - d.putType(' '); + d.putType(' ') d.putNumChild(0) d.putFields(value) + def qdump__QQmlBinding(d, value): d.putEmptyValue() if d.isExpanded(): @@ -2566,7 +2677,6 @@ def jstagAsString(tag): return 'Unknown' - def qdump__QTJSC__JSValue(d, value): d.putEmptyValue() d.putNumChild(1) @@ -2597,6 +2707,7 @@ def qdump__QTJSC__JSValue(d, value): except: pass + def qdump__QScriptValue(d, value): # structure: # engine QScriptEnginePrivate @@ -2614,12 +2725,12 @@ def qdump__QScriptValue(d, value): d.putValue('(invalid)') d.putNumChild(0) return - if int(dd['type']) == 1: # Number + if int(dd['type']) == 1: # Number d.putValue(dd['numberValue']) d.putType('%sQScriptValue (Number)' % ns) d.putNumChild(0) return - if int(dd['type']) == 2: # String + if int(dd['type']) == 2: # String d.putStringValue(dd['stringValue']) d.putType('%sQScriptValue (String)' % ns) return @@ -2681,7 +2792,7 @@ def qdump__QScriptValue(d, value): d.putNumChild(1) if d.isExpanded(): with Children(d): - d.putSubItem('jscValue', dd['jscValue']) + d.putSubItem('jscValue', dd['jscValue']) def qdump__QQmlAccessorProperties__Properties(d, value): @@ -2698,6 +2809,7 @@ def qdump__QQmlAccessorProperties__Properties(d, value): def qdumpHelper_qle_cutBits(value, offset, length): return (value >> offset) & ((1 << length) - 1) + def qdump__QJsonPrivate__qle_bitfield(d, value): offset = value.type[0] length = value.type[1] @@ -2705,6 +2817,7 @@ def qdump__QJsonPrivate__qle_bitfield(d, value): d.putValue('%s' % qdumpHelper_qle_cutBits(val, offset, length)) d.putNumChild(0) + def qdumpHelper_qle_signedbitfield_value(d, value): offset = value.type[0] length = value.type[1] @@ -2714,10 +2827,12 @@ def qdumpHelper_qle_signedbitfield_value(d, value): val -= (1 << (length - 1)) return val + def qdump__QJsonPrivate__qle_signedbitfield(d, value): d.putValue('%s' % qdumpHelper_qle_signedbitfield_value(d, value)) d.putNumChild(0) + def qdump__QJsonPrivate__q_littleendian(d, value): d.putValue('%s' % value['val'].integer()) d.putNumChild(0) @@ -2767,7 +2882,7 @@ def qdumpHelper_QJsonValue(d, data, base, pv): return if t == 3: d.putType('QJsonValue (String)') - data = base + v; + data = base + v if latinOrIntValue: length = d.extractUShort(data) d.putValue(d.readMemory(data + 2, length), 'latin1') @@ -2831,9 +2946,9 @@ def qdumpHelper_QJsonObject(d, data, obj): table = obj + d.extractUInt(obj + 8) for i in range(n): with SubItem(d, i): - entryPtr = table + 4 * i # entryAt(i) - entryStart = obj + d.extractUInt(entryPtr) # Entry::value - keyStart = entryStart + 4 # sizeof(QJsonPrivate::Entry) == 4 + entryPtr = table + 4 * i # entryAt(i) + entryStart = obj + d.extractUInt(entryPtr) # Entry::value + keyStart = entryStart + 4 # sizeof(QJsonPrivate::Entry) == 4 val = d.extractInt(entryStart) key = d.extractInt(keyStart) isLatinKey = qdumpHelper_qle_cutBits(val, 4, 1) diff --git a/share/qtcreator/debugger/setup.cfg b/share/qtcreator/debugger/setup.cfg new file mode 100644 index 00000000000..7b75dd8860a --- /dev/null +++ b/share/qtcreator/debugger/setup.cfg @@ -0,0 +1,15 @@ +[pycodestyle] +max-line-length = 100 +ignore = + # E222 - multiple spaces after operator: Used for alignments + E222, + # E241 - multiple spaces after ',': Used for alignments + E241, + # E265 - block comment should start with '# ': We have a bunch of #warn(foo) lines + # a space after # would leave an incorrect indentation after uncommenting + E265, + # E402 - module level import not at top of file: Sometimes we need to adjust the sys.path before + # we can import + E402, + # E722 - do not use bare except, specify exception instead: TODO + E722 diff --git a/share/qtcreator/debugger/stdtypes.py b/share/qtcreator/debugger/stdtypes.py index e9f99fc3f60..c6693f70b69 100644 --- a/share/qtcreator/debugger/stdtypes.py +++ b/share/qtcreator/debugger/stdtypes.py @@ -26,8 +26,10 @@ from utils import DisplayFormat from dumper import Children, SubItem + def qform__std__array(): - return [DisplayFormat.ArrayPlotFormat] + return [DisplayFormat.ArrayPlot] + def qdump__std__array(d, value): size = value.type[1] @@ -37,7 +39,8 @@ def qdump__std__array(d, value): def qform__std____1__array(): - return [DisplayFormat.ArrayPlotFormat] + return [DisplayFormat.ArrayPlot] + def qdump__std____1__array(d, value): qdump__std__array(d, value) @@ -66,6 +69,7 @@ def qdump__std__complex(d, value): d.putSubItem("real", real) d.putSubItem("imag", imag) + def qdump__std____1__complex(d, value): qdump__std__complex(d, value) @@ -85,7 +89,7 @@ def qdump__std__deque(d, value): bufsize = 512 // innerSize (mapptr, mapsize, startCur, startFirst, startLast, startNode, - finishCur, finishFirst, finishLast, finishNode) = value.split("pppppppppp") + finishCur, finishFirst, finishLast, finishNode) = value.split("pppppppppp") size = bufsize * ((finishNode - startNode) // d.ptrSize() - 1) size += (finishCur - finishFirst) // innerSize @@ -108,6 +112,7 @@ def qdump__std__deque(d, value): pcur = pfirst pnode = newnode + def qdump__std____1__deque(d, value): mptr, mfirst, mbegin, mend, start, size = value.split("pppptt") d.check(0 <= size and size <= 1000 * 1000 * 1000) @@ -123,6 +128,7 @@ def qdump__std____1__deque(d, value): base = d.extractPointer(mfirst + k * ptrSize) d.putSubItem(i, d.createValue(base + j * innerSize, innerType)) + def qdump__std__deque__QNX(d, value): innerType = value.type[0] innerSize = innerType.size() @@ -157,7 +163,8 @@ def qdump__std__deque__QNX(d, value): if mapsize <= block: block -= mapsize d.putSubItem(i, map[block][offset]) - myoff += 1; + myoff += 1 + def qdump__std__deque__MSVC(d, value): innerType = value.type[0] @@ -187,6 +194,7 @@ def qdump__std__deque__MSVC(d, value): d.putSubItem(i, d.createValue(address, innerType)) myoff += 1 + def qdump__std____debug__deque(d, value): qdump__std__deque(d, value) @@ -218,6 +226,7 @@ def qdump__std__list(d, value): d.putSubItem(i, d.createValue(p + 2 * d.ptrSize(), innerType)) p = d.extractPointer(p) + def qdump__std__list__QNX(d, value): (proxy, head, size) = value.split("ppp") d.putItemCount(size, 1000) @@ -230,12 +239,15 @@ def qdump__std__list__QNX(d, value): d.putSubItem(i, d.createValue(p + 2 * d.ptrSize(), innerType)) p = d.extractPointer(p) + def qdump__std____debug__list(d, value): qdump__std__list(d, value) + def qdump__std____cxx11__list(d, value): qdump__std__list(d, value) + def qdump__std____1__list(d, value): if value.type.size() == 3 * d.ptrSize(): # C++11 only. @@ -260,8 +272,10 @@ def qdump__std____1__list(d, value): (prev, p, val) = d.split(typeCode, p) d.putSubItem(i, val) + def qform__std__map(): - return [DisplayFormat.CompactMapFormat] + return [DisplayFormat.CompactMap] + def qdump__std__map(d, value): if d.isQnxTarget() or d.isMsvcTarget(): @@ -270,7 +284,7 @@ def qdump__std__map(d, value): # stuff is actually (color, pad) with 'I@', but we can save cycles/ (compare, stuff, parent, left, right, size) = value.split('pppppp') - d.check(0 <= size and size <= 100*1000*1000) + d.check(0 <= size and size <= 100 * 1000 * 1000) d.putItemCount(size) if d.isExpanded(): @@ -299,16 +313,19 @@ def qdump__std__map(d, value): break node = node["_M_left"] + def qdump_std__map__helper(d, value): (proxy, head, size) = value.split("ppp") - d.check(0 <= size and size <= 100*1000*1000) + d.check(0 <= size and size <= 100 * 1000 * 1000) d.putItemCount(size) if d.isExpanded(): keyType = value.type[0] valueType = value.type[1] pairType = value.type[3][0] + def helper(node): - (left, parent, right, color, isnil, pad, pair) = d.split("pppcc@{%s}" % (pairType.name), node) + (left, parent, right, color, isnil, pad, pair) = d.split( + "pppcc@{%s}" % (pairType.name), node) if left != head: for res in helper(left): yield res @@ -322,24 +339,31 @@ def qdump_std__map__helper(d, value): for (pair, i) in zip(helper(root), d.childRange()): d.putPairItem(i, pair) + def qdump__std____debug__map(d, value): qdump__std__map(d, value) + def qdump__std____debug__set(d, value): qdump__std__set(d, value) + def qdump__std__multiset(d, value): qdump__std__set(d, value) + def qdump__std____cxx1998__map(d, value): qdump__std__map(d, value) + def qform__std__multimap(): - return [DisplayFormat.CompactMapFormat] + return [DisplayFormat.CompactMap] + def qdump__std__multimap(d, value): return qdump__std__map(d, value) + def qdumpHelper__std__tree__iterator(d, value, isSet=False): treeTypeName = None if value.type.name.endswith("::iterator"): @@ -375,30 +399,39 @@ def qdumpHelper__std__tree__iterator(d, value, isSet=False): d.putSubItem("right", d.createValue(right, nodeType)) d.putSubItem("parent", d.createValue(parent, nodeType)) + def qdump__std___Rb_tree_iterator(d, value): qdumpHelper__std__tree__iterator(d, value) + def qdump__std___Rb_tree_const_iterator(d, value): qdumpHelper__std__tree__iterator(d, value) + def qdump__std__map__iterator(d, value): qdumpHelper__std__tree__iterator(d, value) + def qdump____gnu_debug___Safe_iterator(d, value): d.putItem(value["_M_current"]) + def qdump__std__map__const_iterator(d, value): qdumpHelper__std__tree__iterator(d, value) + def qdump__std__set__iterator(d, value): qdumpHelper__std__tree__iterator(d, value, True) + def qdump__std__set__const_iterator(d, value): qdumpHelper__std__tree__iterator(d, value, True) + def qdump__std____cxx1998__set(d, value): qdump__std__set(d, value) + def qdumpHelper__std__tree__iterator_MSVC(d, value): d.putNumChild(1) d.putEmptyValue() @@ -416,9 +449,11 @@ def qdumpHelper__std__tree__iterator_MSVC(d, value): else: d.putSubItem("value", child) + def qdump__std___Tree_const_iterator(d, value): qdumpHelper__std__tree__iterator_MSVC(d, value) + def qdump__std___Tree_iterator(d, value): qdumpHelper__std__tree__iterator_MSVC(d, value) @@ -430,7 +465,7 @@ def qdump__std__set(d, value): impl = value["_M_t"]["_M_impl"] size = impl["_M_node_count"].integer() - d.check(0 <= size and size <= 100*1000*1000) + d.check(0 <= size and size <= 100 * 1000 * 1000) d.putItemCount(size) if d.isExpanded(): valueType = value.type[0] @@ -453,14 +488,17 @@ def qdump__std__set(d, value): while node["_M_left"].pointer() != 0: node = node["_M_left"] + def qdump__std__set__QNX(d, value): (proxy, head, size) = value.split("ppp") - d.check(0 <= size and size <= 100*1000*1000) + d.check(0 <= size and size <= 100 * 1000 * 1000) d.putItemCount(size) if d.isExpanded(): - childType=value.type[0] + childType = value.type[0] + def helper(node): - (left, parent, right, color, isnil, pad, value) = d.split("pppcc@{%s}" % childType.name, node) + (left, parent, right, color, isnil, pad, value) = d.split( + "pppcc@{%s}" % childType.name, node) if left != head: for res in helper(left): yield res @@ -474,6 +512,7 @@ def qdump__std__set__QNX(d, value): for (item, i) in zip(helper(root), d.childRange()): d.putSubItem(i, item) + def std1TreeMin(d, node): #_NodePtr __tree_min(_NodePtr __x): # while (__x->__left_ != nullptr) @@ -485,6 +524,7 @@ def std1TreeMin(d, node): node = left return node + def std1TreeIsLeftChild(d, node): # bool __tree_is_left_child(_NodePtr __x): # return __x == __x->__parent_->__left_; @@ -508,10 +548,11 @@ def std1TreeNext(d, node): node = node['__parent_'] return node['__parent_'] + def qdump__std____1__set(d, value): (proxy, head, size) = value.split("ppp") - d.check(0 <= size and size <= 100*1000*1000) + d.check(0 <= size and size <= 100 * 1000 * 1000) d.putItemCount(size) if d.isExpanded(): @@ -534,21 +575,24 @@ def qdump__std____1__set(d, value): for (i, data) in zip(d.childRange(), in_order_traversal(head)): d.putSubItem(i, data) + def qdump__std____1__multiset(d, value): qdump__std____1__set(d, value) + def qform__std____1__map(): - return [DisplayFormat.CompactMapFormat] + return [DisplayFormat.CompactMap] + def qdump__std____1__map(d, value): try: (proxy, head, size) = value.split("ppp") - d.check(0 <= size and size <= 100*1000*1000) + d.check(0 <= size and size <= 100 * 1000 * 1000) # Sometimes there is extra data at the front. Don't know why at the moment. except RuntimeError: (junk, proxy, head, size) = value.split("pppp") - d.check(0 <= size and size <= 100*1000*1000) + d.check(0 <= size and size <= 100 * 1000 * 1000) d.putItemCount(size) @@ -574,12 +618,15 @@ def qdump__std____1__map(d, value): for (i, pair) in zip(d.childRange(), in_order_traversal(head)): d.putPairItem(i, pair, 'key', 'value') + def qform__std____1__multimap(): - return [DisplayFormat.CompactMapFormat] + return [DisplayFormat.CompactMap] + def qdump__std____1__multimap(d, value): qdump__std____1__map(d, value) + def qdump__std____1__map__iterator(d, value): d.putEmptyValue() if d.isExpanded(): @@ -588,9 +635,11 @@ def qdump__std____1__map__iterator(d, value): d.putSubItem('first', node['first']) d.putSubItem('second', node['second']) + def qdump__std____1__map__const_iterator(d, value): qdump__std____1__map__iterator(d, value) + def qdump__std____1__set__iterator(d, value): d.putEmptyValue() d.putNumChild(1) @@ -606,27 +655,34 @@ def qdump__std____1__set__iterator(d, value): node = node.cast(keyType) d.putSubItem('value', node) + def qdump__std____1__set_const_iterator(d, value): qdump__std____1__set__iterator(d, value) + def qdump__std__stack(d, value): d.putItem(value["c"]) d.putBetterType(value.type) + def qdump__std____debug__stack(d, value): qdump__std__stack(d, value) + def qdump__std____1__stack(d, value): d.putItem(value["c"]) d.putBetterType(value.type) + def qform__std__string(): - return [DisplayFormat.Latin1StringFormat, DisplayFormat.SeparateLatin1StringFormat, - DisplayFormat.Utf8StringFormat, DisplayFormat.SeparateUtf8StringFormat ] + return [DisplayFormat.Latin1String, DisplayFormat.SeparateLatin1String, + DisplayFormat.Utf8String, DisplayFormat.SeparateUtf8String] + def qdump__std__string(d, value): qdumpHelper_std__string(d, value, d.createType("char"), d.currentItemFormat()) + def qdumpHelper_std__string(d, value, charType, format): if d.isQnxTarget(): qdumpHelper__std__string__QNX(d, value, charType, format) @@ -650,34 +706,37 @@ def qdumpHelper_std__string(d, value, charType, format): # struct { size_type _M_length, size_type _M_capacity, int _M_refcount; } (size, alloc, refcount) = d.split("ppp", data - 3 * d.ptrSize()) refcount = refcount & 0xffffffff - d.check(refcount >= -1) # Can be -1 according to docs. - d.check(0 <= size and size <= alloc and alloc <= 100*1000*1000) + d.check(refcount >= -1) # Can be -1 according to docs. + d.check(0 <= size and size <= alloc and alloc <= 100 * 1000 * 1000) d.putCharArrayHelper(data, size, charType, format) + def qdumpHelper__std__string__QNX(d, value, charType, format): size = value['_Mysize'] alloc = value['_Myres'] _BUF_SIZE = int(16 / charType.size()) - if _BUF_SIZE <= alloc: #(_BUF_SIZE <= _Myres ? _Bx._Ptr : _Bx._Buf); + if _BUF_SIZE <= alloc: # (_BUF_SIZE <= _Myres ? _Bx._Ptr : _Bx._Buf); data = value['_Bx']['_Ptr'] else: data = value['_Bx']['_Buf'] sizePtr = data.cast(d.charType().pointer()) refcount = int(sizePtr[-1]) - d.check(refcount >= -1) # Can be -1 accoring to docs. - d.check(0 <= size and size <= alloc and alloc <= 100*1000*1000) + d.check(refcount >= -1) # Can be -1 accoring to docs. + d.check(0 <= size and size <= alloc and alloc <= 100 * 1000 * 1000) d.putCharArrayHelper(sizePtr, size, charType, format) + def qdumpHelper__std__string__MSVC(d, value, charType, format): - (proxy, buffer, size, alloc) = value.split("p16spp"); - _BUF_SIZE = int(16 / charType.size()); - d.check(0 <= size and size <= alloc and alloc <= 100*1000*1000) + (proxy, buffer, size, alloc) = value.split("p16spp") + _BUF_SIZE = int(16 / charType.size()) + d.check(0 <= size and size <= alloc and alloc <= 100 * 1000 * 1000) if _BUF_SIZE <= alloc: - (proxy, data) = value.split("pp"); + (proxy, data) = value.split("pp") else: data = value.address() + d.ptrSize() d.putCharArrayHelper(data, size, charType, format) + def qdump__std____1__string(d, value): firstByte = value.split('b')[0] if int(firstByte & 1) == 0: @@ -707,9 +766,11 @@ def qdump__std____1__wstring(d, value): def qdump__std____weak_ptr(d, value): return qdump__std__shared_ptr(d, value) + def qdump__std__weak_ptr(d, value): return qdump__std__shared_ptr(d, value) + def qdump__std____1__weak_ptr(d, value): return qdump__std____1__shared_ptr(d, value) @@ -727,6 +788,7 @@ def qdump__std__shared_ptr(d, value): d.putItem(i.dereference()) d.putBetterType(value.type) + def qdump__std____1__shared_ptr(d, value): i = value["__ptr_"] if i.pointer() == 0: @@ -736,6 +798,7 @@ def qdump__std____1__shared_ptr(d, value): d.putItem(i.dereference()) d.putBetterType(value.type) + def qdump__std__unique_ptr(d, value): p = d.extractPointer(value) if p == 0: @@ -745,6 +808,7 @@ def qdump__std__unique_ptr(d, value): d.putItem(d.createValue(p, value.type[0])) d.putBetterType(value.type) + def qdump__std____1__unique_ptr(d, value): qdump__std__unique_ptr(d, value) @@ -760,11 +824,14 @@ def qdump__std__pair(d, value): d.putField('keyencoded', key.encoding) d.putValue(value.value, value.encoding) + def qform__std__unordered_map(): - return [DisplayFormat.CompactMapFormat] + return [DisplayFormat.CompactMap] + def qform__std____debug__unordered_map(): - return [DisplayFormat.CompactMapFormat] + return [DisplayFormat.CompactMap] + def qdump__std__unordered_map(d, value): if d.isQnxTarget() or d.isMsvcTarget(): @@ -806,6 +873,7 @@ def qdump__std__unordered_map(d, value): p, pad, key, pad, val = d.split(typeCode, p) d.putPairItem(i, (key, val)) + def qdump__std____debug__unordered_map(d, value): qdump__std__unordered_map(d, value) @@ -813,12 +881,15 @@ def qdump__std____debug__unordered_map(d, value): def qform__std__unordered_multimap(): return qform__std__unordered_map() + def qform__std____debug__unordered_multimap(): return qform__std____debug__unordered_map() + def qdump__std__unordered_multimap(d, value): qdump__std__unordered_map(d, value) + def qdump__std____debug__unordered_multimap(d, value): qdump__std__unordered_multimap(d, value) @@ -861,8 +932,10 @@ def qdump__std__unordered_set(d, value): d.putSubItem(i, d.createValue(p + ptrSize - offset, valueType)) p = d.extractPointer(p + offset) + def qform__std____1__unordered_map(): - return [DisplayFormat.CompactMapFormat] + return [DisplayFormat.CompactMap] + def qdump__std____1__unordered_map(d, value): (size, _) = value["__table_"]["__p2_"].split("pp") @@ -909,15 +982,18 @@ def qdump__std____1__unordered_set(d, value): def qdump__std____debug__unordered_set(d, value): qdump__std__unordered_set(d, value) + def qdump__std__unordered_multiset(d, value): qdump__std__unordered_set(d, value) + def qdump__std____debug__unordered_multiset(d, value): qdump__std__unordered_multiset(d, value) def qform__std__valarray(): - return [DisplayFormat.ArrayPlotFormat] + return [DisplayFormat.ArrayPlot] + def qdump__std__valarray(d, value): if d.isMsvcTarget(): @@ -929,7 +1005,8 @@ def qdump__std__valarray(d, value): def qform__std____1__valarray(): - return [DisplayFormat.ArrayPlotFormat] + return [DisplayFormat.ArrayPlot] + def qdump__std____1__valarray(d, value): innerType = value.type[0] @@ -940,7 +1017,8 @@ def qdump__std____1__valarray(d, value): def qform__std__vector(): - return [DisplayFormat.ArrayPlotFormat] + return [DisplayFormat.ArrayPlot] + def qedit__std__vector(d, value, data): import gdb @@ -954,12 +1032,14 @@ def qedit__std__vector(d, value, data): cmd = "set (%s[%d])*$d={%s}" % (innerType, n, data) gdb.execute(cmd) + def qdump__std__vector(d, value): if d.isQnxTarget() or d.isMsvcTarget(): qdumpHelper__std__vector__QNX(d, value) else: qdumpHelper__std__vector(d, value, False) + def qdumpHelper__std__vector(d, value, isLibCpp): innerType = value.type[0] isBool = innerType.name == 'bool' @@ -975,7 +1055,7 @@ def qdumpHelper__std__vector(d, value, isLibCpp): finish = value["_M_finish"]["_M_p"].pointer() foffset = value["_M_finish"]["_M_offset"].integer() alloc = value["_M_end_of_storage"].pointer() - size = (finish - start) * 8 + foffset - soffset # 8 is CHAR_BIT. + size = (finish - start) * 8 + foffset - soffset # 8 is CHAR_BIT. else: if isLibCpp: start = value["__begin_"].pointer() @@ -1007,6 +1087,7 @@ def qdumpHelper__std__vector(d, value, isLibCpp): else: d.putPlotData(start, size, innerType) + def qdumpHelper__std__vector__QNX(d, value): innerType = value.type[0] isBool = innerType.name == 'bool' @@ -1036,14 +1117,18 @@ def qdumpHelper__std__vector__QNX(d, value): else: d.putPlotData(start, size, innerType) + def qform__std____1__vector(): - return [DisplayFormat.ArrayPlotFormat] + return [DisplayFormat.ArrayPlot] + def qdump__std____1__vector(d, value): qdumpHelper__std__vector(d, value, True) + def qform__std____debug__vector(): - return [DisplayFormat.ArrayPlotFormat] + return [DisplayFormat.ArrayPlot] + def qdump__std____debug__vector(d, value): qdump__std__vector(d, value) @@ -1067,37 +1152,48 @@ def qdump__std__initializer_list(d, value): if d.isExpanded(): d.putPlotData(start, size, innerType) + def qedit__std__string(d, value, data): d.call('void', value, 'assign', '"%s"' % data.replace('"', '\\"')) + def qedit__string(d, expr, value): qedit__std__string(d, expr, value) + def qedit__std____cxx11__string(d, expr, value): qedit__std__string(d, expr, value) + def qedit__std__wstring(d, value, data): d.call('void', value, 'assign', 'L"%s"' % data.replace('"', '\\"')) + def qedit__wstring(d, expr, value): qedit__std__wstring(d, expr, value) + def qedit__std____cxx11__wstring(d, expr, value): qedit__std__wstring(d, expr, value) + def qdump__string(d, value): qdump__std__string(d, value) + def qform__std__wstring(): - return [DisplayFormat.SimpleFormat, DisplayFormat.SeparateFormat] + return [DisplayFormat.Simple, DisplayFormat.Separate] + def qdump__std__wstring(d, value): qdumpHelper_std__string(d, value, d.createType('wchar_t'), d.currentItemFormat()) + def qdump__std__basic_string(d, value): innerType = value.type[0] qdumpHelper_std__string(d, value, innerType, d.currentItemFormat()) + def qdump__std____cxx11__basic_string(d, value): innerType = value.type[0] try: @@ -1107,24 +1203,30 @@ def qdump__std____cxx11__basic_string(d, value): d.putEmptyValue() d.putPlainChildren(value) return - d.check(0 <= size) #and size <= alloc and alloc <= 100*1000*1000) + d.check(0 <= size) # and size <= alloc and alloc <= 100*1000*1000) d.putCharArrayHelper(data, size, innerType, d.currentItemFormat()) + def qform__std____cxx11__string(d, value): qform__std__string(d, value) + def qdump__std____cxx11__string(d, value): (data, size) = value.split("pI") - d.check(0 <= size) #and size <= alloc and alloc <= 100*1000*1000) + d.check(0 <= size) # and size <= alloc and alloc <= 100*1000*1000) d.putCharArrayHelper(data, size, d.charType(), d.currentItemFormat()) # Needed only to trigger the form report above. + + def qform__std____cxx11__string(): return qform__std__string() + def qform__std____cxx11__wstring(): return qform__std__wstring() + def qdump__std____1__basic_string(d, value): innerType = value.type[0].name if innerType == "char": @@ -1134,12 +1236,15 @@ def qdump__std____1__basic_string(d, value): else: d.warn("UNKNOWN INNER TYPE %s" % innerType) + def qdump__wstring(d, value): qdump__std__wstring(d, value) + def qdump__std____1__once_flag(d, value): qdump__std__once_flag(d, value) + def qdump__std__once_flag(d, value): d.putValue(value.split("i")[0]) d.putBetterType(value.type) @@ -1174,14 +1279,17 @@ def qdump__uint8_t(d, value): d.putNumChild(0) d.putValue(value.integer()) + def qdump__int8_t(d, value): d.putNumChild(0) d.putValue(value.integer()) + def qdump__std__byte(d, value): d.putNumChild(0) d.putValue(value.integer()) + def qdump__std__optional(d, value): innerType = value.type[0] (payload, pad, initialized) = d.split('{%s}@b' % innerType.name, value) @@ -1192,5 +1300,6 @@ def qdump__std__optional(d, value): d.putSpecialValue("uninitialized") d.putNumChild(0) + def qdump__std__experimental__optional(d, value): qdump__std__optional(d, value) diff --git a/share/qtcreator/debugger/utils.py b/share/qtcreator/debugger/utils.py index f67b9311199..feec4379cde 100644 --- a/share/qtcreator/debugger/utils.py +++ b/share/qtcreator/debugger/utils.py @@ -26,7 +26,7 @@ # Debugger start modes. Keep in sync with DebuggerStartMode in debuggerconstants.h -class DebuggerStartMode: +class DebuggerStartMode(): ( NoStartMode, StartInternal, @@ -41,33 +41,33 @@ class DebuggerStartMode: # Known special formats. Keep in sync with DisplayFormat in debuggerprotocol.h -class DisplayFormat: +class DisplayFormat(): ( - AutomaticFormat, - RawFormat, - SimpleFormat, - EnhancedFormat, - SeparateFormat, - Latin1StringFormat, - SeparateLatin1StringFormat, - Utf8StringFormat, - SeparateUtf8StringFormat, - Local8BitStringFormat, - Utf16StringFormat, - Ucs4StringFormat, - Array10Format, - Array100Format, - Array1000Format, - Array10000Format, - ArrayPlotFormat, - CompactMapFormat, - DirectQListStorageFormat, - IndirectQListStorageFormat, + Automatic, + Raw, + Simple, + Enhanced, + Separate, + Latin1String, + SeparateLatin1String, + Utf8String, + SeparateUtf8String, + Local8BitString, + Utf16String, + Ucs4String, + Array10, + Array100, + Array1000, + Array10000, + ArrayPlot, + CompactMap, + DirectQListStorage, + IndirectQListStorage, ) = range(0, 20) # Breakpoints. Keep synchronized with BreakpointType in breakpoint.h -class BreakpointType: +class BreakpointType(): ( UnknownType, BreakpointByFileAndLine, @@ -87,24 +87,24 @@ class BreakpointType: # Internal codes for types keep in sync with cdbextensions pytype.cpp -class TypeCode: +class TypeCode(): ( - TypeCodeTypedef, - TypeCodeStruct, - TypeCodeVoid, - TypeCodeIntegral, - TypeCodeFloat, - TypeCodeEnum, - TypeCodePointer, - TypeCodeArray, - TypeCodeComplex, - TypeCodeReference, - TypeCodeFunction, - TypeCodeMemberPointer, - TypeCodeFortranString, - TypeCodeUnresolvable, - TypeCodeBitfield, - TypeCodeRValueReference, + Typedef, + Struct, + Void, + Integral, + Float, + Enum, + Pointer, + Array, + Complex, + Reference, + Function, + MemberPointer, + FortranString, + Unresolvable, + Bitfield, + RValueReference, ) = range(0, 16) diff --git a/share/qtcreator/qml/qmlpuppet/commands/inputeventcommand.h b/share/qtcreator/qml/qmlpuppet/commands/inputeventcommand.h index 2d77cab6dd5..fc484380a1e 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/inputeventcommand.h +++ b/share/qtcreator/qml/qmlpuppet/commands/inputeventcommand.h @@ -50,7 +50,7 @@ public: int angleDelta() const { return m_angleDelta; } private: - QEvent::Type m_type; + QEvent::Type m_type = QEvent::None; QPoint m_pos; Qt::MouseButton m_button = Qt::NoButton; Qt::MouseButtons m_buttons = Qt::NoButton; diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/Arrow.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/Arrow.qml index 488198911b3..b58732dd543 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/Arrow.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/Arrow.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtQuick 2.0 -import QtQuick3D 1.0 +import QtQuick3D 1.15 import MouseArea3D 1.0 DirectionalDraggable { diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/AutoScaleHelper.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/AutoScaleHelper.qml index 16c3dd86804..c16c47ddd79 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/AutoScaleHelper.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/AutoScaleHelper.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtQuick 2.0 -import QtQuick3D 1.0 +import QtQuick3D 1.15 import MouseArea3D 1.0 Node { @@ -45,12 +45,12 @@ Node { Connections { target: camera - onSceneTransformChanged: updateScale() + function onSceneTransformChanged() { updateScale() } } Connections { target: _generalHelper - onOverlayUpdateNeeded: updateScale() + function onOverlayUpdateNeeded() { updateScale() } } function getScale(baseScale) diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/AxisHelper.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/AxisHelper.qml index 34808aecde7..7481d242252 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/AxisHelper.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/AxisHelper.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtQuick 2.0 -import QtQuick3D 1.0 +import QtQuick3D 1.15 View3D { id: axisHelperView @@ -37,7 +37,7 @@ View3D { Node { OrthographicCamera { id: axisHelperCamera - rotation: editCameraCtrl.camera ? editCameraCtrl.camera.rotation : Qt.vector3d(0, 0, 0) + rotation: editCameraCtrl.camera ? editCameraCtrl.camera.rotation : Qt.quaternion(1, 0, 0, 0) position: editCameraCtrl.camera ? editCameraCtrl.camera.position.minus(editCameraCtrl._lookAtPoint) .normalized().times(600) : Qt.vector3d(0, 0, 0) } @@ -54,7 +54,7 @@ View3D { AxisHelperArm { id: armX - rotation: Qt.vector3d(0, 0, -90) + eulerRotation: Qt.vector3d(0, 0, -90) color: Qt.rgba(1, 0, 0, 1) hoverColor: Qt.lighter(Qt.rgba(1, 0, 0, 1)) view3D: axisHelperView @@ -64,7 +64,7 @@ View3D { AxisHelperArm { id: armY - rotation: Qt.vector3d(0, 0, 0) + eulerRotation: Qt.vector3d(0, 0, 0) color: Qt.rgba(0, 0.6, 0, 1) hoverColor: Qt.lighter(Qt.rgba(0, 0.6, 0, 1)) view3D: axisHelperView @@ -74,7 +74,7 @@ View3D { AxisHelperArm { id: armZ - rotation: Qt.vector3d(90, 0, 0) + eulerRotation: Qt.vector3d(90, 0, 0) color: Qt.rgba(0, 0, 1, 1) hoverColor: Qt.lighter(Qt.rgba(0, 0, 1, 1)) view3D: axisHelperView diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/AxisHelperArm.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/AxisHelperArm.qml index 23d2f9bbaf3..0fd5ad1e989 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/AxisHelperArm.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/AxisHelperArm.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtQuick 2.0 -import QtQuick3D 1.0 +import QtQuick3D 1.15 Node { id: armRoot diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/CameraFrustum.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/CameraFrustum.qml new file mode 100644 index 00000000000..f038b9b74d3 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/CameraFrustum.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick3D 1.15 +import CameraGeometry 1.0 + +Model { + id: cameraFrustum + + property alias geometryName: cameraGeometry.name // Name must be unique for each geometry + property alias viewPortRect: cameraGeometry.viewPortRect + property Node targetNode: null + property Node scene: null + property bool selected: false + + function updateGeometry() + { + cameraGeometry.update(); + } + + position: targetNode ? targetNode.scenePosition : Qt.vector3d(0, 0, 0) + rotation: targetNode ? targetNode.sceneRotation : Qt.quaternion(1, 0, 0, 0) + + geometry: cameraGeometry + materials: [ + DefaultMaterial { + id: defaultMaterial + emissiveColor: cameraFrustum.selected ? "#FF0000" : "#555555" + lighting: DefaultMaterial.NoLighting + cullingMode: Material.DisableCulling + } + ] + + CameraGeometry { + id: cameraGeometry + camera: cameraFrustum.scene && cameraFrustum.targetNode ? cameraFrustum.targetNode : null + } +} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/CameraGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/CameraGizmo.qml index 1a9dd554298..bd55fd4a006 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/CameraGizmo.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/CameraGizmo.qml @@ -24,37 +24,33 @@ ****************************************************************************/ import QtQuick 2.0 -import QtQuick3D 1.0 -import CameraGeometry 1.0 IconGizmo { id: cameraGizmo + property var frustumModel: null + iconSource: "qrc:///qtquickplugin/mockfiles/images/editor_camera.png" - property alias geometryName: cameraGeometry.name // Name must be unique for each geometry - property alias viewPortRect: cameraGeometry.viewPortRect + + function connectFrustum(frustum) + { + frustumModel = frustum; + + frustum.selected = selected; + frustum.selected = Qt.binding(function() {return selected;}); + + frustum.scene = scene; + frustum.scene = Qt.binding(function() {return scene;}); + + frustum.targetNode = targetNode; + frustum.targetNode = Qt.binding(function() {return targetNode;}); + + frustum.visible = visible; + frustum.visible = Qt.binding(function() {return visible;}); + } onActiveSceneChanged: { - if (activeScene == scene) - cameraGeometry.update(); - } - - Model { - id: gizmoModel - geometry: cameraGeometry - visible: cameraGizmo.visible - materials: [ - DefaultMaterial { - id: defaultMaterial - emissiveColor: cameraGizmo.selected ? "#FF0000" : "#555555" - lighting: DefaultMaterial.NoLighting - cullingMode: Material.DisableCulling - } - ] - } - - CameraGeometry { - id: cameraGeometry - camera: cameraGizmo.scene && cameraGizmo.targetNode ? cameraGizmo.targetNode : null + if (frustumModel && activeScene == scene) + frustumModel.updateGeometry(); } } diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/DirectionalDraggable.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/DirectionalDraggable.qml index 62096142a82..af24bac6fb5 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/DirectionalDraggable.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/DirectionalDraggable.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtQuick 2.0 -import QtQuick3D 1.0 +import QtQuick3D 1.15 import MouseArea3D 1.0 Model { @@ -61,8 +61,6 @@ Model { var maskedPosition = Qt.vector3d(planePos.x, 0, 0); _posPressed = planePos.x; _scenePosPressed = mouseArea.dragHelper.mapPositionToScene(maskedPosition); - if (targetNode.orientation === Node.RightHanded) - _scenePosPressed.z = -_scenePosPressed.z; _targetStartPos = mouseArea.pivotScenePosition(targetNode); pressed(mouseArea); } @@ -71,8 +69,6 @@ Model { { var maskedPosition = Qt.vector3d(planePos.x, 0, 0); var scenePointerPos = mouseArea.dragHelper.mapPositionToScene(maskedPosition); - if (targetNode.orientation === Node.RightHanded) - scenePointerPos.z = -scenePointerPos.z; return scenePointerPos.minus(_scenePosPressed); } @@ -99,7 +95,7 @@ Model { y: -1.5 width: 12 height: 3 - rotation: Qt.vector3d(0, 0, 90) + eulerRotation: Qt.vector3d(0, 0, 90) grabsMouse: targetNode active: rootModel.active dragHelper: rootModel.dragHelper @@ -116,7 +112,7 @@ Model { y: -1.5 width: 12 height: 3 - rotation: Qt.vector3d(0, 90, 90) + eulerRotation: Qt.vector3d(0, 90, 90) grabsMouse: targetNode active: rootModel.active dragHelper: rootModel.dragHelper diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/EditCameraController.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/EditCameraController.qml index f6bd540fe57..207dc941994 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/EditCameraController.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/EditCameraController.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtQuick 2.12 -import QtQuick3D 1.0 +import QtQuick3D 1.15 Item { id: cameraCtrl @@ -43,8 +43,8 @@ Item { property int _button property real _zoomFactor: 1 property Camera _prevCamera: null - readonly property vector3d _defaultCameraPosition: Qt.vector3d(0, 600, -600) - readonly property vector3d _defaultCameraRotation: Qt.vector3d(45, 0, 0) + readonly property vector3d _defaultCameraPosition: Qt.vector3d(0, 600, 600) + readonly property vector3d _defaultCameraRotation: Qt.vector3d(-45, 0, 0) readonly property real _defaultCameraLookAtDistance: _defaultCameraPosition.length() function restoreCameraState(cameraState) @@ -68,7 +68,7 @@ Item { _lookAtPoint = Qt.vector3d(0, 0, 0); _zoomFactor = 1; camera.position = _defaultCameraPosition; - camera.rotation = _defaultCameraRotation; + camera.eulerRotation = _defaultCameraRotation; _generalHelper.zoomCamera(camera, 0, _defaultCameraLookAtDistance, _lookAtPoint, _zoomFactor, false); } @@ -92,7 +92,7 @@ Item { if (!camera) return; - camera.rotation = rotation; + camera.eulerRotation = rotation; var newLookAtAndZoom = _generalHelper.focusObjectToCamera( camera, _defaultCameraLookAtDistance, targetObject, view3d, _zoomFactor, updateZoom); _lookAtPoint = newLookAtAndZoom.toVector3d(); @@ -151,7 +151,7 @@ Item { onPressed: { if (cameraCtrl.camera && mouse.modifiers === Qt.AltModifier) { cameraCtrl._dragging = true; - cameraCtrl._startRotation = cameraCtrl.camera.rotation; + cameraCtrl._startRotation = cameraCtrl.camera.eulerRotation; cameraCtrl._startPosition = cameraCtrl.camera.position; cameraCtrl._startLookAtPoint = _lookAtPoint; cameraCtrl._pressPoint = Qt.vector3d(mouse.x, mouse.y, 0); diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml index 9ee23e48a4e..3a7f81c90ce 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/EditView3D.qml @@ -25,7 +25,7 @@ import QtQuick 2.12 import QtQuick.Window 2.12 -import QtQuick3D 1.0 +import QtQuick3D 1.15 import QtQuick.Controls 2.0 import QtGraphicalEffects 1.0 import MouseArea3D 1.0 @@ -62,33 +62,42 @@ Item { onUsePerspectiveChanged: _generalHelper.storeToolState(sceneId, "usePerspective", usePerspective) onShowEditLightChanged: _generalHelper.storeToolState(sceneId,"showEditLight", showEditLight) onGlobalOrientationChanged: _generalHelper.storeToolState(sceneId, "globalOrientation", globalOrientation) + onActiveSceneChanged: updateActiveScene(); - onActiveSceneChanged: { + function updateActiveScene() + { if (editView) { // Destroy is async, so make sure we don't get any more updates for the old editView _generalHelper.enableItemUpdate(editView, false); editView.destroy(); } - if (activeScene) { - // importScene cannot be updated after initial set, so we need to reconstruct entire View3D - var component = Qt.createComponent("SceneView3D.qml"); - if (component.status === Component.Ready) { - editView = component.createObject(viewRect, - {"usePerspective": usePerspective, - "showSceneLight": showEditLight, - "importScene": activeScene, - "cameraZoomFactor": cameraControl._zoomFactor, - "z": 1}); - editView.usePerspective = Qt.binding(function() {return usePerspective;}); - editView.showSceneLight = Qt.binding(function() {return showEditLight;}); - editView.cameraZoomFactor = Qt.binding(function() {return cameraControl._zoomFactor;}); - selectionBoxes.length = 0; - updateToolStates(_generalHelper.getToolStates(sceneId), true); - } + // importScene cannot be updated after initial set, so we need to reconstruct entire View3D + var component = Qt.createComponent("SceneView3D.qml"); + if (component.status === Component.Ready) { + editView = component.createObject(viewRect, + {"usePerspective": usePerspective, + "showSceneLight": showEditLight, + "importScene": activeScene, + "cameraZoomFactor": cameraControl._zoomFactor, + "z": 1}); + editView.usePerspective = Qt.binding(function() {return usePerspective;}); + editView.showSceneLight = Qt.binding(function() {return showEditLight;}); + editView.cameraZoomFactor = Qt.binding(function() {return cameraControl._zoomFactor;}); + + selectionBoxes.length = 0; + updateToolStates(_generalHelper.getToolStates(sceneId), true); } } + function clearActiveScene() + { + activeScene = null; + sceneId = ""; + + updateActiveScene(); + } + // Disables edit view update if scene doesn't match current activeScene. // If it matches, updates are enabled. function enableEditViewUpdate(scene) @@ -102,7 +111,7 @@ Item { if (editView) { var targetNode = selectedNodes.length > 0 ? selectionBoxes[0].model : null; - cameraControl.focusObject(targetNode, editView.camera.rotation, true); + cameraControl.focusObject(targetNode, editView.camera.eulerRotation, true); } } @@ -243,7 +252,7 @@ Item { // No free gizmos available, create a new one var component = Qt.createComponent("LightGizmo.qml"); if (component.status === Component.Ready) { - var gizmo = component.createObject(overlayScene, + var gizmo = component.createObject(overlayView, {"view3D": overlayView, "targetNode": obj, "selectedNodes": selectedNodes, "scene": scene, "activeScene": activeScene}); @@ -265,19 +274,24 @@ Item { } } // No free gizmos available, create a new one - var component = Qt.createComponent("CameraGizmo.qml"); - if (component.status === Component.Ready) { + var gizmoComponent = Qt.createComponent("CameraGizmo.qml"); + var frustumComponent = Qt.createComponent("CameraFrustum.qml"); + if (gizmoComponent.status === Component.Ready && frustumComponent.status === Component.Ready) { var geometryName = _generalHelper.generateUniqueName("CameraGeometry"); - var gizmo = component.createObject( + var frustum = frustumComponent.createObject( overlayScene, - {"view3D": overlayView, "targetNode": obj, "geometryName": geometryName, - "viewPortRect": viewPortRect, "selectedNodes": selectedNodes, - "scene": scene, "activeScene": activeScene}); + {"geometryName": geometryName, "viewPortRect": viewPortRect}); + var gizmo = gizmoComponent.createObject( + overlayView, + {"view3D": overlayView, "targetNode": obj, + "selectedNodes": selectedNodes, "scene": scene, "activeScene": activeScene}); + cameraGizmos[cameraGizmos.length] = gizmo; gizmo.clicked.connect(handleObjectClicked); - gizmo.viewPortRect = Qt.binding(function() {return viewPortRect;}); gizmo.selectedNodes = Qt.binding(function() {return selectedNodes;}); gizmo.activeScene = Qt.binding(function() {return activeScene;}); + frustum.viewPortRect = Qt.binding(function() {return viewPortRect;}); + gizmo.connectFrustum(frustum); } } @@ -341,7 +355,7 @@ Item { clipFar: viewRoot.editView ? viewRoot.editView.perpectiveCamera.clipFar : 1000 clipNear: viewRoot.editView ? viewRoot.editView.perpectiveCamera.clipNear : 1 position: viewRoot.editView ? viewRoot.editView.perpectiveCamera.position : Qt.vector3d(0, 0, 0) - rotation: viewRoot.editView ? viewRoot.editView.perpectiveCamera.rotation : Qt.vector3d(0, 0, 0) + rotation: viewRoot.editView ? viewRoot.editView.perpectiveCamera.rotation : Qt.quaternion(1, 0, 0, 0) } OrthographicCamera { @@ -349,7 +363,7 @@ Item { clipFar: viewRoot.editView ? viewRoot.editView.orthoCamera.clipFar : 1000 clipNear: viewRoot.editView ? viewRoot.editView.orthoCamera.clipNear : 1 position: viewRoot.editView ? viewRoot.editView.orthoCamera.position : Qt.vector3d(0, 0, 0) - rotation: viewRoot.editView ? viewRoot.editView.orthoCamera.rotation : Qt.vector3d(0, 0, 0) + rotation: viewRoot.editView ? viewRoot.editView.orthoCamera.rotation : Qt.quaternion(1, 0, 0, 0) scale: viewRoot.editView ? viewRoot.editView.orthoCamera.scale : Qt.vector3d(0, 0, 0) } @@ -395,15 +409,14 @@ Item { view3D: overlayView dragHelper: gizmoDragHelper - onRotateCommit: viewRoot.commitObjectProperty(viewRoot.selectedNode, "rotation") - onRotateChange: viewRoot.changeObjectProperty(viewRoot.selectedNode, "rotation") + onRotateCommit: viewRoot.commitObjectProperty(viewRoot.selectedNode, "eulerRotation") + onRotateChange: viewRoot.changeObjectProperty(viewRoot.selectedNode, "eulerRotation") } AutoScaleHelper { id: autoScale view3D: overlayView position: moveGizmo.scenePosition - orientation: moveGizmo.orientation } Line3D { @@ -412,27 +425,20 @@ Item { name: "3D Edit View Pivot Line" color: "#ddd600" - function flipIfNeeded(vec) { - if (!viewRoot.selectedNode || viewRoot.selectedNode.orientation === Node.LeftHanded) - return vec; - else - return Qt.vector3d(vec.x, vec.y, -vec.z); - } - - startPos: viewRoot.selectedNode ? flipIfNeeded(viewRoot.selectedNode.scenePosition) - : Qt.vector3d(0, 0, 0) + startPos: viewRoot.selectedNode ? viewRoot.selectedNode.scenePosition + : Qt.vector3d(0, 0, 0) Connections { target: viewRoot - onSelectedNodeChanged: { - pivotLine.endPos = pivotLine.flipIfNeeded(gizmoDragHelper.pivotScenePosition( - viewRoot.selectedNode)); + function onSelectedNodeChanged() + { + pivotLine.endPos = gizmoDragHelper.pivotScenePosition(viewRoot.selectedNode); } } Connections { target: viewRoot.selectedNode - onSceneTransformChanged: { - pivotLine.endPos = pivotLine.flipIfNeeded(gizmoDragHelper.pivotScenePosition( - viewRoot.selectedNode)); + function onSceneTransformChanged() + { + pivotLine.endPos = gizmoDragHelper.pivotScenePosition(viewRoot.selectedNode); } } @@ -529,6 +535,32 @@ Item { } } + Rectangle { + id: rotateGizmoLabel + color: "white" + x: rotateGizmo.currentMousePos.x - (10 + width) + y: rotateGizmo.currentMousePos.y - (10 + height) + width: rotateGizmoLabelText.width + 4 + height: rotateGizmoLabelText.height + 4 + border.width: 1 + visible: rotateGizmo.dragging + parent: rotateGizmo.view3D + + Text { + id: rotateGizmoLabelText + text: { + var l = Qt.locale(); + if (rotateGizmo.targetNode) { + var degrees = rotateGizmo.currentAngle * (180 / Math.PI); + return qsTr(Number(degrees).toLocaleString(l, 'f', 1)); + } else { + return ""; + } + } + anchors.centerIn: parent + } + } + EditCameraController { id: cameraControl camera: viewRoot.editView ? viewRoot.editView.camera : null diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/HelperGrid.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/HelperGrid.qml index 3d247b71e2f..38ea65034b6 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/HelperGrid.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/HelperGrid.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtQuick 2.0 -import QtQuick3D 1.0 +import QtQuick3D 1.15 import GridGeometry 1.0 Node { @@ -34,7 +34,7 @@ Node { property alias step: gridGeometry.step property alias subdivAlpha: subGridMaterial.opacity - rotation.x: 90 + eulerRotation.x: 90 // Note: Only one instance of HelperGrid is supported, as the geometry names are fixed @@ -89,7 +89,7 @@ Node { ] } Model { // X Axis - rotation.z: 90 + eulerRotation.z: 90 geometry: GridGeometry { lines: gridGeometry.lines step: gridGeometry.step diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/IconGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/IconGizmo.qml index 77f3a54a055..b42bf4cc2ce 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/IconGizmo.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/IconGizmo.qml @@ -24,10 +24,10 @@ ****************************************************************************/ import QtQuick 2.0 -import QtQuick3D 1.0 +import QtQuick3D 1.15 import QtGraphicalEffects 1.12 -Node { +Item { id: iconGizmo property Node activeScene: null @@ -50,16 +50,13 @@ Node { signal positionCommit() signal clicked(Node node, bool multi) - position: targetNode ? targetNode.scenePosition : Qt.vector3d(0, 0, 0) - rotation: targetNode ? targetNode.sceneRotation : Qt.vector3d(0, 0, 0) visible: activeScene === scene && (targetNode ? targetNode.visible : false) Overlay2D { id: iconOverlay - targetNode: iconGizmo + targetNode: iconGizmo.targetNode targetView: view3D visible: iconGizmo.visible && !isBehindCamera - parent: view3D Rectangle { id: iconRect diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml index 7c9953e9bb5..9f9f0d23263 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/LightGizmo.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtQuick 2.0 -import QtQuick3D 1.0 +import QtQuick3D 1.15 IconGizmo { id: lightGizmo diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/Line3D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/Line3D.qml index 3c0afc08280..b4b911a51de 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/Line3D.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/Line3D.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtQuick 2.0 -import QtQuick3D 1.0 +import QtQuick3D 1.15 import LineGeometry 1.0 Node { diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/MoveGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/MoveGizmo.qml index a6e32441df9..adb6f23a483 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/MoveGizmo.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/MoveGizmo.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtQuick 2.0 -import QtQuick3D 1.0 +import QtQuick3D 1.15 import MouseArea3D 1.0 Node { @@ -40,13 +40,13 @@ Node { property MouseArea3D dragHelper: null position: dragHelper.pivotScenePosition(targetNode) - orientation: targetNode ? targetNode.orientation : Node.LeftHanded onTargetNodeChanged: position = dragHelper.pivotScenePosition(targetNode) Connections { target: moveGizmo.targetNode - onSceneTransformChanged: { + function onSceneTransformChanged() + { moveGizmo.position = moveGizmo.dragHelper.pivotScenePosition(moveGizmo.targetNode); } } @@ -55,14 +55,11 @@ Node { signal positionMove() Node { - rotation: globalOrientation || !moveGizmo.targetNode ? Qt.vector3d(0, 0, 0) + rotation: globalOrientation || !moveGizmo.targetNode ? Qt.quaternion(1, 0, 0, 0) : moveGizmo.targetNode.sceneRotation - rotationOrder: moveGizmo.targetNode ? moveGizmo.targetNode.rotationOrder : Node.YXZ - orientation: moveGizmo.orientation - Arrow { id: arrowX - rotation: Qt.vector3d(0, 0, -90) + eulerRotation: Qt.vector3d(0, 0, -90) targetNode: moveGizmo.targetNode color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(1, 0, 0, 1)) : Qt.rgba(1, 0, 0, 1) @@ -76,7 +73,7 @@ Node { Arrow { id: arrowY - rotation: Qt.vector3d(0, 0, 0) + eulerRotation: Qt.vector3d(0, 0, 0) targetNode: moveGizmo.targetNode color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0.6, 0, 1)) : Qt.rgba(0, 0.6, 0, 1) @@ -90,7 +87,7 @@ Node { Arrow { id: arrowZ - rotation: Qt.vector3d(90, 0, 0) + eulerRotation: Qt.vector3d(90, 0, 0) targetNode: moveGizmo.targetNode color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0, 1, 1)) : Qt.rgba(0, 0, 1, 1) @@ -108,7 +105,7 @@ Node { y: 10 z: 10 - rotation: Qt.vector3d(0, 90, 0) + eulerRotation: Qt.vector3d(0, 90, 0) targetNode: moveGizmo.targetNode color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(1, 0, 0, 1)) : Qt.rgba(1, 0, 0, 1) @@ -126,7 +123,7 @@ Node { x: 10 z: 10 - rotation: Qt.vector3d(90, 0, 0) + eulerRotation: Qt.vector3d(90, 0, 0) targetNode: moveGizmo.targetNode color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0.6, 0, 1)) : Qt.rgba(0, 0.6, 0, 1) @@ -144,7 +141,7 @@ Node { x: 10 y: 10 - rotation: Qt.vector3d(0, 0, 0) + eulerRotation: Qt.vector3d(0, 0, 0) targetNode: moveGizmo.targetNode color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0, 1, 1)) : Qt.rgba(0, 0, 1, 1) diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/Overlay2D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/Overlay2D.qml index 87528eddd32..d60afc7176d 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/Overlay2D.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/Overlay2D.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtQuick 2.0 -import QtQuick3D 1.0 +import QtQuick3D 1.15 Item { id: root @@ -39,29 +39,26 @@ Item { Connections { target: targetNode - onSceneTransformChanged: updateOverlay() + function onSceneTransformChanged() { updateOverlay() } } Connections { target: targetView.camera - onSceneTransformChanged: updateOverlay() + function onSceneTransformChanged() { updateOverlay() } } Connections { target: _generalHelper - onOverlayUpdateNeeded: updateOverlay() + function onOverlayUpdateNeeded() { updateOverlay() } } function updateOverlay() { var scenePos = targetNode ? targetNode.scenePosition : Qt.vector3d(0, 0, 0); // Need separate variable as scenePos is reference to read-only property - var scenePosZ = scenePos.z - if (targetNode && targetNode.orientation === Node.RightHanded) - scenePosZ = -scenePosZ; var scenePosWithOffset = Qt.vector3d(scenePos.x + offset.x, scenePos.y + offset.y, - scenePosZ + offset.z); + scenePos.z + offset.z); var viewPos = targetView ? targetView.mapFrom3DScene(scenePosWithOffset) : Qt.vector3d(0, 0, 0); root.x = viewPos.x; diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/PlanarDraggable.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/PlanarDraggable.qml index 23e4b79c824..6dce8e52086 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/PlanarDraggable.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/PlanarDraggable.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtQuick 2.0 -import QtQuick3D 1.0 +import QtQuick3D 1.15 import MouseArea3D 1.0 Model { @@ -48,7 +48,6 @@ Model { signal dragged(var mouseArea, vector3d sceneRelativeDistance, vector2d relativeDistance) signal released(var mouseArea, vector3d sceneRelativeDistance, vector2d relativeDistance) - rotationOrder: Node.XYZr source: "#Rectangle" DefaultMaterial { @@ -66,8 +65,6 @@ Model { _planePosPressed = planePos; _scenePosPressed = mouseArea.dragHelper.mapPositionToScene(planePos.toVector3d()); - if (targetNode.orientation === Node.RightHanded) - _scenePosPressed.z = -_scenePosPressed.z; _targetStartPos = mouseArea.pivotScenePosition(targetNode); pressed(mouseArea); } @@ -75,8 +72,6 @@ Model { function calcRelativeDistance(mouseArea, planePos) { var scenePointerPos = mouseArea.dragHelper.mapPositionToScene(planePos.toVector3d()); - if (targetNode.orientation === Node.RightHanded) - scenePointerPos.z = -scenePointerPos.z; return scenePointerPos.minus(_scenePosPressed); } diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/PlanarMoveHandle.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/PlanarMoveHandle.qml index 591f1196dea..5f8b2799221 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/PlanarMoveHandle.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/PlanarMoveHandle.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtQuick 2.0 -import QtQuick3D 1.0 +import QtQuick3D 1.15 import MouseArea3D 1.0 PlanarDraggable { diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/PlanarScaleHandle.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/PlanarScaleHandle.qml index 7fd00e66f7a..5515fa96cef 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/PlanarScaleHandle.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/PlanarScaleHandle.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtQuick 2.0 -import QtQuick3D 1.0 +import QtQuick3D 1.15 import MouseArea3D 1.0 PlanarDraggable { diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/RotateGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/RotateGizmo.qml index a1f5a4b509a..54d2d3a0a3e 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/RotateGizmo.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/RotateGizmo.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtQuick 2.0 -import QtQuick3D 1.0 +import QtQuick3D 1.15 import MouseArea3D 1.0 Node { @@ -41,13 +41,13 @@ Node { property point currentMousePos position: dragHelper.pivotScenePosition(targetNode) - orientation: targetNode ? targetNode.orientation : Node.LeftHanded onTargetNodeChanged: position = dragHelper.pivotScenePosition(targetNode) Connections { target: rotateGizmo.targetNode - onSceneTransformChanged: { + function onSceneTransformChanged() + { rotateGizmo.position = rotateGizmo.dragHelper.pivotScenePosition(rotateGizmo.targetNode); } } @@ -70,44 +70,16 @@ Node { copyRingProperties(rotRingZ) } - Rectangle { - id: angleLabel - color: "white" - x: rotateGizmo.currentMousePos.x - (10 + width) - y: rotateGizmo.currentMousePos.y - (10 + height) - width: gizmoLabelText.width + 4 - height: gizmoLabelText.height + 4 - border.width: 1 - visible: rotateGizmo.dragging - parent: rotateGizmo.view3D - - Text { - id: gizmoLabelText - text: { - var l = Qt.locale(); - if (rotateGizmo.targetNode) { - var degrees = currentAngle * (180 / Math.PI); - return qsTr(Number(degrees).toLocaleString(l, 'f', 1)); - } else { - return ""; - } - } - anchors.centerIn: parent - } - } - Node { id: rotNode - rotation: globalOrientation || !rotateGizmo.targetNode ? Qt.vector3d(0, 0, 0) + rotation: globalOrientation || !rotateGizmo.targetNode ? Qt.quaternion(1, 0, 0, 0) : rotateGizmo.targetNode.sceneRotation - rotationOrder: rotateGizmo.targetNode ? rotateGizmo.targetNode.rotationOrder : Node.YXZ - orientation: rotateGizmo.orientation visible: !rotateGizmo.dragging && !freeRotator.dragging RotateRing { id: rotRingX objectName: "Rotate Ring X" - rotation: Qt.vector3d(0, 90, 0) + eulerRotation: Qt.vector3d(0, 90, 0) targetNode: rotateGizmo.targetNode color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(1, 0, 0, 1)) : Qt.rgba(1, 0, 0, 1) @@ -125,7 +97,7 @@ Node { RotateRing { id: rotRingY objectName: "Rotate Ring Y" - rotation: Qt.vector3d(90, 0, 0) + eulerRotation: Qt.vector3d(90, 0, 0) targetNode: rotateGizmo.targetNode color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0.6, 0, 1)) : Qt.rgba(0, 0.6, 0, 1) @@ -145,7 +117,7 @@ Node { RotateRing { id: rotRingZ objectName: "Rotate Ring Z" - rotation: Qt.vector3d(0, 0, 0) + eulerRotation: Qt.vector3d(0, 0, 0) targetNode: rotateGizmo.targetNode color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0, 1, 1)) : Qt.rgba(0, 0, 1, 1) @@ -174,7 +146,6 @@ Node { view3D: rotateGizmo.view3D active: false visible: rotRingX.dragging || rotRingY.dragging || rotRingZ.dragging - orientation: rotateGizmo.orientation } RotateRing { @@ -223,16 +194,14 @@ Node { // Need to recreate vector as we need to adjust it and we can't do that on reference of // scenePosition, which is read-only property var scenePos = rotateGizmo.dragHelper.pivotScenePosition(rotateGizmo.targetNode); - if (rotateGizmo.targetNode && rotateGizmo.targetNode.orientation === Node.RightHanded) - scenePos.z = -scenePos.z _targetPosOnScreen = view3D.mapFrom3DScene(scenePos); _targetPosOnScreen.z = 0; _pointerPosPressed = Qt.vector3d(screenPos.x, screenPos.y, 0); // Recreate vector so we don't follow the changes in targetNode.rotation - _startRotation = Qt.vector3d(rotateGizmo.targetNode.rotation.x, - rotateGizmo.targetNode.rotation.y, - rotateGizmo.targetNode.rotation.z); + _startRotation = Qt.vector3d(rotateGizmo.targetNode.eulerRotation.x, + rotateGizmo.targetNode.eulerRotation.y, + rotateGizmo.targetNode.eulerRotation.z); dragging = true; } diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/RotateRing.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/RotateRing.qml index d5f9370a33d..fc803c679a2 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/RotateRing.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/RotateRing.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtQuick 2.0 -import QtQuick3D 1.0 +import QtQuick3D 1.15 import MouseArea3D 1.0 Model { @@ -80,18 +80,16 @@ Model { // Need to recreate vector as we need to adjust it and we can't do that on reference of // scenePosition, which is read-only property var scenePos = mouseAreaMain.pivotScenePosition(targetNode); - if (targetNode && targetNode.orientation === Node.RightHanded) - scenePos.z = -scenePos.z _targetPosOnScreen = view3D.mapFrom3DScene(scenePos); _targetPosOnScreen.z = 0; _pointerPosPressed = Qt.vector3d(screenPos.x, screenPos.y, 0); _trackBall = angle < 0.1; - // Recreate vector so we don't follow the changes in targetNode.rotation - _startRotation = Qt.vector3d(targetNode.rotation.x, - targetNode.rotation.y, - targetNode.rotation.z); + // Recreate vector so we don't follow the changes in targetNode.eulerRotation + _startRotation = Qt.vector3d(targetNode.eulerRotation.x, + targetNode.eulerRotation.y, + targetNode.eulerRotation.z); currentAngle = 0; currentMousePos = screenPos; } diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/ScaleGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/ScaleGizmo.qml index 7a45d370d55..ccfc45b6211 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/ScaleGizmo.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/ScaleGizmo.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtQuick 2.0 -import QtQuick3D 1.0 +import QtQuick3D 1.15 import MouseArea3D 1.0 Node { @@ -39,13 +39,13 @@ Node { property MouseArea3D dragHelper: null position: dragHelper.pivotScenePosition(targetNode) - orientation: targetNode ? targetNode.orientation : Node.LeftHanded onTargetNodeChanged: position = dragHelper.pivotScenePosition(targetNode) Connections { target: scaleGizmo.targetNode - onSceneTransformChanged: { + function onSceneTransformChanged() + { scaleGizmo.position = scaleGizmo.dragHelper.pivotScenePosition(scaleGizmo.targetNode); } } @@ -54,13 +54,11 @@ Node { signal scaleChange() Node { - rotation: !targetNode ? Qt.vector3d(0, 0, 0) : targetNode.sceneRotation - rotationOrder: scaleGizmo.targetNode ? scaleGizmo.targetNode.rotationOrder : Node.YXZ - orientation: scaleGizmo.orientation + rotation: !targetNode ? Qt.quaternion(1, 0, 0, 0) : targetNode.sceneRotation ScaleRod { id: scaleRodX - rotation: Qt.vector3d(0, 0, -90) + eulerRotation: Qt.vector3d(0, 0, -90) axis: Qt.vector3d(1, 0, 0) targetNode: scaleGizmo.targetNode color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(1, 0, 0, 1)) @@ -75,7 +73,7 @@ Node { ScaleRod { id: scaleRodY - rotation: Qt.vector3d(0, 0, 0) + eulerRotation: Qt.vector3d(0, 0, 0) axis: Qt.vector3d(0, 1, 0) targetNode: scaleGizmo.targetNode color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0.6, 0, 1)) @@ -90,7 +88,7 @@ Node { ScaleRod { id: scaleRodZ - rotation: Qt.vector3d(90, 0, 0) + eulerRotation: Qt.vector3d(90, 0, 0) axis: Qt.vector3d(0, 0, 1) targetNode: scaleGizmo.targetNode color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0, 1, 1)) @@ -109,7 +107,7 @@ Node { y: 10 z: 10 - rotation: Qt.vector3d(0, 90, 0) + eulerRotation: Qt.vector3d(0, 90, 0) axisX: Qt.vector3d(0, 0, -1) axisY: Qt.vector3d(0, 1, 0) targetNode: scaleGizmo.targetNode @@ -129,7 +127,7 @@ Node { x: 10 z: 10 - rotation: Qt.vector3d(90, 0, 0) + eulerRotation: Qt.vector3d(90, 0, 0) axisX: Qt.vector3d(1, 0, 0) axisY: Qt.vector3d(0, 0, 1) targetNode: scaleGizmo.targetNode @@ -149,7 +147,7 @@ Node { x: 10 y: 10 - rotation: Qt.vector3d(0, 0, 0) + eulerRotation: Qt.vector3d(0, 0, 0) axisX: Qt.vector3d(1, 0, 0) axisY: Qt.vector3d(0, 1, 0) targetNode: scaleGizmo.targetNode diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/ScaleRod.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/ScaleRod.qml index b3089b301ef..ead4f1458da 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/ScaleRod.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/ScaleRod.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtQuick 2.0 -import QtQuick3D 1.0 +import QtQuick3D 1.15 import MouseArea3D 1.0 DirectionalDraggable { diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/SceneView3D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/SceneView3D.qml index 5a57595dfbd..e44e9d95128 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/SceneView3D.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/SceneView3D.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtQuick 2.12 -import QtQuick3D 1.14 +import QtQuick3D 1.15 View3D { id: sceneView @@ -74,18 +74,18 @@ View3D { // point. PerspectiveCamera { id: scenePerspectiveCamera - z: -600 + z: 600 y: 600 - rotation.x: 45 + eulerRotation.x: -45 clipFar: 100000 clipNear: 1 } OrthographicCamera { id: sceneOrthoCamera - z: -600 + z: 600 y: 600 - rotation.x: 45 + eulerRotation.x: -45 clipFar: 100000 clipNear: -10000 } diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/SelectionBox.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/SelectionBox.qml index 10c443efce5..256cefa97b3 100644 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/SelectionBox.qml +++ b/share/qtcreator/qml/qmlpuppet/mockfiles/SelectionBox.qml @@ -24,7 +24,7 @@ ****************************************************************************/ import QtQuick 2.0 -import QtQuick3D 1.0 +import QtQuick3D 1.15 import SelectionBoxGeometry 1.0 Node { @@ -48,11 +48,9 @@ Node { geometry: selectionBoxGeometry scale: selectionBox.targetNode ? selectionBox.targetNode.scale : Qt.vector3d(1, 1, 1) - rotation: selectionBox.targetNode ? selectionBox.targetNode.rotation : Qt.vector3d(0, 0, 0) + rotation: selectionBox.targetNode ? selectionBox.targetNode.rotation : Qt.quaternion(1, 0, 0, 0) position: selectionBox.targetNode ? selectionBox.targetNode.position : Qt.vector3d(0, 0, 0) pivot: selectionBox.targetNode ? selectionBox.targetNode.pivot : Qt.vector3d(0, 0, 0) - orientation: selectionBox.targetNode ? selectionBox.targetNode.orientation : Node.LeftHanded - rotationOrder: selectionBox.targetNode ? selectionBox.targetNode.rotationOrder : Node.YXZ visible: selectionBox.targetNode && !selectionBoxGeometry.isEmpty diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp index c123a68d47d..30c2e3a2ec5 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp @@ -28,9 +28,9 @@ #include "selectionboxgeometry.h" +#include #include #include -#include #include #include #include @@ -85,17 +85,17 @@ void GeneralHelper::orbitCamera(QQuick3DCamera *camera, const QVector3D &startRo if (dragVector.length() < 0.001f) return; - camera->setRotation(startRotation); - QVector3D newRotation(dragVector.y(), dragVector.x(), 0.f); + camera->setEulerRotation(startRotation); + QVector3D newRotation(-dragVector.y(), -dragVector.x(), 0.f); newRotation *= 0.5f; // Emprically determined multiplier for nice drag newRotation += startRotation; - camera->setRotation(newRotation); + camera->setEulerRotation(newRotation); const QVector3D oldLookVector = camera->position() - lookAtPoint; QMatrix4x4 m = camera->sceneTransform(); const float *dataPtr(m.data()); - QVector3D newLookVector(-dataPtr[8], -dataPtr[9], -dataPtr[10]); + QVector3D newLookVector(dataPtr[8], dataPtr[9], dataPtr[10]); newLookVector.normalize(); newLookVector *= oldLookVector.length(); @@ -187,7 +187,6 @@ QVector4D GeneralHelper::focusObjectToCamera(QQuick3DCamera *camera, float defau // Adjust lookAt to look directly at the center of the object bounds lookAt = renderModel->globalTransform.map(center); - lookAt.setZ(-lookAt.z()); // Render node transforms have inverted z } } } @@ -196,7 +195,7 @@ QVector4D GeneralHelper::focusObjectToCamera(QQuick3DCamera *camera, float defau // Reset camera position to default zoom QMatrix4x4 m = camera->sceneTransform(); const float *dataPtr(m.data()); - QVector3D newLookVector(-dataPtr[8], -dataPtr[9], -dataPtr[10]); + QVector3D newLookVector(dataPtr[8], dataPtr[9], dataPtr[10]); newLookVector.normalize(); newLookVector *= defaultLookAtDistance; diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.cpp index 98da27f0a8c..cd2e890f86e 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.cpp @@ -81,10 +81,10 @@ QSSGRenderGraphObject *LineGeometry::updateSpatialNode(QSSGRenderGraphObject *no dataPtr[0] = m_startPos[0]; dataPtr[1] = m_startPos[1]; - dataPtr[2] = -m_startPos[2]; + dataPtr[2] = m_startPos[2]; dataPtr[3] = m_endPos[0]; dataPtr[4] = m_endPos[1]; - dataPtr[5] = -m_endPos[2]; + dataPtr[5] = m_endPos[2]; geometry->addAttribute(QSSGRenderGeometry::Attribute::PositionSemantic, 0, QSSGRenderGeometry::Attribute::ComponentType::F32Type); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/mousearea3d.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/mousearea3d.cpp index bfc2891ce7f..89c33c29005 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/mousearea3d.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/mousearea3d.cpp @@ -396,16 +396,12 @@ qreal QmlDesigner::Internal::MouseArea3D::getNewRotationAngle( if (dragVector.length() < 0.001f) return prevAngle; - // Get camera to node direction in node orientation + // Get camera to node direction QVector3D cameraToNodeDir = getCameraToNodeDir(node); if (trackBall) { // Only the distance in plane direction is relevant in trackball drag QVector3D dragDir = QVector3D::crossProduct(getNormal(), cameraToNodeDir).normalized(); QVector3D scenePos = pivotScenePosition(node); - if (node->orientation() == QQuick3DNode::RightHanded) { - scenePos.setZ(-scenePos.z()); - dragDir = -dragDir; - } QVector3D screenDragDir = m_view3D->mapFrom3DScene(scenePos + dragDir); screenDragDir.setZ(0); dragDir = (screenDragDir - nodePos).normalized(); @@ -420,12 +416,10 @@ qreal QmlDesigner::Internal::MouseArea3D::getNewRotationAngle( // Determine drag direction left/right QVector3D dragNormal = QVector3D::crossProduct(nodeToPress, nodeToCurrent).normalized(); - if (node->orientation() == QQuick3DNode::RightHanded) - dragNormal = -dragNormal; angle *= QVector3D::dotProduct(QVector3D(0.f, 0.f, 1.f), dragNormal) < 0 ? -1.0 : 1.0; // Determine drag ring orientation relative to camera - angle *= QVector3D::dotProduct(getNormal(), cameraToNodeDir) < 0 ? 1.0 : -1.0; + angle *= QVector3D::dotProduct(getNormal(), cameraToNodeDir) < 0 ? -1.0 : 1.0; qreal adjustedPrevAngle = prevAngle; const qreal PI_2 = M_PI * 2.0; @@ -451,10 +445,8 @@ void QmlDesigner::Internal::MouseArea3D::applyRotationAngleToNode( QQuick3DNode *node, const QVector3D &startRotation, qreal angle) { if (!qFuzzyIsNull(angle)) { - node->setRotation(startRotation); + node->setEulerRotation(startRotation); QVector3D normal = getNormal(); - if (orientation() != node->orientation()) - normal.setZ(-normal.z()); node->rotate(qRadiansToDegrees(angle), normal, QQuick3DNode::SceneSpace); } } @@ -468,20 +460,15 @@ void MouseArea3D::applyFreeRotation(QQuick3DNode *node, const QVector3D &startRo return; const float *dataPtr(sceneTransform().data()); - QVector3D xAxis = QVector3D(-dataPtr[0], -dataPtr[1], -dataPtr[2]).normalized(); - QVector3D yAxis = QVector3D(-dataPtr[4], -dataPtr[5], -dataPtr[6]).normalized(); - if (node->orientation() == QQuick3DNode::RightHanded) { - xAxis = QVector3D(-xAxis.x(), -xAxis.y(), xAxis.z()); - yAxis = QVector3D(-yAxis.x(), -yAxis.y(), yAxis.z()); - } - + QVector3D xAxis = QVector3D(dataPtr[0], dataPtr[1], dataPtr[2]).normalized(); + QVector3D yAxis = QVector3D(dataPtr[4], dataPtr[5], dataPtr[6]).normalized(); QVector3D finalAxis = (dragVector.x() * yAxis + dragVector.y() * xAxis); qreal degrees = qRadiansToDegrees(qreal(finalAxis.length()) * mouseDragMultiplier()); finalAxis.normalize(); - node->setRotation(startRotation); + node->setEulerRotation(startRotation); node->rotate(degrees, finalAxis, QQuick3DNode::SceneSpace); } @@ -513,8 +500,6 @@ double MouseArea3D::getRelativeScale(QQuick3DNode *node) const // view and scene, will tell us what the distance independent scale should be. QVector3D nodePos(node->scenePosition()); - if (orientation() == QQuick3DNode::RightHanded) - nodePos.setZ(-nodePos.z()); DoubleVec3D posInView1(m_view3D->mapFrom3DScene(nodePos)); @@ -718,12 +703,9 @@ QVector3D MouseArea3D::getCameraToNodeDir(QQuick3DNode *node) const QVector3D dir; if (qobject_cast(m_view3D->camera())) { dir = -m_view3D->camera()->cameraNode()->getDirection(); - dir.setZ(-dir.z()); } else { QVector3D camPos = m_view3D->camera()->scenePosition(); QVector3D nodePos = pivotScenePosition(node); - if (node->orientation() == QQuick3DNode::RightHanded) - nodePos.setZ(-nodePos.z()); dir = (nodePos - camPos).normalized(); } return dir; diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.cpp index 9d8de9dc178..dcb768ce623 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.cpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include @@ -367,10 +367,6 @@ void SelectionBoxGeometry::trackNodeChanges(QQuick3DNode *node) this, &SelectionBoxGeometry::update, Qt::QueuedConnection); m_connections << QObject::connect(node, &QQuick3DNode::pivotChanged, this, &SelectionBoxGeometry::update, Qt::QueuedConnection); - m_connections << QObject::connect(node, &QQuick3DNode::orientationChanged, - this, &SelectionBoxGeometry::update, Qt::QueuedConnection); - m_connections << QObject::connect(node, &QQuick3DNode::rotationOrderChanged, - this, &SelectionBoxGeometry::update, Qt::QueuedConnection); } } diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri index 50c0bd41bb9..4fe46e29d83 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri @@ -1,6 +1,6 @@ INCLUDEPATH += $$PWD/ -qtHaveModule(quick3d) { +versionAtLeast(QT_VERSION, 5.15.0):qtHaveModule(quick3d) { QT *= quick3d-private DEFINES *= QUICK3D_MODULE } diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp index 3b8cb04a909..296a95e7856 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp @@ -174,6 +174,7 @@ void Qt5InformationNodeInstanceServer::createEditView3D() #ifdef QUICK3D_MODULE static bool showEditView = qEnvironmentVariableIsSet("QMLDESIGNER_QUICK3D_SHOW_EDIT_WINDOW"); + qmlRegisterRevision("MouseArea3D", 1, 0); qmlRegisterType("MouseArea3D", 1, 0, "MouseArea3D"); qmlRegisterType("CameraGeometry", 1, 0, "CameraGeometry"); qmlRegisterType("GridGeometry", 1, 0, "GridGeometry"); @@ -420,14 +421,22 @@ void Qt5InformationNodeInstanceServer::updateActiveSceneToEditView3D() sceneIdVar = QVariant::fromValue(sceneId); sceneIdProperty.write(sceneIdVar); - QQmlProperty sceneProperty(m_editView3DRootItem, "activeScene", context()); - sceneProperty.write(activeSceneVar); - - auto helper = qobject_cast(m_3dHelper); QVariantMap toolStates; - if (helper) - toolStates = helper->getToolStates(sceneId); - toolStates.insert("sceneInstanceId", QVariant::fromValue(sceneInstance.instanceId())); + + // if m_active3DScene is null, QQmlProperty::write() doesn't work so invoke the updateActiveScene + // qml method directly + if (!m_active3DScene) { + QMetaObject::invokeMethod(m_editView3DRootItem, "clearActiveScene", Qt::QueuedConnection); + toolStates.insert("sceneInstanceId", QVariant::fromValue(-1)); + } else { + QQmlProperty sceneProperty(m_editView3DRootItem, "activeScene", context()); + sceneProperty.write(activeSceneVar); + + auto helper = qobject_cast(m_3dHelper); + if (helper) + toolStates = helper->getToolStates(sceneId); + toolStates.insert("sceneInstanceId", QVariant::fromValue(sceneInstance.instanceId())); + } nodeInstanceClient()->handlePuppetToCreatorCommand({PuppetToCreatorCommand::ActiveSceneChanged, toolStates}); @@ -514,7 +523,6 @@ void Qt5InformationNodeInstanceServer::doRender3DEditView() { static bool showEditView = qEnvironmentVariableIsSet("QMLDESIGNER_QUICK3D_SHOW_EDIT_WINDOW"); if (m_editView3DRootItem && !showEditView) { - auto t = std::chrono::steady_clock::now(); if (!m_editView3DContentItem) { m_editView3DContentItem = QQmlProperty::read(m_editView3DRootItem, "contentItem").value(); if (m_editView3DContentItem) { @@ -544,10 +552,6 @@ void Qt5InformationNodeInstanceServer::doRender3DEditView() // send the rendered image to creator process nodeInstanceClient()->handlePuppetToCreatorCommand({PuppetToCreatorCommand::Render3DView, QVariant::fromValue(imgContainer)}); - qDebug() << "\x1b[42m \x1b[1m" << __FUNCTION__ - << ", t=" << std::chrono::duration_cast(std::chrono::steady_clock::now()-t).count() - << "\x1b[m"; - if (m_needRender) { m_renderTimer.start(0); m_needRender = false; @@ -880,32 +884,31 @@ void Qt5InformationNodeInstanceServer::setup3DEditView(const QList(m_3dHelper); - if (helper) { - auto it = toolStates.constBegin(); - while (it != toolStates.constEnd()) { - helper->initToolStates(it.key(), it.value()); - ++it; - } - helper->restoreWindowState(); - if (toolStates.contains(helper->globalStateId()) - && toolStates[helper->globalStateId()].contains("rootSize")) { - m_editView3DRootItem->setSize(toolStates[helper->globalStateId()]["rootSize"].value()); - } - } - - updateActiveSceneToEditView3D(); - - createCameraAndLightGizmos(instanceList); + createEditView3D(); + if (!m_editView3DRootItem) { + m_active3DScene = nullptr; + m_active3DView = nullptr; + return; } + + auto helper = qobject_cast(m_3dHelper); + if (helper) { + auto it = toolStates.constBegin(); + while (it != toolStates.constEnd()) { + helper->initToolStates(it.key(), it.value()); + ++it; + } + helper->restoreWindowState(); + if (toolStates.contains(helper->globalStateId()) + && toolStates[helper->globalStateId()].contains("rootSize")) { + m_editView3DRootItem->setSize(toolStates[helper->globalStateId()]["rootSize"].value()); + } + } + + updateActiveSceneToEditView3D(); + + createCameraAndLightGizmos(instanceList); #else Q_UNUSED(instanceList) Q_UNUSED(toolStates) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dnodeinstance.cpp index be4cf456580..960509ee4e0 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dnodeinstance.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dnodeinstance.cpp @@ -129,7 +129,7 @@ void Quick3DNodeInstance::setPickable(bool enable, bool checkParent, bool applyT checkChildren(node); } } - if (nodeType == QQuick3DObject::Model) + if (nodeType == QQuick3DObject::Type::Model) setPropertyVariant("pickable", enable); // allow 3D objects to receive mouse clicks } } diff --git a/share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc b/share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc index 749517125f5..ce71153ecc6 100644 --- a/share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc +++ b/share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc @@ -13,6 +13,7 @@ mockfiles/Arrow.qml mockfiles/AutoScaleHelper.qml mockfiles/MoveGizmo.qml + mockfiles/CameraFrustum.qml mockfiles/CameraGizmo.qml mockfiles/LightGizmo.qml mockfiles/IconGizmo.qml diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AdvancedSection.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AdvancedSection.qml index ab6b17dd12b..276284cfc99 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AdvancedSection.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/AdvancedSection.qml @@ -37,14 +37,17 @@ Section { Label { text: qsTr("Origin") + disabledState: !backendValues.transformOrigin.isAvailable } OriginControl { backendValue: backendValues.transformOrigin + enabled: backendValues.transformOrigin.isAvailable } Label { text: qsTr("Scale") + disabledState: !backendValues.scale.isAvailable } SecondColumnLayout { @@ -57,12 +60,14 @@ Section { minimumValue: -10 maximumValue: 10 Layout.preferredWidth: 140 + enabled: backendValues.scale.isAvailable } ExpandingSpacer { } } Label { text: qsTr("Rotation") + disabledState: !backendValues.rotation.isAvailable } SecondColumnLayout { SpinBox { @@ -73,6 +78,7 @@ Section { minimumValue: -360 maximumValue: 360 Layout.preferredWidth: 140 + enabled: backendValues.rotation.isAvailable } ExpandingSpacer { } @@ -110,12 +116,14 @@ Section { Label { visible: majorQtQuickVersion > 1 text: qsTr("Smooth") + disabledState: !backendValues.smooth.isAvailable } SecondColumnLayout { visible: majorQtQuickVersion > 1 CheckBox { backendValue: backendValues.smooth text: qsTr("Smooth sampling active") + enabled: backendValues.smooth.isAvailable } ExpandingSpacer { } @@ -124,12 +132,14 @@ Section { Label { visible: majorQtQuickVersion > 1 text: qsTr("Antialiasing") + disabledState: !backendValues.antialiasing.isAvailable } SecondColumnLayout { visible: majorQtQuickVersion > 1 CheckBox { backendValue: backendValues.antialiasing text: qsTr("Anti-aliasing active") + enabled: backendValues.antialiasing.isAvailable } ExpandingSpacer { } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayerSection.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayerSection.qml index 4db19fe275f..b95312f1484 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayerSection.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/LayerSection.qml @@ -31,6 +31,7 @@ Section { anchors.left: parent.left anchors.right: parent.right caption: qsTr("Layer") + visible: backendValues.layer_effect.isAvailable SectionLayout { columns: 2 diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/RectangleSpecifics.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/RectangleSpecifics.qml index 65704972975..0fa2b331a8c 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/RectangleSpecifics.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/QtQuick/RectangleSpecifics.qml @@ -50,6 +50,7 @@ Column { anchors.left: parent.left anchors.right: parent.right caption: qsTr("Border Color") + visible: backendValues.border_color.isAvailable ColorEditor { caption: qsTr("Border Color") @@ -63,6 +64,7 @@ Column { anchors.left: parent.left anchors.right: parent.right caption: "Rectangle" + visible: backendValues.border_color.isAvailable SectionLayout { rows: 2 diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/Label.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/Label.qml index 127ffa6ac9d..6a14e7f68cc 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/Label.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/Label.qml @@ -37,7 +37,8 @@ Label { property alias toolTip: toolTipArea.tooltip width: Math.max(Math.min(240, parent.width - 280), 50) - color: StudioTheme.Values.themeTextColor + color: label.disabledState ? StudioTheme.Values.themeDisabledTextColor : StudioTheme.Values.themeTextColor + elide: Text.ElideRight font.pixelSize: StudioTheme.Values.myFontSize @@ -46,9 +47,27 @@ Label { Layout.minimumWidth: width Layout.maximumWidth: width + leftPadding: label.disabledState ? 10 : 0 + rightPadding: label.disabledState ? 10 : 0 + + property bool disabledState: false + + Text { + text: "[" + color: StudioTheme.Values.themeTextColor//StudioTheme.Values.themeDisabledTextColor + visible: label.disabledState + } + + Text { + text: "]" + color: StudioTheme.Values.themeTextColor//StudioTheme.Values.themeDisabledTextColor// + visible: label.disabledState + x: label.contentWidth + 10 + contentWidth + } + ToolTipArea { id: toolTipArea anchors.fill: parent - tooltip: label.text + tooltip: label.disabledState ? qsTr("This property is not available in this configuration.") : label.text } } diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/OriginControl.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/OriginControl.qml index da2f2cac88d..a6db34f4f16 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/OriginControl.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/OriginControl.qml @@ -42,6 +42,8 @@ Item { readonly property color selectedColor: Theme.qmlDesignerBackgroundColorDarkAlternate() readonly property color unselectedColor: Theme.qmlDesignerBackgroundColorDarker() + property bool enabled: true + ExtendedFunctionLogic { id: extFuncLogic backendValue: originControl.backendValue @@ -69,6 +71,7 @@ Item { } Grid { + opacity: originControl.enabled ? 1 : 0.5 rows: 3 columns: 3 spacing: 5 @@ -76,7 +79,8 @@ Item { id: grid function setValue(myValue) { - originControl.backendValue.setEnumeration("Item", myValue) + if (originControl.enabled) + originControl.backendValue.setEnumeration("Item", myValue) } function select(myValue) { diff --git a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/Values.qml b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/Values.qml index ff10e1e79f5..3f432d40808 100644 --- a/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/Values.qml +++ b/share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/Values.qml @@ -84,6 +84,7 @@ QtObject { property string themeControlBackground: "#242424" property string themeControlOutline: "#404040" property string themeTextColor: "#ffffff" + property string themeDisabledTextColor: "#909090" property string themePanelBackground: "#2a2a2a" property string themeHoverHighlight: "#313131" diff --git a/src/libs/advanceddockingsystem/dockareatabbar.cpp b/src/libs/advanceddockingsystem/dockareatabbar.cpp index 6c98ebe4fc0..02d2ae19cde 100644 --- a/src/libs/advanceddockingsystem/dockareatabbar.cpp +++ b/src/libs/advanceddockingsystem/dockareatabbar.cpp @@ -59,12 +59,13 @@ namespace ADS /** * Private data class of DockAreaTabBar class (pimpl) */ - struct DockAreaTabBarPrivate + class DockAreaTabBarPrivate { + public: DockAreaTabBar *q; - DockAreaWidget *m_dockArea; - QWidget *m_tabsContainerWidget; - QBoxLayout *m_tabsLayout; + DockAreaWidget *m_dockArea = nullptr; + QWidget *m_tabsContainerWidget = nullptr; + QBoxLayout *m_tabsLayout = nullptr; int m_currentIndex = -1; /** @@ -87,8 +88,7 @@ namespace ADS * Convenience function to access last tab */ DockWidgetTab *lastTab() const {return q->tab(q->count() - 1);} - }; - // struct DockAreaTabBarPrivate + }; // class DockAreaTabBarPrivate DockAreaTabBarPrivate::DockAreaTabBarPrivate(DockAreaTabBar *parent) : q(parent) diff --git a/src/libs/advanceddockingsystem/dockareatabbar.h b/src/libs/advanceddockingsystem/dockareatabbar.h index 991286c45ee..79373ba2774 100644 --- a/src/libs/advanceddockingsystem/dockareatabbar.h +++ b/src/libs/advanceddockingsystem/dockareatabbar.h @@ -43,7 +43,7 @@ namespace ADS { class DockAreaWidget; class DockWidgetTab; -struct DockAreaTabBarPrivate; +class DockAreaTabBarPrivate; class DockAreaTitleBar; class FloatingDockContainer; class AbstractFloatingWidget; @@ -62,7 +62,7 @@ class ADS_EXPORT DockAreaTabBar : public QScrollArea Q_OBJECT private: DockAreaTabBarPrivate *d; ///< private data (pimpl) - friend struct DockAreaTabBarPrivate; + friend class DockAreaTabBarPrivate; friend class DockAreaTitleBar; void onTabClicked(); diff --git a/src/libs/advanceddockingsystem/dockareatitlebar.cpp b/src/libs/advanceddockingsystem/dockareatitlebar.cpp index a24055d194f..9ee647265d9 100644 --- a/src/libs/advanceddockingsystem/dockareatitlebar.cpp +++ b/src/libs/advanceddockingsystem/dockareatitlebar.cpp @@ -64,17 +64,17 @@ namespace ADS /** * Private data class of DockAreaTitleBar class (pimpl) */ - struct DockAreaTitleBarPrivate + class DockAreaTitleBarPrivate { + public: DockAreaTitleBar *q; QPointer m_tabsMenuButton; QPointer m_undockButton; QPointer m_closeButton; - QBoxLayout *m_layout; - DockAreaWidget *m_dockArea; - DockAreaTabBar *m_tabBar; + QBoxLayout *m_layout = nullptr; + DockAreaWidget *m_dockArea = nullptr; + DockAreaTabBar *m_tabBar = nullptr; bool m_menuOutdated = true; - QMenu *m_tabsMenu; QList m_dockWidgetActionsButtons; QPoint m_dragStartMousePos; @@ -124,8 +124,7 @@ namespace ADS * Makes the dock area floating */ AbstractFloatingWidget *makeAreaFloating(const QPoint &offset, eDragState dragState); - }; // struct DockAreaTitleBarPrivate - + }; // class DockAreaTitleBarPrivate DockAreaTitleBarPrivate::DockAreaTitleBarPrivate(DockAreaTitleBar *parent) : q(parent) diff --git a/src/libs/advanceddockingsystem/dockareatitlebar.h b/src/libs/advanceddockingsystem/dockareatitlebar.h index 482816a34ee..710249911b0 100644 --- a/src/libs/advanceddockingsystem/dockareatitlebar.h +++ b/src/libs/advanceddockingsystem/dockareatitlebar.h @@ -48,7 +48,7 @@ namespace ADS { class DockAreaTabBar; class DockAreaWidget; -struct DockAreaTitleBarPrivate; +class DockAreaTitleBarPrivate; using TitleBarButtonType = QToolButton; @@ -106,7 +106,7 @@ class ADS_EXPORT DockAreaTitleBar : public QFrame Q_OBJECT private: DockAreaTitleBarPrivate *d; ///< private data (pimpl) - friend struct DockAreaTitleBarPrivate; + friend class DockAreaTitleBarPrivate; void onTabsMenuAboutToShow(); void onCloseButtonClicked(); diff --git a/src/libs/advanceddockingsystem/dockareawidget.h b/src/libs/advanceddockingsystem/dockareawidget.h index fab47e94769..9c23584ae78 100644 --- a/src/libs/advanceddockingsystem/dockareawidget.h +++ b/src/libs/advanceddockingsystem/dockareawidget.h @@ -67,9 +67,9 @@ private: friend class DockContainerWidget; friend class DockContainerWidgetPrivate; friend class DockWidgetTab; - friend struct DockWidgetPrivate; + friend class DockWidgetPrivate; friend class DockWidget; - friend struct DockManagerPrivate; + friend class DockManagerPrivate; friend class DockManager; void onTabCloseRequested(int index); diff --git a/src/libs/advanceddockingsystem/dockcontainerwidget.h b/src/libs/advanceddockingsystem/dockcontainerwidget.h index 497b4caa194..41d1d2f0ba2 100644 --- a/src/libs/advanceddockingsystem/dockcontainerwidget.h +++ b/src/libs/advanceddockingsystem/dockcontainerwidget.h @@ -50,12 +50,12 @@ class DockContainerWidgetPrivate; class DockAreaWidget; class DockWidget; class DockManager; -struct DockManagerPrivate; +class DockManagerPrivate; class FloatingDockContainer; -struct FloatingDockContainerPrivate; +class FloatingDockContainerPrivate; class FloatingDragPreview; -struct FloatingDragPreviewPrivate; class DockingStateReader; +class FloatingDragPreviewPrivate; /** * Container that manages a number of dock areas with single dock widgets @@ -71,14 +71,14 @@ private: DockContainerWidgetPrivate *d; ///< private data (pimpl) friend class DockContainerWidgetPrivate; friend class DockManager; - friend struct DockManagerPrivate; + friend class DockManagerPrivate; friend class DockAreaWidget; friend struct DockAreaWidgetPrivate; friend class FloatingDockContainer; - friend struct FloatingDockContainerPrivate; + friend class FloatingDockContainerPrivate; friend class DockWidget; friend class FloatingDragPreview; - friend struct FloatingDragPreviewPrivate; + friend class FloatingDragPreviewPrivate; protected: /** diff --git a/src/libs/advanceddockingsystem/dockmanager.cpp b/src/libs/advanceddockingsystem/dockmanager.cpp index 4e1554dff22..63c71c7a8ad 100644 --- a/src/libs/advanceddockingsystem/dockmanager.cpp +++ b/src/libs/advanceddockingsystem/dockmanager.cpp @@ -77,13 +77,14 @@ namespace ADS /** * Private data class of DockManager class (pimpl) */ - struct DockManagerPrivate + class DockManagerPrivate { + public: DockManager *q; QList m_floatingWidgets; QList m_containers; - DockOverlay *m_containerOverlay; - DockOverlay *m_dockAreaOverlay; + DockOverlay *m_containerOverlay = nullptr; + DockOverlay *m_dockAreaOverlay = nullptr; QMap m_dockWidgetsMap; bool m_restoringState = false; QVector m_uninitializedFloatingWidgets; @@ -94,7 +95,7 @@ namespace ADS QHash m_workspaceDateTimes; QString m_workspaceToRestoreAtStartup; bool m_autorestoreLastWorkspace; // This option is set in the Workspace Manager! - QSettings *m_settings; + QSettings *m_settings = nullptr; /** * Private data constructor @@ -144,8 +145,7 @@ namespace ADS bool restoreContainer(int index, DockingStateReader &stream, bool testing); void workspaceLoadingProgress(); - }; - // struct DockManagerPrivate + }; // class DockManagerPrivate DockManagerPrivate::DockManagerPrivate(DockManager *parent) : q(parent) @@ -188,6 +188,8 @@ namespace ADS } DockingStateReader stateReader(state); stateReader.readNextStartElement(); + if (!stateReader.readNextStartElement()) + return false; if (stateReader.name() != "QtAdvancedDockingSystem") { return false; } diff --git a/src/libs/advanceddockingsystem/dockmanager.h b/src/libs/advanceddockingsystem/dockmanager.h index a788e82d6a1..721f7e76027 100644 --- a/src/libs/advanceddockingsystem/dockmanager.h +++ b/src/libs/advanceddockingsystem/dockmanager.h @@ -66,16 +66,16 @@ const char STARTUP_WORKSPACE_SETTINGS_KEY[] = "QML/Designer/StartupWorkspace"; const char AUTO_RESTORE_WORKSPACE_SETTINGS_KEY[] = "QML/Designer/AutoRestoreLastWorkspace"; } // namespace Constants -struct DockManagerPrivate; +class DockManagerPrivate; class FloatingDockContainer; -struct FloatingDockContainerPrivate; +class FloatingDockContainerPrivate; class DockComponentsFactory; class DockContainerWidget; class DockContainerWidgetPrivate; class DockOverlay; class DockAreaTabBar; class DockWidgetTab; -struct DockWidgetTabPrivate; +class DockWidgetTabPrivate; struct DockAreaWidgetPrivate; class IconProvider; @@ -96,17 +96,17 @@ class ADS_EXPORT DockManager : public DockContainerWidget Q_OBJECT private: DockManagerPrivate *d; ///< private data (pimpl) - friend struct DockManagerPrivate; + friend class DockManagerPrivate; friend class FloatingDockContainer; - friend struct FloatingDockContainerPrivate; + friend class FloatingDockContainerPrivate; friend class DockContainerWidget; friend class DockContainerWidgetPrivate; friend class DockAreaTabBar; friend class DockWidgetTab; friend struct DockAreaWidgetPrivate; - friend struct DockWidgetTabPrivate; + friend class DockWidgetTabPrivate; friend class FloatingDragPreview; - friend struct FloatingDragPreviewPrivate; + friend class FloatingDragPreviewPrivate; friend class DockAreaTitleBar; protected: diff --git a/src/libs/advanceddockingsystem/dockoverlay.cpp b/src/libs/advanceddockingsystem/dockoverlay.cpp index a42962a5f56..e80fcbba8b0 100644 --- a/src/libs/advanceddockingsystem/dockoverlay.cpp +++ b/src/libs/advanceddockingsystem/dockoverlay.cpp @@ -59,11 +59,12 @@ namespace ADS { /** * Private data class of DockOverlay */ - struct DockOverlayPrivate + class DockOverlayPrivate { + public: DockOverlay *q; DockWidgetAreas m_allowedAreas = InvalidDockWidgetArea; - DockOverlayCross *m_cross; + DockOverlayCross *m_cross = nullptr; QPointer m_targetWidget; DockWidgetArea m_lastLocation = InvalidDockWidgetArea; bool m_dropPreviewEnabled = true; @@ -81,13 +82,14 @@ namespace ADS { /** * Private data of DockOverlayCross class */ - struct DockOverlayCrossPrivate + class DockOverlayCrossPrivate { + public: DockOverlayCross *q; DockOverlay::eMode m_mode = DockOverlay::ModeDockAreaOverlay; - DockOverlay *m_dockOverlay; + DockOverlay *m_dockOverlay = nullptr; QHash m_dropIndicatorWidgets; - QGridLayout *m_gridLayout; + QGridLayout *m_gridLayout = nullptr; QColor m_iconColors[5]; bool m_updateRequired = false; double m_lastDevicePixelRatio = 0.1; @@ -335,7 +337,7 @@ namespace ADS { pixmap.setDevicePixelRatio(devicePixelRatio); return pixmap; } - }; + }; // class DockOverlayCrossPrivate DockOverlay::DockOverlay(QWidget *parent, eMode mode) : QFrame(parent) diff --git a/src/libs/advanceddockingsystem/dockoverlay.h b/src/libs/advanceddockingsystem/dockoverlay.h index 04f9d627510..6d1a1925127 100644 --- a/src/libs/advanceddockingsystem/dockoverlay.h +++ b/src/libs/advanceddockingsystem/dockoverlay.h @@ -48,7 +48,7 @@ QT_END_NAMESPACE namespace ADS { -struct DockOverlayPrivate; +class DockOverlayPrivate; class DockOverlayCross; /** @@ -60,7 +60,7 @@ class ADS_EXPORT DockOverlay : public QFrame Q_OBJECT private: DockOverlayPrivate *d; //< private data class - friend struct DockOverlayPrivate; + friend class DockOverlayPrivate; friend class DockOverlayCross; public: @@ -130,7 +130,7 @@ protected: virtual void hideEvent(QHideEvent *event) override; }; -struct DockOverlayCrossPrivate; +class DockOverlayCrossPrivate; /** * DockOverlayCross shows a cross with 5 different drop area possibilities. * I could have handled everything inside DockOverlay, but because of some @@ -176,7 +176,7 @@ public: private: DockOverlayCrossPrivate *d; - friend struct DockOverlayCrossPrivate; + friend class DockOverlayCrossPrivate; friend class DockOverlay; protected: diff --git a/src/libs/advanceddockingsystem/dockwidget.cpp b/src/libs/advanceddockingsystem/dockwidget.cpp index 5b4ff87265d..760f425ae78 100644 --- a/src/libs/advanceddockingsystem/dockwidget.cpp +++ b/src/libs/advanceddockingsystem/dockwidget.cpp @@ -63,8 +63,9 @@ namespace ADS /** * Private data class of DockWidget class (pimpl) */ - struct DockWidgetPrivate + class DockWidgetPrivate { + public: DockWidget *q = nullptr; QBoxLayout *m_layout = nullptr; QWidget *m_widget = nullptr; @@ -114,8 +115,7 @@ namespace ADS * Setup the main scroll area */ void setupScrollArea(); - }; - // struct DockWidgetPrivate + }; // class DockWidgetPrivate DockWidgetPrivate::DockWidgetPrivate(DockWidget *parent) : q(parent) @@ -336,9 +336,9 @@ namespace ADS void DockWidget::toggleViewInternal(bool open) { - DockContainerWidget *dockContainerWidget = dockContainer(); - DockWidget *topLevelDockWidgetBefore = dockContainerWidget - ? dockContainerWidget->topLevelDockWidget() + const DockContainerWidget *const beforeDockContainerWidget = dockContainer(); + DockWidget *topLevelDockWidgetBefore = beforeDockContainerWidget + ? beforeDockContainerWidget->topLevelDockWidget() : nullptr; if (open) { @@ -359,12 +359,14 @@ namespace ADS // Here we need to call the dockContainer() function again, because if // this dock widget was unassigned before the call to showDockWidget() then // it has a dock container now - dockContainerWidget = dockContainer(); + const DockContainerWidget *const dockContainerWidget = dockContainer(); DockWidget *topLevelDockWidgetAfter = dockContainerWidget ? dockContainerWidget->topLevelDockWidget() : nullptr; DockWidget::emitTopLevelEventForWidget(topLevelDockWidgetAfter, true); - FloatingDockContainer *floatingContainer = dockContainerWidget->floatingWidget(); + FloatingDockContainer *floatingContainer = dockContainerWidget + ? dockContainerWidget->floatingWidget() + : nullptr; if (floatingContainer) floatingContainer->updateWindowTitle(); diff --git a/src/libs/advanceddockingsystem/dockwidget.h b/src/libs/advanceddockingsystem/dockwidget.h index 56fbe4431f0..0d6efa28d02 100644 --- a/src/libs/advanceddockingsystem/dockwidget.h +++ b/src/libs/advanceddockingsystem/dockwidget.h @@ -46,7 +46,7 @@ QT_END_NAMESPACE namespace ADS { -struct DockWidgetPrivate; +class DockWidgetPrivate; class DockWidgetTab; class DockManager; class DockContainerWidget; @@ -63,7 +63,7 @@ class ADS_EXPORT DockWidget : public QFrame Q_OBJECT private: DockWidgetPrivate *d; ///< private data (pimpl) - friend struct DockWidgetPrivate; + friend class DockWidgetPrivate; /** * Adjusts the toolbar icon sizes according to the floating state @@ -75,12 +75,12 @@ protected: friend class DockAreaWidget; friend class FloatingDockContainer; friend class DockManager; - friend struct DockManagerPrivate; + friend class DockManagerPrivate; friend class DockContainerWidgetPrivate; friend class DockAreaTabBar; friend class DockWidgetTab; - friend struct DockWidgetTabPrivate; - friend struct DockAreaTitleBarPrivate; + friend class DockWidgetTabPrivate; + friend class DockAreaTitleBarPrivate; /** * Assigns the dock manager that manages this dock widget diff --git a/src/libs/advanceddockingsystem/dockwidgettab.cpp b/src/libs/advanceddockingsystem/dockwidgettab.cpp index c82fc877c5b..611580d3685 100644 --- a/src/libs/advanceddockingsystem/dockwidgettab.cpp +++ b/src/libs/advanceddockingsystem/dockwidgettab.cpp @@ -67,12 +67,13 @@ namespace ADS /** * Private data class of DockWidgetTab class (pimpl) */ - struct DockWidgetTabPrivate + class DockWidgetTabPrivate { + public: DockWidgetTab *q; - DockWidget *m_dockWidget; + DockWidget *m_dockWidget = nullptr; QLabel *m_iconLabel = nullptr; - TabLabelType *m_titleLabel; + TabLabelType *m_titleLabel = nullptr; QPoint m_globalDragStartMousePosition; QPoint m_dragStartMousePosition; bool m_isActiveTab = false; @@ -81,7 +82,6 @@ namespace ADS AbstractFloatingWidget *m_floatingWidget = nullptr; QIcon m_icon; QAbstractButton *m_closeButton = nullptr; - QSpacerItem *m_iconTextSpacer; QPoint m_tabDragStartPosition; /** @@ -155,8 +155,7 @@ namespace ADS m_globalDragStartMousePosition = globalPos; m_dragStartMousePosition = q->mapFromGlobal(globalPos); } - }; - // struct DockWidgetTabPrivate + }; // class DockWidgetTabPrivate DockWidgetTabPrivate::DockWidgetTabPrivate(DockWidgetTab *parent) : q(parent) diff --git a/src/libs/advanceddockingsystem/dockwidgettab.h b/src/libs/advanceddockingsystem/dockwidgettab.h index 95e973fc4f1..500cf529f1c 100644 --- a/src/libs/advanceddockingsystem/dockwidgettab.h +++ b/src/libs/advanceddockingsystem/dockwidgettab.h @@ -43,7 +43,7 @@ namespace ADS { class DockWidget; class DockAreaWidget; -struct DockWidgetTabPrivate; +class DockWidgetTabPrivate; /** * A dock widget tab that shows a title and an icon. @@ -57,7 +57,7 @@ class ADS_EXPORT DockWidgetTab : public QFrame private: DockWidgetTabPrivate *d; ///< private data (pimpl) - friend struct DockWidgetTabPrivate; + friend class DockWidgetTabPrivate; friend class DockWidget; void onDockWidgetFeaturesChanged(); void detachDockWidget(); diff --git a/src/libs/advanceddockingsystem/floatingdockcontainer.cpp b/src/libs/advanceddockingsystem/floatingdockcontainer.cpp index 6bf2d9efbdc..c245dcb2066 100644 --- a/src/libs/advanceddockingsystem/floatingdockcontainer.cpp +++ b/src/libs/advanceddockingsystem/floatingdockcontainer.cpp @@ -62,10 +62,11 @@ namespace ADS /** * Private data class of FloatingDockContainer class (pimpl) */ - struct FloatingDockContainerPrivate + class FloatingDockContainerPrivate { + public: FloatingDockContainer *q; - DockContainerWidget *m_dockContainer; + DockContainerWidget *m_dockContainer = nullptr; unsigned int m_zOrderIndex = ++zOrderCounter; QPointer m_dockManager; eDragState m_draggingState = DraggingInactive; @@ -125,8 +126,7 @@ namespace ADS q->setWindowIcon(QApplication::windowIcon()); } } - }; - // struct FloatingDockContainerPrivate + }; // class FloatingDockContainerPrivate FloatingDockContainerPrivate::FloatingDockContainerPrivate(FloatingDockContainer *parent) : q(parent) diff --git a/src/libs/advanceddockingsystem/floatingdockcontainer.h b/src/libs/advanceddockingsystem/floatingdockcontainer.h index 83be9c2662f..83ca1edddeb 100644 --- a/src/libs/advanceddockingsystem/floatingdockcontainer.h +++ b/src/libs/advanceddockingsystem/floatingdockcontainer.h @@ -48,18 +48,18 @@ using FloatingWidgetBaseType = QWidget; namespace ADS { -struct FloatingDockContainerPrivate; +class FloatingDockContainerPrivate; class DockManager; -struct DockManagerPrivate; +class DockManagerPrivate; class DockAreaWidget; class DockContainerWidget; class DockWidget; class DockManager; class DockAreaTabBar; class DockWidgetTab; -struct DockWidgetTabPrivate; +class DockWidgetTabPrivate; class DockAreaTitleBar; -struct DockAreaTitleBarPrivate; +class DockAreaTitleBarPrivate; class FloatingWidgetTitleBar; class DockingStateReader; @@ -111,14 +111,14 @@ class ADS_EXPORT FloatingDockContainer : public FloatingWidgetBaseType, Q_OBJECT private: FloatingDockContainerPrivate *d; ///< private data (pimpl) - friend struct FloatingDockContainerPrivate; + friend class FloatingDockContainerPrivate; friend class DockManager; - friend struct DockManagerPrivate; + friend class DockManagerPrivate; friend class DockAreaTabBar; - friend struct DockWidgetTabPrivate; + friend class DockWidgetTabPrivate; friend class DockWidgetTab; friend class DockAreaTitleBar; - friend struct DockAreaTitleBarPrivate; + friend class DockAreaTitleBarPrivate; friend class DockWidget; friend class DockAreaWidget; friend class FloatingWidgetTitleBar; diff --git a/src/libs/advanceddockingsystem/floatingdragpreview.cpp b/src/libs/advanceddockingsystem/floatingdragpreview.cpp index b54b6bfbf06..33e0a5ac346 100644 --- a/src/libs/advanceddockingsystem/floatingdragpreview.cpp +++ b/src/libs/advanceddockingsystem/floatingdragpreview.cpp @@ -56,16 +56,16 @@ namespace ADS /** * Private data class (pimpl) */ - struct FloatingDragPreviewPrivate + class FloatingDragPreviewPrivate { + public: FloatingDragPreview *q; - QWidget *m_content; + QWidget *m_content = nullptr; DockAreaWidget *m_contentSourceArea = nullptr; DockContainerWidget *m_contenSourceContainer = nullptr; QPoint m_dragStartMousePosition; - DockManager *m_dockManager; + DockManager *m_dockManager = nullptr; DockContainerWidget *m_dropContainer = nullptr; - qreal m_windowOpacity; bool m_hidden = false; QPixmap m_contentPreviewPixmap; @@ -91,8 +91,7 @@ namespace ADS m_dockManager->dockAreaOverlay()->hideOverlay(); q->close(); } - }; - // struct FloatingDragPreviewPrivate + }; // class FloatingDragPreviewPrivate void FloatingDragPreviewPrivate::updateDropOverlays(const QPoint &globalPosition) { diff --git a/src/libs/advanceddockingsystem/floatingdragpreview.h b/src/libs/advanceddockingsystem/floatingdragpreview.h index 2c0defba3b0..db1bca27894 100644 --- a/src/libs/advanceddockingsystem/floatingdragpreview.h +++ b/src/libs/advanceddockingsystem/floatingdragpreview.h @@ -43,7 +43,7 @@ namespace ADS { class DockWidget; class DockAreaWidget; -struct FloatingDragPreviewPrivate; +class FloatingDragPreviewPrivate; /** * A floating overlay is a temporary floating widget that is just used to @@ -56,7 +56,7 @@ class FloatingDragPreview : public QWidget, public AbstractFloatingWidget Q_OBJECT private: FloatingDragPreviewPrivate *d; - friend struct FloatingDragPreviewPrivate; + friend class FloatingDragPreviewPrivate; /** * Cancel non opaque undocking if application becomes inactive diff --git a/src/libs/advanceddockingsystem/linux/floatingwidgettitlebar.cpp b/src/libs/advanceddockingsystem/linux/floatingwidgettitlebar.cpp index 52eb6e784b5..64e71a3b1c3 100644 --- a/src/libs/advanceddockingsystem/linux/floatingwidgettitlebar.cpp +++ b/src/libs/advanceddockingsystem/linux/floatingwidgettitlebar.cpp @@ -46,11 +46,12 @@ using tCloseButton = QPushButton; /** * @brief Private data class of public interface CFloatingWidgetTitleBar */ -struct FloatingWidgetTitleBarPrivate +class FloatingWidgetTitleBarPrivate { +public: FloatingWidgetTitleBar *q; ///< public interface class QLabel *m_iconLabel = nullptr; - TabLabelType *m_titleLabel; + TabLabelType *m_titleLabel = nullptr; tCloseButton *m_closeButton = nullptr; FloatingDockContainer *m_floatingWidget = nullptr; eDragState m_dragState = DraggingInactive; diff --git a/src/libs/advanceddockingsystem/linux/floatingwidgettitlebar.h b/src/libs/advanceddockingsystem/linux/floatingwidgettitlebar.h index f35e096a68f..ed0c4202c93 100644 --- a/src/libs/advanceddockingsystem/linux/floatingwidgettitlebar.h +++ b/src/libs/advanceddockingsystem/linux/floatingwidgettitlebar.h @@ -30,7 +30,7 @@ namespace ADS { class FloatingDockContainer; -struct FloatingWidgetTitleBarPrivate; +class FloatingWidgetTitleBarPrivate; /** * Titlebar for floating widgets to capture non client are mouse events. diff --git a/src/libs/qmljs/CMakeLists.txt b/src/libs/qmljs/CMakeLists.txt index 5ccb629cb23..2c05b662c3b 100644 --- a/src/libs/qmljs/CMakeLists.txt +++ b/src/libs/qmljs/CMakeLists.txt @@ -4,7 +4,6 @@ add_qtc_library(QmlJS SOURCES jsoncheck.cpp jsoncheck.h parser/qmldirparser.cpp parser/qmldirparser_p.h - parser/qmlerror.cpp parser/qmlerror.h parser/qmljsast.cpp parser/qmljsast_p.h parser/qmljsastfwd_p.h parser/qmljsastvisitor.cpp parser/qmljsastvisitor_p.h @@ -15,6 +14,7 @@ add_qtc_library(QmlJS parser/qmljslexer.cpp parser/qmljslexer_p.h parser/qmljsmemorypool_p.h parser/qmljsparser.cpp parser/qmljsparser_p.h + parser/qmljssourcelocation_p.h persistenttrie.cpp persistenttrie.h qmljs_global.h qmljsbind.cpp qmljsbind.h diff --git a/src/libs/qmljs/jsoncheck.cpp b/src/libs/qmljs/jsoncheck.cpp index 15d0edb1a78..d2beb507cc9 100644 --- a/src/libs/qmljs/jsoncheck.cpp +++ b/src/libs/qmljs/jsoncheck.cpp @@ -310,6 +310,14 @@ bool JsonCheck::visit(StringLiteral *ast) return false; } +void JsonCheck::throwRecursionDepthError() +{ + analysis()->m_messages.append(Message(ErrHitMaximumRecursion, + SourceLocation(), + QString(), QString(), false)); + +} + static QString formatExpectedTypes(QStringList all) { all.removeDuplicates(); diff --git a/src/libs/qmljs/jsoncheck.h b/src/libs/qmljs/jsoncheck.h index e8efc8db190..9885ad2353d 100644 --- a/src/libs/qmljs/jsoncheck.h +++ b/src/libs/qmljs/jsoncheck.h @@ -59,6 +59,8 @@ private: bool visit(AST::NumericLiteral *ast) override; bool visit(AST::StringLiteral *ast) override; + void throwRecursionDepthError() override; + struct AnalysisData { AnalysisData() : m_ranking(0), m_hasMatch(false) {} @@ -71,12 +73,12 @@ private: }; void processSchema(AST::Node *ast); - bool proceedCheck(Utils::JsonValue::Kind kind, const AST::SourceLocation &location); + bool proceedCheck(Utils::JsonValue::Kind kind, const SourceLocation &location); AnalysisData *analysis(); Document::Ptr m_doc; - AST::SourceLocation m_firstLoc; + SourceLocation m_firstLoc; Utils::JsonSchema *m_schema; QStack m_analysis; }; diff --git a/src/libs/qmljs/parser/cmd.sed b/src/libs/qmljs/parser/cmd.sed index a9b8ac0a6e5..0e6fc698281 100644 --- a/src/libs/qmljs/parser/cmd.sed +++ b/src/libs/qmljs/parser/cmd.sed @@ -1,16 +1,25 @@ -s/private\/qdeclarative/qml/g +s/include */include "qmljs\/parser\/\1"/g +s/qtqmlcompilerglobal_p.h/qmljsglobal_p.h/g +s//"qmljsglobal_p.h"/g +s/Q_QMLCOMPILER_PRIVATE_EXPORT/QML_PARSER_EXPORT/g s/qqml/qml/g s/QDECLARATIVE/QML/g s/QQml/Qml/g s/QQMLJS/QMLJS/g s/Q_QML_EXPORT //g -s/Q_QML_PRIVATE_EXPORT/QML_PARSER_EXPORT/ +s/Q_QML_PRIVATE_EXPORT/QML_PARSER_EXPORT/g +s/QT_BEGIN_NAMESPACE/QT_QML_BEGIN_NAMESPACE/g +s/QT_END_NAMESPACE/QT_QML_END_NAMESPACE/g # adjust pri file s/ \$\$PWD\/qmljsglobal_p.h/ $$PWD\/qmljsglobal_p.h \\\ + $$PWD\/qmljssourcelocation_p.h \\\ + $$PWD\/qmljsmemorypool_p.h \\\ $$PWD\/qmldirparser_p.h \\\ - $$PWD\/qmlerror.h/ -s/ \$\$PWD\/qmljsparser.cpp/ $$PWD\/qmljsparser.cpp \\\ + $$PWD\/qmljsgrammar_p.h \\\ + $$PWD\/qmljsparser_p.h/ + +s/ \$\$PWD\/qmljslexer.cpp/ $$PWD\/qmljslexer.cpp \\\ $$PWD\/qmldirparser.cpp \\\ - $$PWD\/qmlerror.cpp/ -s/OTHER_FILES/DISTFILES/ + $$PWD\/qmljsgrammar.cpp \\\ + $$PWD\/qmljsparser.cpp/ diff --git a/src/libs/qmljs/parser/gen-parser.sh b/src/libs/qmljs/parser/gen-parser.sh index acd30d0906a..c78c307adcf 100755 --- a/src/libs/qmljs/parser/gen-parser.sh +++ b/src/libs/qmljs/parser/gen-parser.sh @@ -10,11 +10,12 @@ # cd src/libs/qmljs/parser # QTDIR=~/path/to/qtdeclarative-checkout ./gen-parser.sh -if [ -z "$QTDIR" ]; then - echo "Usage: QTDIR=~/path/to/qtdeclarative-checkout $0" 1>&2 +if [ -z "$QTDIR" -o -z "$QLALR" ]; then + echo "Usage: QTDIR=~/path/to/qtdeclarative-checkout QLALR=~/path/to/qlalr $0" 1>&2 exit 1 fi + me=$(dirname $0) for i in $QTDIR/src/qml/parser/*.{g,h,cpp,pri}; do @@ -23,22 +24,23 @@ for i in $QTDIR/src/qml/parser/*.{g,h,cpp,pri}; do fi done -for i in $QTDIR/src/qml/qml/qqml{error.{h,cpp},dirparser{_p.h,.cpp}}; do - sed -f $me/cmd.sed $i > $me/$(echo $(basename $i) | sed s/qqml/qml/) +for i in $QTDIR/src/qml/qmldirparser/*.{h,cpp}; do + if ! echo $i | grep -q qmljsglobal; then + sed -f $me/cmd.sed $i > $me/$(echo $(basename $i) | sed s/qqml/qml/) + fi done -# export QmlDirParser -perl -p -0777 -i -e 's/QT_BEGIN_NAMESPACE\n\nclass QmlError;\nclass QmlEngine;\nclass Q_AUTOTEST_EXPORT QmlDirParser/#include "qmljsglobal_p.h"\n\nQT_BEGIN_NAMESPACE\n\nclass QmlError;\nclass QmlEngine;\nclass QML_PARSER_EXPORT QmlDirParser/' qmldirparser_p.h -# export QmlJSGrammar -perl -p -0777 -i -e 's/#include \n\nQT_BEGIN_NAMESPACE\n\nclass QmlJSGrammar\n/#include "qmljsglobal_p.h"\n#include \n\nQT_BEGIN_NAMESPACE\n\nclass QML_PARSER_EXPORT QmlJSGrammar\n/' qmljsgrammar_p.h +for i in $QTDIR/src/qml/common/qqmljs{sourcelocation,memorypool}_p.h; do + sed -f $me/cmd.sed $i > $me/$(echo $(basename $i) | sed s/qqmljs/qmljs/) +done + +# remove qmlapiversion_p.h include +#include "qmlapiversion_p.h" +perl -p -0777 -i -e 's/#include \"qmlapiversion_p.h\"//' qmljsdiagnosticmessage_p.h # remove qmlglobal_p.h include perl -p -0777 -i -e 's/#include \"qmlglobal_p.h\"//' qmldirparser.cpp # remove qmlglobal_p.h include -perl -p -0777 -i -e 's/#include \"qmlglobal_p.h\"//' qmlerror.cpp -# remove qmlglobal_p.h include perl -p -0777 -i -e 's/#include \//' qmldirparser.cpp -# remove QtQml/qtqmlglobal.h include -perl -p -0777 -i -e 's/#include \//' qmlerror.h # replace private/qhashedstring_p.h include and QHashedStringRef perl -p -0777 -i -e 's/#include \//' qmldirparser_p.h perl -p -0777 -i -e 's/QHashedStringRef/QString/g' qmldirparser_p.h qmldirparser.cpp @@ -51,11 +53,15 @@ sed -i -e 's/chars.length()/chars.size()/' $me/qmljslexer.cpp sed -i -e 's/DiagnosticMessage::Error/Severity::Error/g' $me/qmljsparser.cpp sed -i -e 's/DiagnosticMessage::Warning/Severity::Warning/g' $me/qmljsparser.cpp sed -i -e 's/DiagnosticMessage::Warning/Severity::Warning/g' $me/qmljsparser_p.h -sed -i -e 's|#include ||g' $me/qmlerror.cpp sed -i -e 's|#include |#include |g' $me/qmljsengine_p.h sed -i -e 's|#include |#include |g' $me/qmljsengine_p.h sed -i -e 's/qt_qnan/qQNaN/' $me/qmljsengine_p.cpp sed -i -e 's|#include |#include |' $me/qmljsengine_p.cpp perl -p -0777 -i -e 's/QT_QML_BEGIN_NAMESPACE/#include \nQT_QML_BEGIN_NAMESPACE/' qmljsengine_p.h +patch -p1 < grammar.patch +$QLALR qmljs.g + ./changeLicense.py $me/../qmljs_global.h qml*.{cpp,h} + +patch -p1 < parser.patch diff --git a/src/libs/qmljs/parser/grammar.patch b/src/libs/qmljs/parser/grammar.patch new file mode 100644 index 00000000000..6189b89a905 --- /dev/null +++ b/src/libs/qmljs/parser/grammar.patch @@ -0,0 +1,21 @@ +diff -u parser-genOut/qmljs.g parser/qmljs.g +--- parser-genOut/qmljs.g 2020-03-02 13:53:50.000000000 +0100 ++++ parser/qmljs.g 2020-03-02 13:55:50.000000000 +0100 +@@ -379,7 +379,7 @@ + inline DiagnosticMessage diagnosticMessage() const + { + for (const DiagnosticMessage &d : diagnostic_messages) { +- if (d.type != QtWarningMsg) ++ if (d.kind != Severity::Warning) + return d; + } + +@@ -423,7 +423,7 @@ + DiagnosticMessage error; + error.loc = location; + error.message = message; +- error.type = kind; ++ error.kind = DiagnosticMessage::qtMsgTypeToKind(kind); + return error; + } + diff --git a/src/libs/qmljs/parser/parser.patch b/src/libs/qmljs/parser/parser.patch index c1bef1860c3..d8e530133e0 100644 --- a/src/libs/qmljs/parser/parser.patch +++ b/src/libs/qmljs/parser/parser.patch @@ -1,157 +1,83 @@ -diff --git a/src/libs/qmljs/parser/qmlerror.cpp b/src/libs/qmljs/parser/qmlerror.cpp -index d090a19..5ec311d 100644 ---- a/src/libs/qmljs/parser/qmlerror.cpp -+++ b/src/libs/qmljs/parser/qmlerror.cpp -@@ -65,6 +65,12 @@ QT_BEGIN_NAMESPACE +diff -u parser-genOut/qmljsgrammar.cpp parser/qmljsgrammar.cpp +--- parser-genOut/qmljsgrammar.cpp 2020-03-02 13:53:50.000000000 +0100 ++++ parser/qmljsgrammar.cpp 2020-03-02 14:16:26.000000000 +0100 +@@ -21,7 +21,8 @@ + ** information to ensure the GNU General Public License requirements will + ** be met: https://www.gnu.org/licenses/gpl-3.0.html. + ** +-***************************************************************************// This file was generated by qlalr - DO NOT EDIT! ++***************************************************************************/ ++// This file was generated by qlalr - DO NOT EDIT! + #include "qmljsgrammar_p.h" - \sa QQuickView::errors(), QmlComponent::errors() - */ -+ -+static quint16 qmlSourceCoordinate(int n) -+{ -+ return (n > 0 && n <= static_cast(USHRT_MAX)) ? static_cast(n) : 0; -+} -+ - class QmlErrorPrivate + const char *const QmlJSGrammar::spell [] = { +diff -u parser-genOut/qmljsgrammar_p.h parser/qmljsgrammar_p.h +--- parser/qmljsgrammar_p.h 2020-03-03 13:51:43.000000000 +0100 ++++ parser-fixed2/qmljsgrammar_p.h 2020-03-02 17:20:56.000000000 +0100 +@@ -21,11 +21,13 @@ + ** information to ensure the GNU General Public License requirements will + ** be met: https://www.gnu.org/licenses/gpl-3.0.html. + ** +-***************************************************************************// This file was generated by qlalr - DO NOT EDIT! ++***************************************************************************/ ++// This file was generated by qlalr - DO NOT EDIT! + #ifndef QMLJSGRAMMAR_P_H + #define QMLJSGRAMMAR_P_H ++#include "qmljsglobal_p.h" + +-class QmlJSGrammar ++class QML_PARSER_EXPORT QmlJSGrammar { public: -diff --git a/src/libs/qmljs/parser/qmljsengine_p.cpp b/src/libs/qmljs/parser/qmljsengine_p.cpp -index 1e22fa5..10fc3d1 100644 ---- a/src/libs/qmljs/parser/qmljsengine_p.cpp -+++ b/src/libs/qmljs/parser/qmljsengine_p.cpp -@@ -110,7 +110,7 @@ double integerFromString(const QString &str, int radix) - - - Engine::Engine() -- : _lexer(0) -+ : _lexer(0), _directives(0) - { } - - Engine::~Engine() -@@ -131,6 +131,12 @@ Lexer *Engine::lexer() const - void Engine::setLexer(Lexer *lexer) - { _lexer = lexer; } - -+void Engine::setDirectives(Directives *directives) -+{ _directives = directives; } -+ -+Directives *Engine::directives() const -+{ return _directives; } -+ - MemoryPool *Engine::pool() - { return &_pool; } - -diff --git a/src/libs/qmljs/parser/qmljsengine_p.h b/src/libs/qmljs/parser/qmljsengine_p.h -index b1f7e1a..29b69d1 100644 ---- a/src/libs/qmljs/parser/qmljsengine_p.h -+++ b/src/libs/qmljs/parser/qmljsengine_p.h -@@ -44,36 +44,35 @@ - #include "qmljsglobal_p.h" - #include "qmljsastfwd_p.h" - #include "qmljsmemorypool_p.h" -+#include - - #include - #include - --#include - QT_QML_BEGIN_NAMESPACE - + enum VariousConstants { +diff -u parser-genOut/qmljslexer_p.h parser/qmljslexer_p.h +--- parser-genOut/qmljslexer_p.h 2020-03-02 13:53:50.000000000 +0100 ++++ parser/qmljslexer_p.h 2020-03-02 13:55:13.000000000 +0100 +@@ -47,7 +47,7 @@ namespace QmlJS { - class Lexer; -+class Directives; - class MemoryPool; + class Engine; +-struct DiagnosticMessage; ++class DiagnosticMessage; + class Directives; - class QML_PARSER_EXPORT DiagnosticMessage - { - public: -- enum Kind { Warning, Error }; -- - DiagnosticMessage() -- : kind(Error) {} -+ : kind(Severity::Error) {} + class QML_PARSER_EXPORT Lexer: public QmlJSGrammar +diff -u parser-genOut/qmljsparser.cpp parser/qmljsparser.cpp +--- parser-genOut/qmljsparser.cpp 2020-03-02 13:53:50.000000000 +0100 ++++ parser/qmljsparser.cpp 2020-03-02 14:16:01.000000000 +0100 +@@ -22,5 +22,6 @@ + ** be met: https://www.gnu.org/licenses/gpl-3.0.html. + ** + ****************************************************************************/ ++#line 172 "qmljs.g" -- DiagnosticMessage(Kind kind, const AST::SourceLocation &loc, const QString &message) -+ DiagnosticMessage(Severity::Enum kind, const AST::SourceLocation &loc, const QString &message) - : kind(kind), loc(loc), message(message) {} + #include "qmljs/parser/qmljsengine_p.h" +diff -u parser-genOut/qmljsparser_p.h parser/qmljsparser_p.h +--- parser-genOut/qmljsparser_p.h 2020-03-02 13:53:50.000000000 +0100 ++++ parser/qmljsparser_p.h 2020-03-02 14:13:25.000000000 +0100 +@@ -22,6 +22,7 @@ + ** be met: https://www.gnu.org/licenses/gpl-3.0.html. + ** + ****************************************************************************/ ++#line 223 "qmljs.g" - bool isWarning() const -- { return kind == Warning; } -+ { return kind == Severity::Warning; } - bool isError() const -- { return kind == Error; } -+ { return kind == Severity::Error; } + // + +diff -u parser-genOut/parser.pri parser/parser.pri +--- parser-genOut/parser.pri 2020-03-02 15:40:09.000000000 +0100 ++++ parser/parser.pri 2020-03-02 15:41:11.000000000 +0100 +@@ -22,10 +22,10 @@ + $$PWD/qmljsparser.cpp \ -- Kind kind; -+ Severity::Enum kind; - AST::SourceLocation loc; - QString message; - }; -@@ -81,6 +80,7 @@ public: - class QML_PARSER_EXPORT Engine - { - Lexer *_lexer; -+ Directives *_directives; - MemoryPool _pool; - QList _comments; - QString _extraCode; -@@ -99,6 +99,9 @@ public: - Lexer *lexer() const; - void setLexer(Lexer *lexer); +-CONFIG += qlalr ++#CONFIG += qlalr + QLALRSOURCES = $$PWD/qmljs.g +-QMAKE_QLALRFLAGS = --no-debug --qt ++#QMAKE_QLALRFLAGS = --no-debug --qt -+ void setDirectives(Directives *directives); -+ Directives *directives() const; -+ - MemoryPool *pool(); + OTHER_FILES += $$QLALRSOURCES - inline QStringRef midRef(int position, int size) { return _code.midRef(position, size); } -diff --git a/src/libs/qmljs/parser/qmljslexer.cpp b/src/libs/qmljs/parser/qmljslexer.cpp -index 9698e9d..036be75 100644 ---- a/src/libs/qmljs/parser/qmljslexer.cpp -+++ b/src/libs/qmljs/parser/qmljslexer.cpp -@@ -345,7 +345,7 @@ static inline bool isIdentifierStart(QChar ch) - // fast path for ascii - if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || - (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || -- ch == '$' || ch == '_') -+ ch == QLatin1Char('$') || ch == QLatin1Char('_')) - return true; - - switch (ch.category()) { -@@ -368,7 +368,7 @@ static bool isIdentifierPart(QChar ch) - if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || - (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || - (ch.unicode() >= '0' && ch.unicode() <= '9') || -- ch == '$' || ch == '_' || -+ ch == QLatin1Char('$') || ch == QLatin1Char('_') || - ch.unicode() == 0x200c /* ZWNJ */ || ch.unicode() == 0x200d /* ZWJ */) - return true; - -diff --git a/src/libs/qmljs/parser/qmljsparser.cpp b/src/libs/qmljs/parser/qmljsparser.cpp -index 6e61637..e016b91 100644 ---- a/src/libs/qmljs/parser/qmljsparser.cpp -+++ b/src/libs/qmljs/parser/qmljsparser.cpp -@@ -157,7 +157,20 @@ bool Parser::parse(int startToken) - - token_buffer[0].token = startToken; - first_token = &token_buffer[0]; -- last_token = &token_buffer[1]; -+ if (startToken == T_FEED_JS_PROGRAM) { -+ Directives ignoreDirectives; -+ Directives *directives = driver->directives(); -+ if (!directives) -+ directives = &ignoreDirectives; -+ lexer->scanDirectives(directives); -+ token_buffer[1].token = lexer->tokenKind(); -+ token_buffer[1].dval = lexer->tokenValue(); -+ token_buffer[1].loc = location(lexer); -+ token_buffer[1].spell = lexer->tokenSpell(); -+ last_token = &token_buffer[2]; -+ } else { -+ last_token = &token_buffer[1]; -+ } - - tos = -1; - program = 0; + # make sure we install the headers generated by qlalr +-private_headers.CONFIG += no_check_exist ++#private_headers.CONFIG += no_check_exist diff --git a/src/libs/qmljs/parser/parser.pri b/src/libs/qmljs/parser/parser.pri index 7418ea56be2..0694a5188bd 100644 --- a/src/libs/qmljs/parser/parser.pri +++ b/src/libs/qmljs/parser/parser.pri @@ -3,30 +3,29 @@ HEADERS += \ $$PWD/qmljsastfwd_p.h \ $$PWD/qmljsastvisitor_p.h \ $$PWD/qmljsengine_p.h \ - $$PWD/qmljsgrammar_p.h \ $$PWD/qmljslexer_p.h \ - $$PWD/qmljsmemorypool_p.h \ - $$PWD/qmljsparser_p.h \ $$PWD/qmljsglobal_p.h \ + $$PWD/qmljssourcelocation_p.h \ + $$PWD/qmljsmemorypool_p.h \ $$PWD/qmldirparser_p.h \ - $$PWD/qmlerror.h \ + $$PWD/qmljsgrammar_p.h \ + $$PWD/qmljsparser_p.h \ $$PWD/qmljskeywords_p.h SOURCES += \ $$PWD/qmljsast.cpp \ $$PWD/qmljsastvisitor.cpp \ $$PWD/qmljsengine_p.cpp \ - $$PWD/qmljsgrammar.cpp \ $$PWD/qmljslexer.cpp \ - $$PWD/qmljsparser.cpp \ $$PWD/qmldirparser.cpp \ - $$PWD/qmlerror.cpp + $$PWD/qmljsgrammar.cpp \ + $$PWD/qmljsparser.cpp \ #CONFIG += qlalr QLALRSOURCES = $$PWD/qmljs.g #QMAKE_QLALRFLAGS = --no-debug --qt -DISTFILES += $$QLALRSOURCES +OTHER_FILES += $$QLALRSOURCES # make sure we install the headers generated by qlalr #private_headers.CONFIG += no_check_exist diff --git a/src/libs/qmljs/parser/qmldirparser.cpp b/src/libs/qmljs/parser/qmldirparser.cpp index d56affdbe12..003f4aa97bb 100644 --- a/src/libs/qmljs/parser/qmldirparser.cpp +++ b/src/libs/qmljs/parser/qmldirparser.cpp @@ -24,11 +24,10 @@ ****************************************************************************/ #include "qmldirparser_p.h" -#include "qmlerror.h" #include -QT_BEGIN_NAMESPACE +QT_QML_BEGIN_NAMESPACE static int parseInt(const QStringRef &str, bool *ok) { @@ -60,12 +59,18 @@ static bool parseVersion(const QString &str, int *major, int *minor) return false; } -QmlDirParser::QmlDirParser() : _designerSupported(false) -{ -} - -QmlDirParser::~QmlDirParser() +void QmlDirParser::clear() { + _errors.clear(); + _typeNamespace.clear(); + _components.clear(); + _dependencies.clear(); + _imports.clear(); + _scripts.clear(); + _plugins.clear(); + _designerSupported = false; + _typeInfos.clear(); + _className.clear(); } inline static void scanSpace(const QChar *&ch) { @@ -88,13 +93,6 @@ inline static void scanWord(const QChar *&ch) { */ bool QmlDirParser::parse(const QString &source) { - _errors.clear(); - _plugins.clear(); - _components.clear(); - _scripts.clear(); - _designerSupported = false; - _className.clear(); - quint16 lineNumber = 0; bool firstLine = true; @@ -193,7 +191,7 @@ bool QmlDirParser::parse(const QString &source) } Component entry(sections[1], sections[2], -1, -1); entry.internal = true; - _components.insertMulti(entry.typeName, entry); + _components.insert(entry.typeName, entry); } else if (sections[0] == QLatin1String("singleton")) { if (sectionCount < 3 || sectionCount > 4) { reportError(lineNumber, 0, @@ -204,7 +202,7 @@ bool QmlDirParser::parse(const QString &source) // singleton TestSingletonType TestSingletonType.qml Component entry(sections[1], sections[2], -1, -1); entry.singleton = true; - _components.insertMulti(entry.typeName, entry); + _components.insert(entry.typeName, entry); } else { // handle qmldir module listing case where singleton is defined in the following pattern: // singleton TestSingletonType 2.0 TestSingletonType20.qml @@ -213,7 +211,7 @@ bool QmlDirParser::parse(const QString &source) const QString &fileName = sections[3]; Component entry(sections[1], fileName, major, minor); entry.singleton = true; - _components.insertMulti(entry.typeName, entry); + _components.insert(entry.typeName, entry); } else { reportError(lineNumber, 0, QStringLiteral("invalid version %1, expected .").arg(sections[2])); } @@ -249,10 +247,17 @@ bool QmlDirParser::parse(const QString &source) } else { reportError(lineNumber, 0, QStringLiteral("invalid version %1, expected .").arg(sections[2])); } + } else if (sections[0] == QLatin1String("import")) { + if (sectionCount != 2) { + reportError(lineNumber, 0, + QStringLiteral("import requires 2 arguments, but %1 were provided").arg(sectionCount - 1)); + continue; + } + _imports << sections[1]; } else if (sectionCount == 2) { // No version specified (should only be used for relative qmldir files) const Component entry(sections[0], sections[1], -1, -1); - _components.insertMulti(entry.typeName, entry); + _components.insert(entry.typeName, entry); } else if (sectionCount == 3) { int major, minor; if (parseVersion(sections[1], &major, &minor)) { @@ -264,7 +269,7 @@ bool QmlDirParser::parse(const QString &source) _scripts.append(entry); } else { const Component entry(sections[0], fileName, major, minor); - _components.insertMulti(entry.typeName, entry); + _components.insert(entry.typeName, entry); } } else { reportError(lineNumber, 0, QStringLiteral("invalid version %1, expected .").arg(sections[1])); @@ -297,27 +302,20 @@ bool QmlDirParser::hasError() const return false; } -void QmlDirParser::setError(const QmlError &e) +void QmlDirParser::setError(const QmlJS::DiagnosticMessage &e) { _errors.clear(); - reportError(e.line(), e.column(), e.description()); + reportError(e.loc.startLine, e.loc.startColumn, e.message); } -QList QmlDirParser::errors(const QString &uri) const +QList QmlDirParser::errors(const QString &uri) const { - QUrl url(uri); - QList errors; + QList errors; const int numErrors = _errors.size(); errors.reserve(numErrors); for (int i = 0; i < numErrors; ++i) { - const QmlJS::DiagnosticMessage &msg = _errors.at(i); - QmlError e; - QString description = msg.message; - description.replace(QLatin1String("$$URI$$"), uri); - e.setDescription(description); - e.setUrl(url); - e.setLine(msg.loc.startLine); - e.setColumn(msg.loc.startColumn); + QmlJS::DiagnosticMessage e = _errors.at(i); + e.message.replace(QLatin1String("$$URI$$"), uri); errors << e; } return errors; @@ -338,7 +336,7 @@ QList QmlDirParser::plugins() const return _plugins; } -QHash QmlDirParser::components() const +QMultiHash QmlDirParser::components() const { return _components; } @@ -348,17 +346,20 @@ QHash QmlDirParser::dependencies() const return _dependencies; } +QStringList QmlDirParser::imports() const +{ + return _imports; +} + QList QmlDirParser::scripts() const { return _scripts; } -#ifdef QT_CREATOR QList QmlDirParser::typeInfos() const { return _typeInfos; } -#endif bool QmlDirParser::designerSupported() const { @@ -384,4 +385,4 @@ QDebug &operator<< (QDebug &debug, const QmlDirParser::Script &script) return debug << qPrintable(output); } -QT_END_NAMESPACE +QT_QML_END_NAMESPACE diff --git a/src/libs/qmljs/parser/qmldirparser_p.h b/src/libs/qmljs/parser/qmldirparser_p.h index a39bfff0d27..9b26d023510 100644 --- a/src/libs/qmljs/parser/qmldirparser_p.h +++ b/src/libs/qmljs/parser/qmldirparser_p.h @@ -39,34 +39,44 @@ #include #include #include -#include "qmljsengine_p.h" -#include "qmljsglobal_p.h" +#include "qmljs/parser/qmljsglobal_p.h" +#include "qmljs/parser/qmljsengine_p.h" +#include "qmljs/parser/qmljsdiagnosticmessage_p.h" -QT_BEGIN_NAMESPACE +QT_QML_BEGIN_NAMESPACE -class QmlError; class QmlEngine; class QML_PARSER_EXPORT QmlDirParser { public: - QmlDirParser(); - ~QmlDirParser(); - + void clear(); bool parse(const QString &source); bool hasError() const; - void setError(const QmlError &); - QList errors(const QString &uri) const; + void setError(const QmlJS::DiagnosticMessage &); + QList errors(const QString &uri) const; QString typeNamespace() const; void setTypeNamespace(const QString &s); + static void checkNonRelative(const char *item, const QString &typeName, const QString &fileName) + { + if (fileName.startsWith(QLatin1Char('/'))) { + qWarning() << item << typeName + << "is specified with non-relative URL" << fileName << "in a qmldir file." + << "URLs in qmldir files should be relative to the qmldir file's directory."; + } + } + struct Plugin { - Plugin() {} + Plugin() = default; Plugin(const QString &name, const QString &path) - : name(name), path(path) {} + : name(name), path(path) + { + checkNonRelative("Plugin", name, path); + } QString name; QString path; @@ -74,11 +84,14 @@ public: struct Component { - Component() {} + Component() = default; Component(const QString &typeName, const QString &fileName, int majorVersion, int minorVersion) : typeName(typeName), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion), - internal(false), singleton(false) {} + internal(false), singleton(false) + { + checkNonRelative("Component", typeName, fileName); + } QString typeName; QString fileName; @@ -90,10 +103,13 @@ public: struct Script { - Script() {} + Script() = default; Script(const QString &nameSpace, const QString &fileName, int majorVersion, int minorVersion) - : nameSpace(nameSpace), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion) {} + : nameSpace(nameSpace), fileName(fileName), majorVersion(majorVersion), minorVersion(minorVersion) + { + checkNonRelative("Script", nameSpace, fileName); + } QString nameSpace; QString fileName; @@ -101,16 +117,16 @@ public: int minorVersion = 0; }; - QHash components() const; + QMultiHash components() const; QHash dependencies() const; + QStringList imports() const; QList