fix crash on loading linked macro fx
This commit is contained in:
parent
7d69b3b746
commit
be2cc70aa7
3 changed files with 36 additions and 4 deletions
|
@ -220,9 +220,9 @@ TFx *TMacroFx::clone(bool recursive) const {
|
||||||
assert(fx);
|
assert(fx);
|
||||||
clones[i] = fx->clone(false);
|
clones[i] = fx->clone(false);
|
||||||
assert(table.count(fx) == 0);
|
assert(table.count(fx) == 0);
|
||||||
table[fx] = i;
|
table[fx] = i;
|
||||||
if (fx == m_root.getPointer()) rootIndex = i;
|
if (fx == m_root.getPointer()) rootIndex = i;
|
||||||
TFx *linkedFx = fx->getLinkedFx();
|
TFx *linkedFx = fx->getLinkedFx();
|
||||||
if (linkedFx && table.find(linkedFx) != table.end())
|
if (linkedFx && table.find(linkedFx) != table.end())
|
||||||
clones[i]->linkParams(clones[table[linkedFx]].getPointer());
|
clones[i]->linkParams(clones[table[linkedFx]].getPointer());
|
||||||
}
|
}
|
||||||
|
@ -476,9 +476,14 @@ void TMacroFx::loadData(TIStream &is) {
|
||||||
std::string tagName;
|
std::string tagName;
|
||||||
while (is.openChild(tagName)) {
|
while (is.openChild(tagName)) {
|
||||||
if (tagName == "root") {
|
if (tagName == "root") {
|
||||||
|
// set the flag here in order to prevent the leaf macro fx in the tree
|
||||||
|
// to try to link this fx before finish loading
|
||||||
|
m_isLoading = true;
|
||||||
TPersist *p = 0;
|
TPersist *p = 0;
|
||||||
is >> p;
|
is >> p;
|
||||||
m_root = dynamic_cast<TFx *>(p);
|
m_root = dynamic_cast<TFx *>(p);
|
||||||
|
// release the flag
|
||||||
|
m_isLoading = false;
|
||||||
} else if (tagName == "nodes") {
|
} else if (tagName == "nodes") {
|
||||||
while (!is.eos()) {
|
while (!is.eos()) {
|
||||||
TPersist *p = 0;
|
TPersist *p = 0;
|
||||||
|
@ -495,6 +500,11 @@ void TMacroFx::loadData(TIStream &is) {
|
||||||
// collecting params just after loading nodes since they may need on
|
// collecting params just after loading nodes since they may need on
|
||||||
// loading "super" tag in case it is linked with another macro fx
|
// loading "super" tag in case it is linked with another macro fx
|
||||||
collectParams(this);
|
collectParams(this);
|
||||||
|
// link parameters if there is a waiting fx for linking with this
|
||||||
|
if (m_waitingLinkFx) {
|
||||||
|
m_waitingLinkFx->linkParams(this);
|
||||||
|
m_waitingLinkFx = nullptr;
|
||||||
|
}
|
||||||
} else if (tagName == "ports") {
|
} else if (tagName == "ports") {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (is.matchTag(tagName)) {
|
while (is.matchTag(tagName)) {
|
||||||
|
@ -566,6 +576,21 @@ void TMacroFx::saveData(TOStream &os) {
|
||||||
os.closeChild();
|
os.closeChild();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
|
||||||
|
void TMacroFx::linkParams(TFx *src) {
|
||||||
|
// in case the src fx is not yet loaded
|
||||||
|
// (i.e. we are in loading the src fx tree),
|
||||||
|
// wait linking the parameters until loading src is completed
|
||||||
|
TMacroFx *srcMacroFx = dynamic_cast<TMacroFx *>(src);
|
||||||
|
if (srcMacroFx && srcMacroFx->isLoading()) {
|
||||||
|
srcMacroFx->setWaitingLinkFx(this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TFx::linkParams(src);
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
FX_IDENTIFIER(TMacroFx, "macroFx")
|
FX_IDENTIFIER(TMacroFx, "macroFx")
|
||||||
// FX_IDENTIFIER_IS_HIDDEN(TMacroFx, "macroFx")
|
// FX_IDENTIFIER_IS_HIDDEN(TMacroFx, "macroFx")
|
||||||
|
|
|
@ -373,7 +373,7 @@ public:
|
||||||
TFx *clone(TFx *fx, bool recursive) const;
|
TFx *clone(TFx *fx, bool recursive) const;
|
||||||
|
|
||||||
void unlinkParams();
|
void unlinkParams();
|
||||||
void linkParams(TFx *src);
|
virtual void linkParams(TFx *src);
|
||||||
|
|
||||||
TFx *getLinkedFx() const;
|
TFx *getLinkedFx() const;
|
||||||
|
|
||||||
|
@ -543,7 +543,7 @@ inline std::string TFx::getFxType() const { return getDeclaration()->getId(); }
|
||||||
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
||||||
|
|
||||||
#define FX_DECLARATION(T) \
|
#define FX_DECLARATION(T) \
|
||||||
\
|
\
|
||||||
public: \
|
public: \
|
||||||
const TPersistDeclaration *getDeclaration() const override;
|
const TPersistDeclaration *getDeclaration() const override;
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,9 @@ class DVAPI TMacroFx final : public TRasterFx {
|
||||||
|
|
||||||
bool isaLeaf(TFx *fx) const;
|
bool isaLeaf(TFx *fx) const;
|
||||||
|
|
||||||
|
bool m_isLoading = false;
|
||||||
|
TMacroFx *m_waitingLinkFx = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static bool analyze(const std::vector<TFxP> &fxs, TFxP &root,
|
static bool analyze(const std::vector<TFxP> &fxs, TFxP &root,
|
||||||
std::vector<TFxP> &roots, std::vector<TFxP> &leafs);
|
std::vector<TFxP> &roots, std::vector<TFxP> &leafs);
|
||||||
|
@ -78,6 +81,10 @@ public:
|
||||||
void compatibilityTranslatePort(int majorVersion, int minorVersion,
|
void compatibilityTranslatePort(int majorVersion, int minorVersion,
|
||||||
std::string &portName) override;
|
std::string &portName) override;
|
||||||
|
|
||||||
|
void linkParams(TFx *src) override;
|
||||||
|
bool isLoading() { return m_isLoading; }
|
||||||
|
void setWaitingLinkFx(TMacroFx *linkFx) { m_waitingLinkFx = linkFx; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// non implementati
|
// non implementati
|
||||||
TMacroFx(const TMacroFx &);
|
TMacroFx(const TMacroFx &);
|
||||||
|
|
Loading…
Reference in a new issue