Skip to content

Commit 59db800

Browse files
committed
Fix crash when trying to copy a group of connected nodes
- Regression due to 5f9ee01
1 parent e621fee commit 59db800

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/edge.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,11 @@ void Edge::setArrowHeadPen(const QPen & pen)
208208
void Edge::setLabelVisible(bool visible, EdgeTextEdit::VisibilityChangeReason vcr)
209209
{
210210
if (m_enableLabel) {
211-
const bool isEnoughSpaceForLabel = !m_label->sceneBoundingRect().intersects(sourceNode().sceneBoundingRect()) && //
211+
// Note: We need to test for scene(), because sceneBoundingRect() will crash if the item has not been added to any scene (yet).
212+
const bool isEnoughSpaceForLabel = m_label->scene() && !m_label->sceneBoundingRect().intersects(sourceNode().sceneBoundingRect()) && //
212213
!m_label->sceneBoundingRect().intersects(targetNode().sceneBoundingRect());
213214
const bool dummyLabelTextIsShoterThanLabelText = m_dummyLabel->text().length() < m_label->text().length();
214-
const bool isEnoughSpaceForDummyLabel = !m_dummyLabel->sceneBoundingRect().intersects(sourceNode().sceneBoundingRect()) && //
215+
const bool isEnoughSpaceForDummyLabel = m_dummyLabel->scene() && !m_dummyLabel->sceneBoundingRect().intersects(sourceNode().sceneBoundingRect()) && //
215216
!m_dummyLabel->sceneBoundingRect().intersects(targetNode().sceneBoundingRect());
216217
switch (vcr) {
217218
case EdgeTextEdit::VisibilityChangeReason::AvailableSpaceChanged: {
@@ -288,13 +289,9 @@ void Edge::setDashedLine(bool enable)
288289
void Edge::setText(const QString & text)
289290
{
290291
m_edgeModel->text = text;
291-
if (!TestMode::enabled()) {
292-
if (m_enableLabel) {
293-
m_label->setText(text);
294-
setLabelVisible(!text.isEmpty());
295-
}
296-
} else {
297-
TestMode::logDisabledCode("Set label text");
292+
if (m_enableLabel) {
293+
m_label->setText(text);
294+
setLabelVisible(!text.isEmpty());
298295
}
299296
}
300297

0 commit comments

Comments
 (0)