Compare commits

...

6 Commits

Author SHA1 Message Date
Laurent Trinques d3cf8f2635 Remove github action test-vs2026.yml 2026-06-23 13:44:05 +02:00
plc-user 6aa14a7536 Merge pull request #518 from ispyisail/fix/terminal-data-leak
looks plausible, compiles fine

thank you @ispyisail
2026-06-23 09:39:46 +02:00
plc-user 6ce688a709 Merge pull request #520 from ispyisail/fix/element-editor-first-click-481
fixed:
view jumps, but graphic primitives stay at position
all parts can be moved as before
compile-warning is gone

thank you @ispyisail
2026-06-23 09:26:02 +02:00
Shane Ringrose 28357b0f55 fix(editor): correct initializer list order to silence -Wreorder warning
m_first_move was initialized before _linestyle in the constructor
initializer list, but _linestyle is declared first in the class. Reorder
to match declaration order.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-23 07:04:34 +12:00
Shane Ringrose 2a115e4381 fix(editor): suppress spurious first-click element moves (#481)
When an item type is selected for the first time the properties dock
expands, causing the QGraphicsView viewport to shrink. Qt recalculates
scene coordinates and fires one or more synthetic mouseMoveEvents before
the user has actually moved the mouse.

The original code used a single-shot m_first_move flag in
CustomElementGraphicPart, which absorbed exactly one spurious event.
PartText and PartDynamicTextField had no protection at all.

Fix: compare screen-coordinate displacement against
QApplication::startDragDistance() (~4 px). Screen coordinates are
stable across viewport resizes, so the check correctly rejects
synthetic dock-expansion events while allowing genuine drags.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-23 05:38:11 +12:00
Shane Ringrose df5f622418 Fix TerminalData memory leak in Terminal destructor
Terminal stores its TerminalData* as member d but never deletes it.
Every Element creation (placing on diagram, loading icon for the
element browser, drag previews) leaks one TerminalData per terminal.
ASan confirmed 112 leaked objects (9856 bytes) in a short session
across four call sites all rooted in Element::parseTerminal.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-21 00:38:07 +12:00
5 changed files with 35 additions and 137 deletions
-112
View File
@@ -1,112 +0,0 @@
name: Test Windows VS2026 migration
# Ce workflow vérifie que le build QElectroTech fonctionne sur l'image
# windows-2025-vs2026, avant la migration forcée du 8 juin 2026.
# Il peut être supprimé une fois la migration confirmée OK.
on:
workflow_dispatch: # déclenchement manuel uniquement
schedule:
- cron: '0 4 * * 1' # chaque lundi à 4h00 UTC (optionnel)
jobs:
test-vs2026:
name: Build on windows-2025-vs2026
runs-on: windows-2025-vs2026 # <-- image avec VS 2026
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Install MSYS2 + dependencies
uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
update: false
install: >-
mingw-w64-ucrt-x86_64-gcc
mingw-w64-ucrt-x86_64-cmake
mingw-w64-ucrt-x86_64-ninja
mingw-w64-ucrt-x86_64-qt5-base
mingw-w64-ucrt-x86_64-qt5-svg
mingw-w64-ucrt-x86_64-qt5-tools
mingw-w64-ucrt-x86_64-qt5-translations
mingw-w64-ucrt-x86_64-sqlite3
mingw-w64-ucrt-x86_64-pkgconf
mingw-w64-ucrt-x86_64-extra-cmake-modules
mingw-w64-ucrt-x86_64-kwidgetsaddons-qt5
mingw-w64-ucrt-x86_64-kcoreaddons-qt5
mingw-w64-ucrt-x86_64-nsis
mingw-w64-ucrt-x86_64-ccache
mingw-w64-ucrt-x86_64-7zip
git
- name: Force Qt5 (remove Qt6 interference)
shell: msys2 {0}
run: |
rm -rf /ucrt64/lib/cmake/Qt6 || true
pacman -R --noconfirm mingw-w64-ucrt-x86_64-qt6-tools 2>/dev/null || true
- name: Cache ccache
uses: actions/cache@v4
with:
path: C:\Users\runneradmin\AppData\Local\ccache
key: ccache-vs2026-${{ runner.os }}-${{ github.sha }}
restore-keys: |
ccache-vs2026-${{ runner.os }}-
- name: Configure (CMake)
shell: msys2 {0}
run: |
set -euo pipefail
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DQt5_DIR=/ucrt64/lib/cmake/Qt5 \
-DQT_VERSION_MAJOR=5 \
-DCMAKE_DISABLE_FIND_PACKAGE_Qt6=ON \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_FLAGS="-DQET_EXPORT_PROJECT_DB" \
-DBUILD_TESTING=OFF \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DCMAKE_C_COMPILER_LAUNCHER=/ucrt64/bin/ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=/ucrt64/bin/ccache \
-DSQLite3_INCLUDE_DIR=/ucrt64/include \
-DSQLite3_LIBRARY=/ucrt64/lib/libsqlite3.dll.a \
- name: Build
shell: msys2 {0}
run: |
set -euo pipefail
cmake --build build --parallel $(nproc)
- name: Verify executable
shell: msys2 {0}
run: |
set -euo pipefail
EXE=$(find build -name "qelectrotech.exe" | head -1)
if [ -z "$EXE" ]; then
echo "ERROR: qelectrotech.exe introuvable après le build"
exit 1
fi
SIZE=$(stat -c%s "$EXE")
echo "Executable trouvé : $EXE ($SIZE octets)"
if [ "$SIZE" -lt 100000 ]; then
echo "ERROR: exe trop petit ($SIZE octets), build probablement incomplet"
exit 1
fi
echo "BUILD VS2026 : OK ✓"
- name: Summary
if: always()
shell: msys2 {0}
run: |
echo "=== Résumé de compatibilité VS2026 ==="
gcc --version
cmake --version
ninja --version
echo "Image runner : windows-2025-vs2026"
echo "Date du test : $(date -u)"
@@ -20,6 +20,7 @@
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../elementscene.h"
#include <QApplication>
#include <QRegularExpression>
/**
@@ -39,7 +40,8 @@ CustomElementGraphicPart::CustomElementGraphicPart(QETElementEditor *editor,
_lineweight(NormalWeight),
_filling(NoneFilling),
_color(BlackColor),
_antialiased(false)
_antialiased(false),
m_first_move (false)
{
setFlags(QGraphicsItem::ItemIsSelectable
| QGraphicsItem::ItemIsMovable
@@ -1332,26 +1334,24 @@ void CustomElementGraphicPart::mousePressEvent(QGraphicsSceneMouseEvent *event)
void CustomElementGraphicPart::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
//m_first_move is used to avoid an unwanted behavior
//when the properties dock widget is displayed :
//1 there is no selection
//2 the dock widget width is set to minimum
//3 select a part, the dock widget gain new widgets used to edit
//the current selected part and the width of the dock grow
//so the width of the QGraphicsView is reduced and cause a mouse move event.
//When this case occur the part is moved but they should not. This bool fix it.
if (Q_UNLIKELY(m_first_move)) {
if (m_first_move) {
// Suppress spurious move events fired when the properties dock
// widget expands on first selection of a new item type, causing
// the QGraphicsView to shrink and re-map coordinates. Screen
// coordinates are stable across viewport changes; scene coords
// are not — so use screenPos() for the threshold check.
const QPointF d = event->screenPos() - event->buttonDownScreenPos(Qt::LeftButton);
if (d.manhattanLength() < QApplication::startDragDistance())
return;
m_first_move = false;
return;
}
if((event->buttons() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable))
{
if ((event->buttons() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable)) {
QPointF pos = event->scenePos() + (m_origin_pos - event->buttonDownScenePos(Qt::LeftButton));
event->modifiers() == Qt::ControlModifier ? setPos(pos) : setPos(elementScene()->snapToGrid(pos));
}
else
} else {
QGraphicsObject::mouseMoveEvent(event);
}
}
void CustomElementGraphicPart::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
@@ -20,6 +20,7 @@
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../../qetapp.h"
#include "../elementscene.h"
#include <QApplication>
#include <QColor>
#include <QFont>
@@ -495,12 +496,16 @@ bool PartDynamicTextField::keepVisualRotation() const {
@param event
*/
void PartDynamicTextField::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
if((event -> buttons() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable)) {
QPointF pos = event -> scenePos() + (m_origin_pos - event -> buttonDownScenePos(Qt::LeftButton));
event -> modifiers() == Qt::ControlModifier ? setPos(pos) : setPos(elementScene() -> snapToGrid(pos));
}
else
if ((event->buttons() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable)) {
// Suppress spurious moves from the properties dock resizing the viewport.
const QPointF d = event->screenPos() - event->buttonDownScreenPos(Qt::LeftButton);
if (d.manhattanLength() < QApplication::startDragDistance())
return;
QPointF pos = event->scenePos() + (m_origin_pos - event->buttonDownScenePos(Qt::LeftButton));
event->modifiers() == Qt::ControlModifier ? setPos(pos) : setPos(elementScene()->snapToGrid(pos));
} else {
QGraphicsObject::mouseMoveEvent(event);
}
}
/**
+9 -5
View File
@@ -18,6 +18,7 @@
#include "parttext.h"
#include "../../QPropertyUndoCommand/qpropertyundocommand.h"
#include <QApplication>
#include "../../qetapp.h"
#include "../elementprimitivedecorator.h"
#include "../elementscene.h"
@@ -324,11 +325,14 @@ void PartText::setFont(const QFont &font) {
}
void PartText::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
if((event -> buttons() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable)) {
QPointF pos = event -> scenePos() + (m_origin_pos - event -> buttonDownScenePos(Qt::LeftButton));
event -> modifiers() == Qt::ControlModifier ? setPos(pos) : setPos(elementScene() -> snapToGrid(pos));
}
else {
if ((event->buttons() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable)) {
// Suppress spurious moves from the properties dock resizing the viewport.
const QPointF d = event->screenPos() - event->buttonDownScreenPos(Qt::LeftButton);
if (d.manhattanLength() < QApplication::startDragDistance())
return;
QPointF pos = event->scenePos() + (m_origin_pos - event->buttonDownScenePos(Qt::LeftButton));
event->modifiers() == Qt::ControlModifier ? setPos(pos) : setPos(elementScene()->snapToGrid(pos));
} else {
QGraphicsObject::mouseMoveEvent(event);
}
}
+1
View File
@@ -86,6 +86,7 @@ Terminal::Terminal(TerminalData* data, Element* e) :
*/
Terminal::~Terminal() {
qDeleteAll(m_conductors_list);
delete d;
}
/**