|
From: <mcu...@us...> - 2015-01-09 21:01:21
|
Revision: 1559
http://sourceforge.net/p/orm/code/1559
Author: mcurland
Date: 2015-01-09 21:01:18 +0000 (Fri, 09 Jan 2015)
Log Message:
-----------
Fix some verbalization crushes with difficult subquery scenarios by checking for null returns on all uses of GetRolePlayerVariableUse. Most of this is defensive: I don't have scenarios for all of these cases, but triggered one of these cases with a partial binding to an incomplete subquery definition.
Modified Paths:
--------------
trunk/ORMModel/ObjectModel/Verbalization.cs
trunk/Setup/Readme.htm
Modified: trunk/ORMModel/ObjectModel/Verbalization.cs
===================================================================
--- trunk/ORMModel/ObjectModel/Verbalization.cs 2015-01-08 02:17:32 UTC (rev 1558)
+++ trunk/ORMModel/ObjectModel/Verbalization.cs 2015-01-09 21:01:18 UTC (rev 1559)
@@ -7984,7 +7984,8 @@
{
// Continue with another reading starting with the lead role of the
// preceding fact type.
- if (localContextLeadVariable == GetRolePlayerVariableUse(new RolePathNode(factTypeEntry, pathContext)).Value.PrimaryRolePlayerVariable)
+ RolePlayerVariableUse? entryVariableUse;
+ if (localContextLeadVariable == ((entryVariableUse = GetRolePlayerVariableUse(new RolePathNode(factTypeEntry, pathContext))).HasValue ? entryVariableUse.Value.PrimaryRolePlayerVariable : null))
{
// Optimization of next branch to test the entry variable without invoking the delegate
reading = factType.GetMatchingReading(readingOrders, null, entryRoleBase, null, null, MatchingReadingOptions.NoFrontText | MatchingReadingOptions.LeadRolesNotHyphenBound);
@@ -8810,7 +8811,8 @@
RolePlayerVariable newVariable = useMap[queryRoleKey].PrimaryRolePlayerVariable;
RolePlayerVariableUse correlatedUse = useMap[new RolePathNode(factTypeEntry, pathContext)];
object correlationRoot = correlatedUse.CorrelationRoot;
- foreach (RolePlayerVariable variable in (correlationRoot != null ? useMap[correlationRoot] : correlatedUse).GetCorrelatedVariables(true))
+ RolePlayerVariableUse rootCorrelatedUse;
+ foreach (RolePlayerVariable variable in (correlationRoot != null ? (useMap.TryGetValue(correlationRoot, out rootCorrelatedUse) ? rootCorrelatedUse : correlatedUse) : correlatedUse).GetCorrelatedVariables(true))
{
CustomCorrelateVariables(variable, newVariable);
}
@@ -11557,10 +11559,12 @@
int usePhase = CurrentQuantificationUsePhase;
object pathContext = node.PathContext;
RolePlayerVariableUse? resolvedChildVariableUse;
- if (testChildIndex >= childPathedRoles.Count || // Indicates a pure existential, we're here because the entry role can possibly be partnered.
- ((resolvedChildVariableUse = GetRolePlayerVariableUse(new RolePathNode(childPathedRoles[testChildIndex], pathContext))).HasValue && !resolvedChildVariableUse.Value.PrimaryRolePlayerVariable.HasBeenUsed(usePhase, true)))
+ RolePlayerVariableUse? entryVariableUse;
+ if ((testChildIndex >= childPathedRoles.Count || // Indicates a pure existential, we're here because the entry role can possibly be partnered.
+ ((resolvedChildVariableUse = GetRolePlayerVariableUse(new RolePathNode(childPathedRoles[testChildIndex], pathContext))).HasValue && !resolvedChildVariableUse.Value.PrimaryRolePlayerVariable.HasBeenUsed(usePhase, true))) &&
+ (entryVariableUse = GetRolePlayerVariableUse(new RolePathNode(entryPathedRole, pathContext))).HasValue)
{
- RolePlayerVariableUse variableUse = GetRolePlayerVariableUse(new RolePathNode(entryPathedRole, pathContext)).Value;
+ RolePlayerVariableUse variableUse = entryVariableUse.Value;
RolePlayerVariable primaryVariable = variableUse.PrimaryRolePlayerVariable;
object correlateWithKey = CorrelationRootToContextBoundKey(variableUse.CorrelationRoot, pathContext);
if (null == GetUnpairedPartnerVariable(
@@ -11625,6 +11629,7 @@
else
{
object correlationRoot = variableUse.CorrelationRoot;
+ RolePlayerVariableUse? rootVariableUse;
if (correlationRoot == null)
{
if (variableUse.CorrelatedVariablesHead != null)
@@ -11632,9 +11637,9 @@
partnerCorrelatedVariables = variableUse.GetCorrelatedVariables(false); // No reason to test the primary variable
}
}
- else
+ else if ((rootVariableUse = GetRolePlayerVariableUse(CorrelationRootToContextBoundKey(correlationRoot, pathContext))).HasValue)
{
- partnerCorrelatedVariables = GetRolePlayerVariableUse(CorrelationRootToContextBoundKey(correlationRoot, pathContext)).Value.GetCorrelatedVariables(true);
+ partnerCorrelatedVariables = rootVariableUse.Value.GetCorrelatedVariables(true);
}
if (partnerCorrelatedVariables != null)
{
@@ -11775,6 +11780,7 @@
return true;
}
object correlationRoot;
+ RolePlayerVariableUse? rootVariableUse;
if (variableUse.CorrelatedVariablesHead != null)
{
foreach (RolePlayerVariable testVariable in variableUse.GetCorrelatedVariables(false))
@@ -11785,9 +11791,10 @@
}
}
}
- else if (null != (correlationRoot = variableUse.CorrelationRoot))
+ else if (null != (correlationRoot = variableUse.CorrelationRoot) &&
+ (rootVariableUse = GetRolePlayerVariableUse(CorrelationRootToContextBoundKey(correlationRoot, pathContext))).HasValue)
{
- foreach (RolePlayerVariable testVariable in GetRolePlayerVariableUse(CorrelationRootToContextBoundKey(correlationRoot, pathContext)).Value.GetCorrelatedVariables(true))
+ foreach (RolePlayerVariable testVariable in rootVariableUse.Value.GetCorrelatedVariables(true))
{
if (testVariable == variable)
{
@@ -11976,12 +11983,19 @@
return true;
}
object correlationRootKey = CorrelationRootToContextBoundKey(variableUse.CorrelationRoot, pathContext);
- foreach (RolePlayerVariable correlatedVariable in (correlationRootKey != null) ? GetRolePlayerVariableUse(correlationRootKey).Value.GetCorrelatedVariables(true) : variableUse.GetCorrelatedVariables(false))
+ RolePlayerVariableUse? rootVariableUse;
+ IEnumerable<RolePlayerVariable> variableIter;
+ if (null != (variableIter = (correlationRootKey != null) ?
+ ((rootVariableUse = GetRolePlayerVariableUse(correlationRootKey)).HasValue ? rootVariableUse.Value.GetCorrelatedVariables(true): null) :
+ variableUse.GetCorrelatedVariables(false)))
{
- if (correlatedVariable != primaryVariable &&
- correlatedVariable.HasBeenUsed(quantificationUsePhase, true))
+ foreach (RolePlayerVariable correlatedVariable in variableIter)
{
- return true;
+ if (correlatedVariable != primaryVariable &&
+ correlatedVariable.HasBeenUsed(quantificationUsePhase, true))
+ {
+ return true;
+ }
}
}
Dictionary<RolePlayerVariable, LinkedNode<RolePlayerVariable>> customCorrelations;
Modified: trunk/Setup/Readme.htm
===================================================================
--- trunk/Setup/Readme.htm 2015-01-08 02:17:32 UTC (rev 1558)
+++ trunk/Setup/Readme.htm 2015-01-09 21:01:18 UTC (rev 1559)
@@ -72,7 +72,7 @@
<hr/>
<h2><span class="toggle" onclick="toggleDisp(this,'jan2015')">-</span>January 2015 CTP Changes</h2>
<div id="jan2015">
-<div>The January 2015 CTP release includes all modifications through changeset 1558. Full changeset descriptions can be found at the <a href="http://orm.svn.sourceforge.net/viewvc/orm/trunk/?view=log">sourceforge code repository</a> (be patient with this link, the page contains a full changeset history).</div>
+<div>The January 2015 CTP release includes all modifications through changeset 1559. Full changeset descriptions can be found at the <a href="http://orm.svn.sourceforge.net/viewvc/orm/trunk/?view=log">sourceforge code repository</a> (be patient with this link, the page contains a full changeset history).</div>
<ul>
<li>Feature Changes:
<ol>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|