Add missing locks.

Refs #5846
This commit is contained in:
Gunnar Beutner 2014-03-24 09:15:45 +01:00
parent 7086b44d3a
commit fd1aaa1997
1 changed files with 9 additions and 0 deletions

View File

@ -25,6 +25,7 @@
#include "base/scriptfunction.h" #include "base/scriptfunction.h"
#include "base/scriptvariable.h" #include "base/scriptvariable.h"
#include "base/utility.h" #include "base/utility.h"
#include "base/objectlock.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <boost/exception_ptr.hpp> #include <boost/exception_ptr.hpp>
#include <boost/exception/errinfo_nested_exception.hpp> #include <boost/exception/errinfo_nested_exception.hpp>
@ -57,6 +58,7 @@ void AExpression::ExtractPath(const std::vector<String>& path, const Array::Ptr&
if (m_Operator == &AExpression::OpDict) { if (m_Operator == &AExpression::OpDict) {
Array::Ptr exprl = m_Operand1; Array::Ptr exprl = m_Operand1;
ObjectLock olock(exprl);
BOOST_FOREACH(const AExpression::Ptr& expr, exprl) { BOOST_FOREACH(const AExpression::Ptr& expr, exprl) {
expr->ExtractPath(path, result); expr->ExtractPath(path, result);
} }
@ -68,6 +70,7 @@ void AExpression::ExtractPath(const std::vector<String>& path, const Array::Ptr&
if (path.size() == 1) { if (path.size() == 1) {
VERIFY(exprl->m_Operator == &AExpression::OpDict); VERIFY(exprl->m_Operator == &AExpression::OpDict);
Array::Ptr subexprl = exprl->m_Operand1; Array::Ptr subexprl = exprl->m_Operand1;
ObjectLock olock(subexprl);
BOOST_FOREACH(const AExpression::Ptr& expr, subexprl) { BOOST_FOREACH(const AExpression::Ptr& expr, subexprl) {
result->Add(expr); result->Add(expr);
} }
@ -86,6 +89,7 @@ void AExpression::FindDebugInfoPath(const std::vector<String>& path, DebugInfo&
if (m_Operator == &AExpression::OpDict) { if (m_Operator == &AExpression::OpDict) {
Array::Ptr exprl = m_Operand1; Array::Ptr exprl = m_Operand1;
ObjectLock olock(exprl);
BOOST_FOREACH(const AExpression::Ptr& expr, exprl) { BOOST_FOREACH(const AExpression::Ptr& expr, exprl) {
expr->FindDebugInfoPath(path, result); expr->FindDebugInfoPath(path, result);
} }
@ -113,6 +117,7 @@ void AExpression::DumpOperand(std::ostream& stream, const Value& operand, int in
if (operand.IsObjectType<Array>()) { if (operand.IsObjectType<Array>()) {
Array::Ptr arr = operand; Array::Ptr arr = operand;
stream << String(indent, ' ') << "Array:\n"; stream << String(indent, ' ') << "Array:\n";
ObjectLock olock(arr);
BOOST_FOREACH(const Value& elem, arr) { BOOST_FOREACH(const Value& elem, arr) {
DumpOperand(stream, elem, indent + 1); DumpOperand(stream, elem, indent + 1);
} }
@ -250,6 +255,7 @@ Value AExpression::OpIn(const AExpression *expr, const Dictionary::Ptr& locals)
Array::Ptr arr = right; Array::Ptr arr = right;
bool found = false; bool found = false;
ObjectLock olock(arr);
BOOST_FOREACH(const Value& value, arr) { BOOST_FOREACH(const Value& value, arr) {
if (value == left) { if (value == left) {
found = true; found = true;
@ -285,6 +291,7 @@ Value AExpression::OpFunctionCall(const AExpression *expr, const Dictionary::Ptr
Array::Ptr arr = expr->EvaluateOperand2(locals); Array::Ptr arr = expr->EvaluateOperand2(locals);
std::vector<Value> arguments; std::vector<Value> arguments;
ObjectLock olock(arr);
BOOST_FOREACH(const AExpression::Ptr& aexpr, arr) { BOOST_FOREACH(const AExpression::Ptr& aexpr, arr) {
arguments.push_back(aexpr->Evaluate(locals)); arguments.push_back(aexpr->Evaluate(locals));
} }
@ -298,6 +305,7 @@ Value AExpression::OpArray(const AExpression *expr, const Dictionary::Ptr& local
Array::Ptr result = make_shared<Array>(); Array::Ptr result = make_shared<Array>();
if (arr) { if (arr) {
ObjectLock olock(arr);
BOOST_FOREACH(const AExpression::Ptr& aexpr, arr) { BOOST_FOREACH(const AExpression::Ptr& aexpr, arr) {
result->Add(aexpr->Evaluate(locals)); result->Add(aexpr->Evaluate(locals));
} }
@ -315,6 +323,7 @@ Value AExpression::OpDict(const AExpression *expr, const Dictionary::Ptr& locals
result->Set("__parent", locals); result->Set("__parent", locals);
if (arr) { if (arr) {
ObjectLock olock(arr);
BOOST_FOREACH(const AExpression::Ptr& aexpr, arr) { BOOST_FOREACH(const AExpression::Ptr& aexpr, arr) {
aexpr->Evaluate(in_place ? locals : result); aexpr->Evaluate(in_place ? locals : result);
} }