summaryrefslogtreecommitdiff
path: root/pyuno/source/module/pyuno.cxx
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@novell.com>2011-05-19 14:46:28 +0100
committerMichael Meeks <michael.meeks@novell.com>2011-05-19 14:50:35 +0100
commitf85638485cdc1ddd25f322ea4c30a386351f4bd5 (patch)
treedc7e0618ce18734d6e617e956a31dc2efc46b2be /pyuno/source/module/pyuno.cxx
parent31c1e6f573498364497480615eb072944c0d9d17 (diff)
don't crash when interacting with a class that implements XInvocation
VclStringResourceLoader eg. test = smgr.createInstance("com.sun.star.resource.VclStringResourceLoader") invocation = test.setValue("FileName", "test") It seems we can't cope with XInvocation implementors, so give a nice exception instead
Diffstat (limited to 'pyuno/source/module/pyuno.cxx')
-rw-r--r--pyuno/source/module/pyuno.cxx19
1 files changed, 16 insertions, 3 deletions
diff --git a/pyuno/source/module/pyuno.cxx b/pyuno/source/module/pyuno.cxx
index dbdddac470b3..2df863dabe5b 100644
--- a/pyuno/source/module/pyuno.cxx
+++ b/pyuno/source/module/pyuno.cxx
@@ -708,14 +708,14 @@ PyObject* PyUNO_new (
Reference<XInterface> tmp_interface;
targetInterface >>= tmp_interface;
+
if (!tmp_interface.is ())
{
// empty reference !
Py_INCREF( Py_None );
return Py_None;
}
-
- return PyUNO_new_UNCHECKED (targetInterface, ssf);
+ return PyUNO_new_UNCHECKED (targetInterface, ssf);
}
@@ -729,14 +729,27 @@ PyObject* PyUNO_new_UNCHECKED (
self = PyObject_New (PyUNO, &PyUNOType);
if (self == NULL)
- return NULL; //NULL == error
+ return NULL; // == error
self->members = new PyUNOInternals();
arguments[0] <<= targetInterface;
{
PyThreadDetach antiguard;
tmp_interface = ssf->createInstanceWithArguments (arguments);
+
+ if (!tmp_interface.is ())
+ {
+ Py_INCREF( Py_None );
+ return Py_None;
+ }
+
Reference<XInvocation2> tmp_invocation (tmp_interface, UNO_QUERY);
+ if (!tmp_invocation.is()) {
+ throw RuntimeException (rtl::OUString::createFromAscii (
+ "XInvocation2 not implemented, cannot interact with object"),
+ Reference< XInterface > ());
+ }
+
self->members->xInvocation = tmp_invocation;
self->members->wrappedObject = targetInterface;
}