summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/CHANGES3
-rw-r--r--cpp/src/Ice/Instance.cpp2
-rw-r--r--cpp/src/Ice/Instance.h2
-rw-r--r--cpp/src/Ice/Proxy.cpp26
-rw-r--r--cpp/src/Ice/Reference.cpp50
-rw-r--r--cpp/src/Ice/Reference.h2
-rw-r--r--cpp/test/Ice/operations/Twoways.cpp5
-rw-r--r--cpp/test/Ice/operations/TwowaysAMI.cpp9
8 files changed, 25 insertions, 74 deletions
diff --git a/cpp/CHANGES b/cpp/CHANGES
index e566da25aee..589022f2a14 100644
--- a/cpp/CHANGES
+++ b/cpp/CHANGES
@@ -1,6 +1,9 @@
Changes since version 2.1.2
---------------------------
+- Communicator::setDefaultContext no longer changes the context
+ information set on existing proxies.
+
- slice2cpp and slice2freeze now provide the --add-header option. It adds a
#include directive for the specified header at the beginning of the generated
source file. For example:
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp
index 3c6d9c3a42d..f5eec22f276 100644
--- a/cpp/src/Ice/Instance.cpp
+++ b/cpp/src/Ice/Instance.cpp
@@ -400,7 +400,7 @@ IceInternal::Instance::setDefaultContext(const Context& ctx)
_defaultContext = ctx;
}
-const Context&
+Context
IceInternal::Instance::getDefaultContext() const
{
IceUtil::RecMutex::Lock sync(*this);
diff --git a/cpp/src/Ice/Instance.h b/cpp/src/Ice/Instance.h
index 6f6dedef17a..44b50d98e95 100644
--- a/cpp/src/Ice/Instance.h
+++ b/cpp/src/Ice/Instance.h
@@ -76,7 +76,7 @@ public:
Ice::Int serverACM() const;
void flushBatchRequests();
void setDefaultContext(const ::Ice::Context&);
- const ::Ice::Context& getDefaultContext() const;
+ ::Ice::Context getDefaultContext() const;
private:
diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp
index e9b70364262..11e8e6077dc 100644
--- a/cpp/src/Ice/Proxy.cpp
+++ b/cpp/src/Ice/Proxy.cpp
@@ -333,31 +333,17 @@ IceProxy::Ice::Object::ice_getContext() const
ObjectPrx
IceProxy::Ice::Object::ice_newContext(const Context& newContext) const
{
- if(_reference->hasContext() && newContext == _reference->getContext())
- {
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
- }
- else
- {
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeContext(newContext));
- return proxy;
- }
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeContext(newContext));
+ return proxy;
}
ObjectPrx
IceProxy::Ice::Object::ice_defaultContext() const
{
- if(!_reference->hasContext())
- {
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
- }
- else
- {
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->defaultContext());
- return proxy;
- }
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->defaultContext());
+ return proxy;
}
Identity
diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp
index 383befc7907..6e89cb098b6 100644
--- a/cpp/src/Ice/Reference.cpp
+++ b/cpp/src/Ice/Reference.cpp
@@ -35,19 +35,14 @@ void IceInternal::decRef(IceInternal::Reference* p) { p->__decRef(); }
const Context&
IceInternal::Reference::getContext() const
{
- return _hasContext ? _context : _instance->getDefaultContext();
+ return _context;
}
ReferencePtr
IceInternal::Reference::defaultContext() const
{
- if(!_hasContext)
- {
- return ReferencePtr(const_cast<Reference*>(this));
- }
ReferencePtr r = _instance->referenceFactory()->copy(this);
- r->_hasContext = false;
- r->_context.clear();
+ r->_context = _instance->getDefaultContext();
return r;
}
@@ -60,12 +55,7 @@ IceInternal::Reference::getCommunicator() const
ReferencePtr
IceInternal::Reference::changeContext(const Context& newContext) const
{
- if(_hasContext && newContext == _context)
- {
- return ReferencePtr(const_cast<Reference*>(this));
- }
ReferencePtr r = _instance->referenceFactory()->copy(this);
- r->_hasContext = true;
r->_context = newContext;
return r;
}
@@ -111,8 +101,7 @@ IceInternal::Reference::changeDefault() const
{
ReferencePtr r = _instance->referenceFactory()->copy(this);
r->_mode = ModeTwoway;
- r->_hasContext = false;
- r->_context.clear();
+ r->_context = _instance->getDefaultContext();
r->_facet = "";
return r;
}
@@ -142,18 +131,15 @@ Reference::hash() const
h = 5 * h + *p;
}
- if(_hasContext)
+ for(q = _context.begin(); q != _context.end(); ++q)
{
- for(q = _context.begin(); q != _context.end(); ++q)
+ for(p = q->first.begin(); p != q->first.end(); ++p)
{
- for(p = q->first.begin(); p != q->first.end(); ++p)
- {
- h = 5 * h + *p;
- }
- for(p = q->second.begin(); p != q->second.end(); ++p)
- {
- h = 5 * h + *p;
- }
+ h = 5 * h + *p;
+ }
+ for(p = q->second.begin(); p != q->second.end(); ++p)
+ {
+ h = 5 * h + *p;
}
}
@@ -299,11 +285,6 @@ IceInternal::Reference::operator==(const Reference& r) const
return false;
}
- if(_hasContext != r._hasContext)
- {
- return false;
- }
-
if(_context != r._context)
{
return false;
@@ -348,15 +329,6 @@ IceInternal::Reference::operator<(const Reference& r) const
return false;
}
- if(_hasContext < r._hasContext)
- {
- return true;
- }
- else if(r._hasContext < _hasContext)
- {
- return false;
- }
-
if(_context < r._context)
{
return true;
@@ -406,7 +378,6 @@ IceInternal::Reference::Reference(const InstancePtr& inst, const CommunicatorPtr
_communicator(com),
_mode(md),
_identity(ident),
- _hasContext(!ctx.empty()),
_context(ctx),
_facet(fs),
_hashInitialized(false)
@@ -418,7 +389,6 @@ IceInternal::Reference::Reference(const Reference& r)
_communicator(r._communicator),
_mode(r._mode),
_identity(r._identity),
- _hasContext(r._hasContext),
_context(r._context),
_facet(r._facet),
_hashInitialized(false)
diff --git a/cpp/src/Ice/Reference.h b/cpp/src/Ice/Reference.h
index 37441044bd4..d317a8828e6 100644
--- a/cpp/src/Ice/Reference.h
+++ b/cpp/src/Ice/Reference.h
@@ -64,7 +64,6 @@ public:
ReferencePtr changeContext(const Ice::Context&) const;
ReferencePtr changeMode(Mode) const;
ReferencePtr changeIdentity(const Ice::Identity&) const;
- bool hasContext() const { return _hasContext; }
ReferencePtr changeFacet(const std::string&) const;
//
@@ -115,7 +114,6 @@ private:
Mode _mode;
Ice::Identity _identity;
- bool _hasContext;
Ice::Context _context;
std::string _facet;
diff --git a/cpp/test/Ice/operations/Twoways.cpp b/cpp/test/Ice/operations/Twoways.cpp
index 4653086f2bf..86c7ab4c959 100644
--- a/cpp/test/Ice/operations/Twoways.cpp
+++ b/cpp/test/Ice/operations/Twoways.cpp
@@ -648,7 +648,7 @@ twoways(const Ice::CommunicatorPtr& communicator, const Test::MyClassPrx& p)
Ice::Context dflt;
dflt["a"] = "b";
communicator->setDefaultContext(dflt);
- test(p->opContext() == dflt);
+ test(p->opContext() != dflt);
Test::MyClassPrx p2 = Test::MyClassPrx::uncheckedCast(p->ice_newContext(Ice::Context()));
test(p2->opContext().empty());
@@ -657,8 +657,7 @@ twoways(const Ice::CommunicatorPtr& communicator, const Test::MyClassPrx& p)
test(p2->opContext() == dflt);
communicator->setDefaultContext(Ice::Context());
- test(p->opContext().empty());
- test(p2->opContext().empty());
+ test(!p2->opContext().empty());
}
}
}
diff --git a/cpp/test/Ice/operations/TwowaysAMI.cpp b/cpp/test/Ice/operations/TwowaysAMI.cpp
index c322256bf09..0961a421cd3 100644
--- a/cpp/test/Ice/operations/TwowaysAMI.cpp
+++ b/cpp/test/Ice/operations/TwowaysAMI.cpp
@@ -1138,7 +1138,7 @@ twowaysAMI(const Ice::CommunicatorPtr& communicator, const Test::MyClassPrx& p)
dflt["a"] = "b";
communicator->setDefaultContext(dflt);
{
- AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(dflt);
+ AMI_MyClass_opContextNotEqualIPtr cb = new AMI_MyClass_opContextNotEqualI(dflt);
p->opContext_async(cb);
test(cb->check());
}
@@ -1159,12 +1159,7 @@ twowaysAMI(const Ice::CommunicatorPtr& communicator, const Test::MyClassPrx& p)
communicator->setDefaultContext(Ice::Context());
{
- AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(Ice::Context());
- p->opContext_async(cb);
- test(cb->check());
- }
- {
- AMI_MyClass_opContextEqualIPtr cb = new AMI_MyClass_opContextEqualI(Ice::Context());
+ AMI_MyClass_opContextNotEqualIPtr cb = new AMI_MyClass_opContextNotEqualI(Ice::Context());
p2->opContext_async(cb);
test(cb->check());
}