Skip to content

Commit 778a6b2

Browse files
committed
Field: Set value ID properly
1 parent 1bf6941 commit 778a6b2

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/scratch/field.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: Apache-2.0
22

33
#include <scratchcpp/field.h>
4+
#include <scratchcpp/entity.h>
45

56
#include "field_p.h"
67

@@ -58,6 +59,11 @@ std::shared_ptr<Entity> Field::valuePtr() const
5859
void Field::setValuePtr(const std::shared_ptr<Entity> &newValuePtr)
5960
{
6061
impl->valuePtr = newValuePtr;
62+
63+
if (newValuePtr)
64+
impl->valueId = newValuePtr->id();
65+
else
66+
impl->valueId = "";
6167
}
6268

6369
/*! Returns the ID of the value (e. g. a variable). */

src/scratch/field_p.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// SPDX-License-Identifier: Apache-2.0
22

3+
#include <scratchcpp/entity.h>
4+
35
#include "field_p.h"
46

57
using namespace libscratchcpp;
@@ -9,6 +11,8 @@ FieldPrivate::FieldPrivate(const std::string &name, const Value &value, std::sha
911
value(value),
1012
valuePtr(valuePtr)
1113
{
14+
if (valuePtr)
15+
valueId = valuePtr->id();
1216
}
1317

1418
FieldPrivate::FieldPrivate(const std::string &name, const Value &value, const std::string &valueId) :

0 commit comments

Comments
 (0)