Skip to content

Commit

Permalink
Updated to Qt6
Browse files Browse the repository at this point in the history
Fixed NULL pointer exception on connecting nodes (paceholder#441)
  • Loading branch information
chateauferret committed Sep 19, 2024
1 parent a939cf8 commit 90f44fc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
14 changes: 7 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ endif()
add_subdirectory(external)

# Find the QtWidgets library
find_package(Qt5 5.3 COMPONENTS
find_package(Qt6 5.3 COMPONENTS
Core
Widgets
Gui
OpenGL)

qt5_add_resources(RESOURCES ./resources/resources.qrc)
qt6_add_resources(RESOURCES ./resources/resources.qrc)

# Unfortunately, as we have a split include/src, AUTOMOC doesn't work.
# We'll have to manually specify some files
Expand Down Expand Up @@ -89,10 +89,10 @@ target_include_directories(nodes

target_link_libraries(nodes
PUBLIC
Qt5::Core
Qt5::Widgets
Qt5::Gui
Qt5::OpenGL
Qt6::Core
Qt6::Widgets
Qt6::Gui
Qt6::OpenGL
)

target_compile_definitions(nodes
Expand Down Expand Up @@ -130,7 +130,7 @@ set_target_properties(nodes

file(GLOB_RECURSE HEADERS_TO_MOC include/nodes/internal/*.hpp)

qt5_wrap_cpp(nodes_moc
qt6_wrap_cpp(nodes_moc
${HEADERS_TO_MOC}
TARGET nodes
OPTIONS --no-notes # Don't display a note for the headers which don't produce a moc_*.cpp
Expand Down
8 changes: 6 additions & 2 deletions src/ConnectionStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <QtCore/QJsonArray>

#include <QDebug>
#include <qrandom.h>

#include "StyleCollection.hpp"

Expand Down Expand Up @@ -166,8 +167,11 @@ normalColor(QString typeId) const

std::size_t const hue_range = 0xFF;

qsrand(hash);
std::size_t hue = qrand() % hue_range;
// Replace deprecated qrand and qsrand with QRandomGenerator
QRandomGenerator rand;
rand.seed (hash);

std::size_t hue = rand.generate() % hue_range;

std::size_t sat = 120 + hash % 129;

Expand Down
3 changes: 2 additions & 1 deletion src/NodeGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ portWidth(PortType portType) const
name = _dataModel->dataType(portType, i).name;
}

width = std::max(unsigned(_fontMetrics.width(name)),
// Replace deprecated FontMetrics::width(name) with FontMetrics.boundingRect(name).width()
width = std::max(unsigned(_fontMetrics.boundingRect(name).width()),
width);
}

Expand Down
4 changes: 2 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
find_package(Catch2 2.3.0 REQUIRED)
find_package(Qt5 COMPONENTS Test)
find_package(Qt6 COMPONENTS Test)

add_executable(test_nodes
test_main.cpp
Expand All @@ -20,7 +20,7 @@ target_link_libraries(test_nodes
PRIVATE
NodeEditor::nodes
Catch2::Catch2
Qt5::Test
Qt6::Test
)

add_test(
Expand Down

0 comments on commit 90f44fc

Please sign in to comment.