diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 98f854d7..2b0a2eb8 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -17,10 +17,11 @@ jobs: - uses: actions/checkout@v2 - name: Install Qt - uses: jurplel/install-qt-action@v2 + uses: jurplel/install-qt-action@v3 with: - version: 5.15.2 # Update Qt version here. + version: 6.2.4 # Update Qt version here. aqtversion: '>=0.9.7' + modules: 'qtimageformats' - name: Install Boost shell: bash diff --git a/.github/workflows/build_mac.yml b/.github/workflows/build_mac.yml index b2234ebd..3def3109 100644 --- a/.github/workflows/build_mac.yml +++ b/.github/workflows/build_mac.yml @@ -17,10 +17,11 @@ jobs: - uses: actions/checkout@v2 - name: Install Qt - uses: jurplel/install-qt-action@v2 + uses: jurplel/install-qt-action@v3 with: - version: 5.15.2 # Update Qt version here. + version: 6.2.4 # Update Qt version here. aqtversion: '>=0.9.7' + modules: 'qtimageformats' - name: Build shell: bash diff --git a/.github/workflows/build_windows.yml b/.github/workflows/build_windows.yml index ab00faaf..1f523179 100644 --- a/.github/workflows/build_windows.yml +++ b/.github/workflows/build_windows.yml @@ -13,10 +13,11 @@ jobs: - uses: actions/checkout@v2 - name: Install Qt - uses: jurplel/install-qt-action@v2 + uses: jurplel/install-qt-action@v3 with: - version: 5.15.2 # Update Qt version here. + version: 6.2.4 # Update Qt version here. aqtversion: '>=0.9.7' + modules: 'qtimageformats' - name: Install Boost shell: pwsh @@ -41,5 +42,5 @@ jobs: cd build cmake --build . --config $BUILD_TYPE --target DegateTests cd tests/out/bin/$BUILD_TYPE - $Qt5_Dir/bin/windeployqt.exe ./ + $Qt6_DIR/bin/windeployqt.exe ./ ./DegateTests.exe diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index b92437a7..90e2dbc5 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -55,7 +55,7 @@ jobs: - name: Install Qt uses: jurplel/install-qt-action@v2 with: - version: 5.15.2 # Update Qt version here. + version: 6.2.4 # Update Qt version here. aqtversion: '>=0.9.7' - name: Install Boost diff --git a/.github/workflows/deploy_linux.yml b/.github/workflows/deploy_linux.yml index 2962d1d6..11ec30e8 100644 --- a/.github/workflows/deploy_linux.yml +++ b/.github/workflows/deploy_linux.yml @@ -8,16 +8,17 @@ env: jobs: build: - runs-on: ubuntu-18.04 # Update Ubuntu version here (might be the oldest LTS for AppImage creation). + runs-on: ubuntu-20.04 # Update Ubuntu version here (might be the oldest LTS for AppImage creation). steps: - uses: actions/checkout@v2 - name: Install Qt - uses: jurplel/install-qt-action@v2 + uses: jurplel/install-qt-action@v3 with: - version: 5.15.2 # Update Qt version here. + version: 6.2.4 # Update Qt version here. aqtversion: '>=0.9.7' + modules: 'qtimageformats' - name: Install Boost shell: pwsh @@ -80,10 +81,10 @@ jobs: run: | sudo apt install p7zip-full cd etc/installer - wget https://download.qt.io/online/qtsdkrepository/linux_x64/desktop/tools_ifw/qt.tools.ifw.44/4.4.1-0-202206210640ifw-linux-x64.7z - 7z x 4.4.1-0-202206210640ifw-linux-x64.7z -y - ./Tools/QtInstallerFramework/4.4/bin/binarycreator --offline-only -c config/config.xml -p packages "Degate_offline_installer_Linux_x64" - ./Tools/QtInstallerFramework/4.4/bin/binarycreator --online-only -c config/config.xml -p packages "Degate_online_installer_Linux_x64" + wget https://download.qt.io/online/qtsdkrepository/linux_x64/desktop/tools_ifw/qt.tools.ifw.46/4.6.0-0-202305221011ifw-linux-x64.7z + 7z x 4.6.0-0-202305221011ifw-linux-x64.7z -y + ./Tools/QtInstallerFramework/4.6/bin/binarycreator --offline-only -c config/config.xml -p packages "Degate_offline_installer_Linux_x64" + ./Tools/QtInstallerFramework/4.6/bin/binarycreator --online-only -c config/config.xml -p packages "Degate_online_installer_Linux_x64" - name: Upload Degate offline installer uses: actions/upload-artifact@v2 @@ -101,7 +102,7 @@ jobs: shell: bash run: | cd etc/installer - ./Tools/QtInstallerFramework/4.4/bin/repogen -p packages repository + ./Tools/QtInstallerFramework/4.6/bin/repogen -p packages repository - name: Upload Degate update uses: actions/upload-artifact@v2 diff --git a/.github/workflows/deploy_mac.yml b/.github/workflows/deploy_mac.yml index 2c5f06b5..2401bd29 100644 --- a/.github/workflows/deploy_mac.yml +++ b/.github/workflows/deploy_mac.yml @@ -14,10 +14,11 @@ jobs: - uses: actions/checkout@v2 - name: Install Qt - uses: jurplel/install-qt-action@v2 + uses: jurplel/install-qt-action@v3 with: - version: 5.15.2 # Update Qt version here. + version: 6.2.4 # Update Qt version here. aqtversion: '>=0.9.7' + modules: 'qtimageformats' - name: Build shell: bash @@ -31,7 +32,7 @@ jobs: shell: bash run: | cd build/out/bin/ - $Qt5_Dir/bin/macdeployqt ./Degate.app + $Qt6_DIR/bin/macdeployqt ./Degate.app - name: Upload Degate binaries uses: actions/upload-artifact@v2 @@ -47,10 +48,10 @@ jobs: brew install p7zip cp -R build/out/bin/ etc/installer/packages/Degate/data cd etc/installer - wget https://download.qt.io/online/qtsdkrepository/mac_x64/desktop/tools_ifw/qt.tools.ifw.44/4.4.1-0-202206210643ifw-mac-x64.7z - 7z x 4.4.1-0-202206210643ifw-mac-x64.7z -y - ./Tools/QtInstallerFramework/4.4/bin/binarycreator --offline-only -c config/config.xml -p packages "mac_deploy_offline/Degate_offline_installer_Mac_x64" - ./Tools/QtInstallerFramework/4.4/bin/binarycreator --online-only -c config/config.xml -p packages "mac_deploy_online/Degate_online_installer_Mac_x64" + wget https://download.qt.io/online/qtsdkrepository/mac_x64/desktop/tools_ifw/qt.tools.ifw.46/4.6.0-0-202305221011ifw-mac-x64.7z + 7z x 4.6.0-0-202305221011ifw-mac-x64.7z -y + ./Tools/QtInstallerFramework/4.6/bin/binarycreator --offline-only -c config/config.xml -p packages "mac_deploy_offline/Degate_offline_installer_Mac_x64" + ./Tools/QtInstallerFramework/4.6/bin/binarycreator --online-only -c config/config.xml -p packages "mac_deploy_online/Degate_online_installer_Mac_x64" - name: Upload Degate offline installer uses: actions/upload-artifact@v2 @@ -68,7 +69,7 @@ jobs: shell: bash run: | cd etc/installer - ./Tools/QtInstallerFramework/4.4/bin/repogen -p packages repository + ./Tools/QtInstallerFramework/4.6/bin/repogen -p packages repository - name: Upload Degate update uses: actions/upload-artifact@v2 diff --git a/.github/workflows/deploy_windows.yml b/.github/workflows/deploy_windows.yml index ba79eb4b..8107712a 100644 --- a/.github/workflows/deploy_windows.yml +++ b/.github/workflows/deploy_windows.yml @@ -13,10 +13,11 @@ jobs: - uses: actions/checkout@v2 - name: Install Qt - uses: jurplel/install-qt-action@v2 + uses: jurplel/install-qt-action@v3 with: - version: 5.15.2 # Update Qt version here. + version: 6.2.4 # Update Qt version here. aqtversion: '>=0.9.7' + modules: 'qtimageformats' - name: Install Boost shell: pwsh @@ -39,7 +40,7 @@ jobs: shell: bash run: | cd build/out/bin/$BUILD_TYPE - $Qt5_Dir/bin/windeployqt.exe ./ + $Qt6_DIR/bin/windeployqt.exe ./ - name: Upload Degate binaries uses: actions/upload-artifact@v2 @@ -61,10 +62,10 @@ jobs: # Update the Qt Installer Framework (ifw) version here (by providing the exe download link and changing the exe name/path). run: | cd etc/installer - C:\msys64\usr\bin\wget.exe https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/tools_ifw/qt.tools.ifw.44/4.4.1-0-202206210642ifw-win-x86.7z - 7z.exe x 4.4.1-0-202206210642ifw-win-x86.7z -y - .\Tools\QtInstallerFramework\4.4\bin\binarycreator.exe --offline-only -c config\config.xml -p packages "Degate_offline_installer_Windows_x64.exe" - .\Tools\QtInstallerFramework\4.4\bin\binarycreator.exe --online-only -c config\config.xml -p packages "Degate_online_installer_Windows_x64.exe" + C:\msys64\usr\bin\wget.exe https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/tools_ifw/qt.tools.ifw.46/4.6.0-0-202305221011ifw-win-x86.7z + 7z.exe x 4.6.0-0-202305221011ifw-win-x86.7z -y + .\Tools\QtInstallerFramework\4.6\bin\binarycreator.exe --offline-only -c config\config.xml -p packages "Degate_offline_installer_Windows_x64.exe" + .\Tools\QtInstallerFramework\4.6\bin\binarycreator.exe --online-only -c config\config.xml -p packages "Degate_online_installer_Windows_x64.exe" - name: Upload Degate offline installer uses: actions/upload-artifact@v2 @@ -82,7 +83,7 @@ jobs: shell: cmd run: | cd etc/installer - .\Tools\QtInstallerFramework\4.4\bin\repogen.exe -p packages repository + .\Tools\QtInstallerFramework\4.6\bin\repogen.exe -p packages repository - name: Upload Degate update uses: actions/upload-artifact@v2 diff --git a/CMakeLists.txt b/CMakeLists.txt index ed739c82..e6d02924 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ set(CMAKE_VERBOSE_MAKEFILE true) # Set flags # if (NOT MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g -fno-inline -std=c++11") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -g -fno-inline") else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") endif() @@ -85,8 +85,8 @@ include_directories(${Boost_INCLUDE_DIRS}) set(LIBS ${Boost_LIBRARIES}) ############# Qt -find_package(Qt5 COMPONENTS Core Widgets Gui Xml OpenGL Concurrent LinguistTools REQUIRED) -set(LIBS ${LIBS} Qt5::Widgets Qt5::Gui Qt5::Core Qt5::Xml Qt5::OpenGL Qt5::Concurrent) +find_package(Qt6 COMPONENTS Core Widgets Gui Xml OpenGL OpenGLWidgets Concurrent LinguistTools REQUIRED) +set(LIBS ${LIBS} Qt6::Widgets Qt6::Gui Qt6::Core Qt6::Xml Qt6::OpenGL Qt6::OpenGLWidgets Qt6::Concurrent) ############################################################################ @@ -96,12 +96,12 @@ set(LIBS ${LIBS} Qt5::Widgets Qt5::Gui Qt5::Core Qt5::Xml Qt5::OpenGL Qt5::Concu # # Configuration # -if (CMAKE_SIZEOF_VOID_P MATCHES 8) # if x64 - message(STATUS "x64 configuration") - set(CONFIGURATION "x64") -else() # if x86 - message(STATUS "x86 configuration") - set(CONFIGURATION "x86") +if (CMAKE_SIZEOF_VOID_P MATCHES 8) # if 64-bits + message(STATUS "64 bits configuration") + set(CONFIGURATION "BUILD_64") +else() # if 32-bits + message(STATUS "32 bits configuration") + set(CONFIGURATION "BUILD_32") endif() # @@ -147,10 +147,15 @@ SET(TRANSLATION_FILES list(TRANSFORM TRANSLATION_FILES PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/res/languages/) -# Redefine "qt5_create_translation" function because of a bug (it originally parse all boost files, and make the build VERY slow) -include(${CMAKE_CURRENT_SOURCE_DIR}/etc/cmake/Qt5LinguistToolsMacros.cmake) +# Redefine "qt6_create_translation" function because of a bug (it originally parse all boost files, and make the build VERY slow) +include(${CMAKE_CURRENT_SOURCE_DIR}/etc/cmake/Qt6LinguistToolsMacros.cmake) -qt5_create_translation(QM_FILES ${SRC_FILES} ${TRANSLATION_FILES} OPTIONS -no-obsolete) +# TODO: Figure out why this is needed. +if (WIN32) + qt6_create_translation(QM_FILES ${SRC_FILES} ${TRANSLATION_FILES}) +else () + qt6_create_translation(QM_FILES ${SRC_FILES} ${TRANSLATION_FILES} OPTIONS "-no-obsolete") +endif () configure_file(res/languages/translations.qrc ${CMAKE_BINARY_DIR} COPYONLY) diff --git a/etc/cmake/Qt5LinguistToolsMacros.cmake b/etc/cmake/Qt6LinguistToolsMacros.cmake similarity index 96% rename from etc/cmake/Qt5LinguistToolsMacros.cmake rename to etc/cmake/Qt6LinguistToolsMacros.cmake index 6e7fb6a0..7b7070fb 100644 --- a/etc/cmake/Qt5LinguistToolsMacros.cmake +++ b/etc/cmake/Qt6LinguistToolsMacros.cmake @@ -33,7 +33,7 @@ include(CMakeParseArguments) # redefine this function because of a bug (it originally parse all boost files, and make the build VERY slow) -function(QT5_CREATE_TRANSLATION _qm_files) +function(QT6_CREATE_TRANSLATION _qm_files) set(options) set(oneValueArgs) set(multiValueArgs OPTIONS) @@ -82,7 +82,7 @@ function(QT5_CREATE_TRANSLATION _qm_files) get_source_file_property(_qm_output_location ${_ts_file} OUTPUT_LOCATION) add_custom_command(OUTPUT ${_tmpts_file} - COMMAND ${Qt5_LUPDATE_EXECUTABLE} + COMMAND ${Qt6_LUPDATE_EXECUTABLE} ARGS ${_lupdate_options} "@${_ts_lst_file}" -ts ${_ts_file} COMMAND ${CMAKE_COMMAND} -E copy ${_ts_file} ${_tmpts_file} DEPENDS ${_my_sources} @@ -93,6 +93,6 @@ function(QT5_CREATE_TRANSLATION _qm_files) endif() endforeach() - qt5_add_translation(${_qm_files} ${_my_temptsfiles}) + qt6_add_translation(${_qm_files} ${_my_temptsfiles}) set(${_qm_files} ${${_qm_files}} PARENT_SCOPE) endfunction() diff --git a/src/Core/LogicModel/Gate/GateLibraryExporter.cc b/src/Core/LogicModel/Gate/GateLibraryExporter.cc index f8d00010..34e7b564 100644 --- a/src/Core/LogicModel/Gate/GateLibraryExporter.cc +++ b/src/Core/LogicModel/Gate/GateLibraryExporter.cc @@ -73,7 +73,7 @@ void GateLibraryExporter::export_data(std::string const& filename, GateLibrary_s } QTextStream stream(&file); - stream.setCodec("UTF-8"); + stream.setEncoding(QStringConverter::Utf8); stream << doc.toString(); file.close(); diff --git a/src/Core/LogicModel/LogicModelExporter.cc b/src/Core/LogicModel/LogicModelExporter.cc index f2d7ba5b..21abfc2d 100644 --- a/src/Core/LogicModel/LogicModelExporter.cc +++ b/src/Core/LogicModel/LogicModelExporter.cc @@ -130,7 +130,7 @@ void LogicModelExporter::export_data(std::string const& filename, LogicModel_shp } QTextStream stream(&file); - stream.setCodec("UTF-8"); + stream.setEncoding(QStringConverter::Utf8); stream << doc.toString(); file.close(); diff --git a/src/Core/Project/ProjectExporter.cc b/src/Core/Project/ProjectExporter.cc index a2ae7e29..64e859cb 100644 --- a/src/Core/Project/ProjectExporter.cc +++ b/src/Core/Project/ProjectExporter.cc @@ -106,7 +106,7 @@ void ProjectExporter::export_data(std::string const& filename, const Project_shp } QTextStream stream(&file); - stream.setCodec("UTF-8"); + stream.setEncoding(QStringConverter::Utf8); stream << doc.toString(); file.close(); diff --git a/src/Core/RuleCheck/RCVBlacklistExporter.cc b/src/Core/RuleCheck/RCVBlacklistExporter.cc index 9431e00b..bb819829 100644 --- a/src/Core/RuleCheck/RCVBlacklistExporter.cc +++ b/src/Core/RuleCheck/RCVBlacklistExporter.cc @@ -59,7 +59,7 @@ void RCVBlacklistExporter::export_data(std::string const& filename, } QTextStream stream(&file); - stream.setCodec("UTF-8"); + stream.setEncoding(QStringConverter::Utf8); stream << doc.toString(); file.close(); diff --git a/src/Core/Utils/MemoryMap.h b/src/Core/Utils/MemoryMap.h index af796693..aaeb345f 100644 --- a/src/Core/Utils/MemoryMap.h +++ b/src/Core/Utils/MemoryMap.h @@ -409,8 +409,17 @@ namespace degate return RET_ERR; } +#ifdef SYS_APPLE + + struct stat inf; + if (fstat(file, &inf) < 0) + +#else + struct stat64 inf; if (fstat64(file, &inf) < 0) + +#endif { debug(TM, "can't get the size of file: %s", filename.c_str()); return RET_ERR; diff --git a/src/Core/XML/XMLImporter.h b/src/Core/XML/XMLImporter.h index 8ec359df..26f84833 100644 --- a/src/Core/XML/XMLImporter.h +++ b/src/Core/XML/XMLImporter.h @@ -49,7 +49,7 @@ namespace degate const QString attribute = node.attribute(QString::fromStdString(attribute_str), 0); - if (attribute == 0) + if (attribute.isNull()) { throw XMLAttributeMissingException(std::string("attribute is not present: ") + attribute_str); } @@ -69,7 +69,7 @@ namespace degate const QString attribute = node.attribute(QString::fromStdString(attribute_str), 0); - if (attribute == 0) return default_value; + if (attribute.isNull()) return default_value; else return parse_number(attribute.toStdString()); } diff --git a/src/GUI/Dialog/GateEditDialog.cc b/src/GUI/Dialog/GateEditDialog.cc index da6702c6..6b112af2 100644 --- a/src/GUI/Dialog/GateEditDialog.cc +++ b/src/GUI/Dialog/GateEditDialog.cc @@ -28,6 +28,9 @@ #include "GateEditDialog.h" #include "TerminalDialog.h" +#include +#include + namespace degate { // Entity tab diff --git a/src/GUI/Dialog/GateEditDialog.h b/src/GUI/Dialog/GateEditDialog.h index eb0e925b..57cea110 100644 --- a/src/GUI/Dialog/GateEditDialog.h +++ b/src/GUI/Dialog/GateEditDialog.h @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include diff --git a/src/GUI/Dialog/GateLibraryDialog.cc b/src/GUI/Dialog/GateLibraryDialog.cc index 83a0e74e..3bf045c1 100644 --- a/src/GUI/Dialog/GateLibraryDialog.cc +++ b/src/GUI/Dialog/GateLibraryDialog.cc @@ -21,6 +21,8 @@ #include "GateLibraryDialog.h" +#include + namespace degate { GateLibraryDialog::GateLibraryDialog(QWidget* parent, const Project_shptr& project) diff --git a/src/GUI/Dialog/GateListDialog.cc b/src/GUI/Dialog/GateListDialog.cc index 7d8c5169..316811b0 100644 --- a/src/GUI/Dialog/GateListDialog.cc +++ b/src/GUI/Dialog/GateListDialog.cc @@ -45,7 +45,7 @@ namespace degate // ID Filter id_filter_label.setText(tr("ID filter:")); - id_filter_edit.setValidator(new QRegExpValidator(QRegExp("[0-9]*"), this)); + id_filter_edit.setValidator(new QRegularExpressionValidator(QRegularExpression("[0-9]*"), this)); // Gate template name filter gate_template_name_filter_label.setText(tr("Gate template filter:")); diff --git a/src/GUI/Dialog/PortPlacementDialog.h b/src/GUI/Dialog/PortPlacementDialog.h index 0923051e..aa252bfa 100644 --- a/src/GUI/Dialog/PortPlacementDialog.h +++ b/src/GUI/Dialog/PortPlacementDialog.h @@ -25,6 +25,7 @@ #include "GUI/Widget/PortPlacementWidget.h" #include +#include #include namespace degate diff --git a/src/GUI/MainWindow.cc b/src/GUI/MainWindow.cc index 95c1ea7a..aadb6f6c 100644 --- a/src/GUI/MainWindow.cc +++ b/src/GUI/MainWindow.cc @@ -25,8 +25,10 @@ #include "Core/Version.h" #include "Core/Utils/CrashReport.h" +#include + #ifdef SYS_WINDOWS -#include +#include #endif #include @@ -38,7 +40,7 @@ namespace degate MainWindow::MainWindow(int width, int height) : status_bar(this), tools_group(this), updater(this) { if (width == 0 || height == 0) - resize(QDesktopWidget().availableGeometry(this).size() * 0.7); + resize(QGuiApplication::screenAt(this->pos())->availableGeometry().size() * 0.7); else resize(width, height); @@ -407,10 +409,10 @@ namespace degate QObject::connect(&auto_save_timer, SIGNAL(timeout()), this, SLOT(auto_save())); // Workaround for a bug on Windows that occurs when using QOpenGLWidget + fullscreen mode. - // See: https://doc.qt.io/qt-5/windows-issues.html#fullscreen-opengl-based-windows. + // See: https://doc.qt.io/qt-6/windows-issues.html#fullscreen-opengl-based-windows. #ifdef SYS_WINDOWS - this->topLevelWidget()->winId(); - QWindowsWindowFunctions::setHasBorderInFullScreen(this->topLevelWidget()->windowHandle(), true); + HWND handle = reinterpret_cast(window()->winId()); + SetWindowLongPtr(handle, GWL_STYLE, GetWindowLongPtr(handle, GWL_STYLE) | WS_BORDER); #endif // Check for updates. diff --git a/src/GUI/Text/Text.cc b/src/GUI/Text/Text.cc index 2ba4ce11..f83ed197 100644 --- a/src/GUI/Text/Text.cc +++ b/src/GUI/Text/Text.cc @@ -550,7 +550,7 @@ namespace degate font_data->font = font; QTextStream font_config_file_stream(&font_config_file); - font_config_file_stream.setCodec("UTF-8"); + font_config_file_stream.setEncoding(QStringConverter::Utf8); if (font_config_file_stream.readLine().toUInt() != font_data->font.font_size || font_config_file_stream.readLine().toStdString() != font_data->font.font_family_name) { @@ -703,7 +703,7 @@ namespace degate } QTextStream font_config_file_stream(&font_config_file); - font_config_file_stream.setCodec("UTF-8"); + font_config_file_stream.setEncoding(QStringConverter::Utf8); font_config_file_stream << font_data->font.font_size << Qt::endl; font_config_file_stream << QString::fromStdString(font_data->font.font_family_name) << Qt::endl; diff --git a/src/GUI/Utils/ImageRenderer.cc b/src/GUI/Utils/ImageRenderer.cc index 477061ce..18080fea 100644 --- a/src/GUI/Utils/ImageRenderer.cc +++ b/src/GUI/Utils/ImageRenderer.cc @@ -42,7 +42,7 @@ namespace degate { makeCurrent(); - // Use cleanup function for opengl objects destruction + this->cleanup(); if (vao.isCreated()) vao.destroy(); @@ -153,6 +153,10 @@ namespace degate void ImageRenderer::cleanup() { + // Prevent cleanup if OpenGL functions wheren't initialized + if (!initialized) + return; + makeCurrent(); // Delete opengl objects here @@ -172,6 +176,8 @@ namespace degate initializeOpenGLFunctions(); + initialized = true; + glClearColor(0.0, 0.0, 0.0, 1.0); glEnable(GL_BLEND); glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE); @@ -217,8 +223,6 @@ namespace degate if (update_on_gl_initialize) update_screen(); - - connect(context(), &QOpenGLContext::aboutToBeDestroyed, this, &ImageRenderer::cleanup); } void ImageRenderer::paintGL() diff --git a/src/GUI/Utils/ImageRenderer.h b/src/GUI/Utils/ImageRenderer.h index f891fa19..edca7dd7 100644 --- a/src/GUI/Utils/ImageRenderer.h +++ b/src/GUI/Utils/ImageRenderer.h @@ -26,6 +26,7 @@ #include "Core/Project/Project.h" #include +#include /** * This define the zoom out factor (zoom *= zoom_out). @@ -97,7 +98,7 @@ namespace degate void free_texture(); /** - * Delete all opengl objects (called when QOpenGLContext::aboutToBeDestroyed signal is emitted). + * Delete all opengl objects. */ void cleanup(); @@ -140,6 +141,7 @@ namespace degate QOpenGLVertexArrayObject vao; private: + bool initialized = false; float scale = 1; float center_x = 0, center_y = 0; float viewport_min_x = 0, viewport_min_y = 0, viewport_max_x = 0, viewport_max_y = 0; diff --git a/src/GUI/Utils/Updater.cc b/src/GUI/Utils/Updater.cc index 731e0da5..3459ec6a 100644 --- a/src/GUI/Utils/Updater.cc +++ b/src/GUI/Utils/Updater.cc @@ -33,7 +33,7 @@ namespace degate : parent(parent) { connect(&process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(process_finished(int, QProcess::ExitStatus))); - connect(&process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(process_error(QProcess::ProcessError))); + connect(&process, SIGNAL(errorOccurred(QProcess::ProcessError)), this, SLOT(process_error(QProcess::ProcessError))); #if defined(Q_OS_WIN) tool_name = "maintenancetool.exe"; diff --git a/src/GUI/Workspace/WorkspaceRenderer.cc b/src/GUI/Workspace/WorkspaceRenderer.cc index 05c4e309..e5a73522 100644 --- a/src/GUI/Workspace/WorkspaceRenderer.cc +++ b/src/GUI/Workspace/WorkspaceRenderer.cc @@ -48,9 +48,13 @@ namespace degate WorkspaceRenderer::~WorkspaceRenderer() { + // Prevent cleanup if OpenGL functions wheren't initialized + if (!initialized) + return; + makeCurrent(); - // Use cleanup function for opengl objects destruction + this->cleanup(); doneCurrent(); @@ -392,6 +396,7 @@ namespace degate if (draw_grid == true) { + makeCurrent(); regular_grid.update(); update(); } @@ -426,6 +431,8 @@ namespace degate initializeOpenGLFunctions(); + initialized = true; + Text::init_context(); //QColor color = QApplication::palette().color(QWidget::backgroundRole()); @@ -454,8 +461,6 @@ namespace degate // Get and print GLSL version QOpenGLFunctions *glFuncs = QOpenGLContext::currentContext()->functions(); debug(TM, "GLSL version: %s", glFuncs->glGetString(GL_SHADING_LANGUAGE_VERSION)); - - connect(context(), &QOpenGLContext::aboutToBeDestroyed, this, &WorkspaceRenderer::cleanup); } void WorkspaceRenderer::paintGL() @@ -546,6 +551,8 @@ namespace degate if (object == nullptr) return; + makeCurrent(); + if (Gate_shptr gate = std::dynamic_pointer_cast(object)) { gates.update(gate); diff --git a/src/GUI/Workspace/WorkspaceRenderer.h b/src/GUI/Workspace/WorkspaceRenderer.h index 2adc039d..86f9fec3 100644 --- a/src/GUI/Workspace/WorkspaceRenderer.h +++ b/src/GUI/Workspace/WorkspaceRenderer.h @@ -40,6 +40,7 @@ #include "GUI/Workspace/WorkspaceRegularGrid.h" #include +#include #include #include @@ -247,7 +248,7 @@ namespace degate void free_textures(); /** - * Delete all opengl objects (called when QOpenGLContext::aboutToBeDestroyed signal is emitted). + * Delete all opengl objects. */ void cleanup(); @@ -449,6 +450,7 @@ namespace degate private: // General Project_shptr project = nullptr; + bool initialized = false; // View QMatrix4x4 projection;