summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2013-07-05 09:04:15 +0200
committerPatrick Ohly <patrick.ohly@intel.com>2013-07-10 13:45:05 +0200
commit92092a7e1a65ee707b403f1a7af04177fb9c8025 (patch)
tree78e553ef19c66527a9d2f0959bfc4efdf704eb09
parentd814788a9c4653ad9335f90e08d27627c0bd734c (diff)
engine: fix MERGEFIELDS()
Commit de7ff9 introduced a new mode of operation for merging, where one side gets updated to be identical to the other side, regardless of what the field list says. That commit broke MERGEFIELDS() is several ways: - The extra parameter was not declared in TBuiltInFuncDef and therefore all attempts to call MERGEFIELDS() from a script caused a parsing error (something like "closing bracket expected"). - The parameter was meant to be optional, but not passing it caused a crash because aFuncContextP->getLocalVar(0) then is NULL. This commit fixes these issues by making the new parameter optional and checking whether it exists (probably not necessary) and was set.
-rwxr-xr-xsrc/sysync/multifielditemtype.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/sysync/multifielditemtype.cpp b/src/sysync/multifielditemtype.cpp
index 6dd32d9..1e7c966 100755
--- a/src/sysync/multifielditemtype.cpp
+++ b/src/sysync/multifielditemtype.cpp
@@ -195,9 +195,11 @@ public:
static void func_MergeFields(TItemField *&aTermP, TScriptContext *aFuncContextP)
{
TMultiFieldItemType *mfitP = static_cast<TMultiFieldItemType *>(aFuncContextP->getCallerContext());
- if (mfitP->fFirstItemP)
+ if (mfitP->fFirstItemP) {
+ TItemField *argP = aFuncContextP->getLocalVar(0);
mfitP->fFirstItemP->standardMergeWith(*(mfitP->fSecondItemP),mfitP->fChangedFirst,mfitP->fChangedSecond,
- aFuncContextP->getLocalVar(0)->getAsInteger());
+ (argP && argP->isAssigned()) ? argP->getAsInteger() : 0);
+ }
}; // func_MergeFields
@@ -360,7 +362,7 @@ const TBuiltInFuncDef DataTypeFuncDefs[] = {
{ "DELETEWINS", TMFTypeFuncs::func_DeleteWins, fty_none, 0, NULL },
{ "PREVENTADD", TMFTypeFuncs::func_PreventAdd, fty_none, 0, NULL },
{ "IGNOREUPDATE", TMFTypeFuncs::func_IgnoreUpdate, fty_none, 0, NULL },
- { "MERGEFIELDS", TMFTypeFuncs::func_MergeFields, fty_none, 0, NULL },
+ { "MERGEFIELDS", TMFTypeFuncs::func_MergeFields, fty_none, 1, param_oneOptInteger },
{ "WINNINGCHANGED", TMFTypeFuncs::func_WinningChanged, fty_integer, 0, NULL },
{ "LOOSINGCHANGED", TMFTypeFuncs::func_LoosingChanged, fty_integer, 0, NULL },
{ "SETWINNINGCHANGED", TMFTypeFuncs::func_SetWinningChanged, fty_none, 1, param_IntArg },