From d1f00a543929292a5e41bcfc57523f390627c555 Mon Sep 17 00:00:00 2001 From: "markh%activestate.com" Date: Sat, 18 Aug 2001 14:27:46 +0000 Subject: [PATCH] Fix a bug in interface flattening when an attribute was set before one on the same interface was fetched. Added test for this case too. Not part of the build. git-svn-id: svn://10.0.0.236/trunk@101412 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/extensions/python/xpcom/client/__init__.py | 6 +++++- mozilla/extensions/python/xpcom/test/test_test_component.py | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mozilla/extensions/python/xpcom/client/__init__.py b/mozilla/extensions/python/xpcom/client/__init__.py index e422dd49a17..70e784a117e 100644 --- a/mozilla/extensions/python/xpcom/client/__init__.py +++ b/mozilla/extensions/python/xpcom/client/__init__.py @@ -299,7 +299,11 @@ class Component(_XPCOMBase): self._build_all_supported_interfaces_() interface_name = self.__dict__['_name_to_interface_name_'].get(attr, None) if interface_name is not None: - interface = self._interface_names_[interface_name] + interface = self._interface_names_.get(interface_name, None) + if interface is None: + iid = XPTI_GetInterfaceInfoManager().GetInfoForName(interface_name).GetIID() + self.QueryInterface(iid) + interface = self.__dict__['_interface_names_'][interface_name] setattr(interface, attr, val) return raise AttributeError, "XPCOM component '%s' can not set attribute '%s'" % (self._object_name_, attr) diff --git a/mozilla/extensions/python/xpcom/test/test_test_component.py b/mozilla/extensions/python/xpcom/test/test_test_component.py index 8bb82eb1ab3..2f55b88bc8d 100644 --- a/mozilla/extensions/python/xpcom/test/test_test_component.py +++ b/mozilla/extensions/python/xpcom/test/test_test_component.py @@ -380,6 +380,12 @@ def test_all(): c = xpcom.components.classes[contractid].createInstance() test_base_interface(c) test_derived_interface(c, test_flat=1) + + # We had a bug where a "set" of an attribute before a "get" failed. + # Don't let it happen again :) + c = xpcom.components.classes[contractid].createInstance() + c.boolean_value = 0 + # This name is used in exceptions etc - make sure we got it from nsIClassInfo OK. assert c._object_name_ == "Python.TestComponent"