mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-08 13:04:13 +02:00
e1acf95da4
ConductorProfile's default constructor leaves beginOrientation and
endOrientation untouched, and the copy constructor and operator= then
read them from such a profile when a conductor's profiles are stored in
a QHash. UndefinedBehaviorSanitizer stops the binary there on every
project with conductors:
conductorprofile.cpp:42:23: runtime error: load of value 1869263360,
which is not a valid value for type 'Qet::Orientation'
#0 ConductorProfile::ConductorProfile(ConductorProfile const&)
#2 QHashPrivate::Node<Qt::Corner, ConductorProfile>::createInPlace
Give both members a default value, Qet::North, in the header. No
behaviour changes: a default-constructed profile is null (no segments)
and its orientations are never used before fromConductor() sets them.
No file-format change. Tests: the sanitizer build of the Linux CI job
(separate PR) fails on master with the report above and passes with
this change; all 23 example projects go through --export-svg and
--resave under ASan/UBSan on macOS without a report.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Beat Hangartner <beat@hangartners.ch>
61 lines
1.9 KiB
C++
61 lines
1.9 KiB
C++
/*
|
|
Copyright 2006-2026 The QElectroTech Team
|
|
This file is part of QElectroTech.
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#ifndef CONDUCTOR_PROFILE_H
|
|
#define CONDUCTOR_PROFILE_H
|
|
#include <QList>
|
|
#include "qet.h"
|
|
class Conductor;
|
|
class ConductorSegmentProfile;
|
|
/**
|
|
This class represents the profile of a conductor, i.e. its primary
|
|
characteristics.
|
|
*/
|
|
class ConductorProfile {
|
|
public:
|
|
// constructors, destructor
|
|
ConductorProfile();
|
|
ConductorProfile(Conductor *conductor);
|
|
ConductorProfile(const ConductorProfile &);
|
|
ConductorProfile &operator=(const ConductorProfile &);
|
|
virtual ~ConductorProfile();
|
|
|
|
// attributes
|
|
public:
|
|
/// Segments composing the conductor
|
|
QList<ConductorSegmentProfile *> segments;
|
|
/// Orientation of the start terminal. Initialised because the default
|
|
/// constructor leaves it as is, and the copy constructor and operator=
|
|
/// then read it from such a profile.
|
|
Qet::Orientation beginOrientation = Qet::North;
|
|
/// Orientation of the end terminal.
|
|
Qet::Orientation endOrientation = Qet::North;
|
|
|
|
// methods
|
|
public:
|
|
bool isNull() const;
|
|
void setNull();
|
|
qreal width() const;
|
|
qreal height() const;
|
|
uint segmentsCount(QET::ConductorSegmentType) const;
|
|
QList<ConductorSegmentProfile *> horizontalSegments();
|
|
QList<ConductorSegmentProfile *> verticalSegments();
|
|
void fromConductor(Conductor *);
|
|
};
|
|
QDebug &operator<<(QDebug d, ConductorProfile &);
|
|
#endif
|