[Libreoffice-commits] .: pyuno/source

Michael Meeks michael at kemper.freedesktop.org
Thu May 19 06:51:34 PDT 2011


 pyuno/source/module/pyuno.cxx          |   19 ++++++++++++++++---
 pyuno/source/module/pyuno_callable.cxx |    4 +++-
 2 files changed, 19 insertions(+), 4 deletions(-)

New commits:
commit 9ca6726e9f44c0540ef1a939b6a0fa347e5ae2b8
Author: Michael Meeks <michael.meeks at novell.com>
Date:   Thu May 19 14:46:28 2011 +0100

    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

diff --git a/pyuno/source/module/pyuno.cxx b/pyuno/source/module/pyuno.cxx
index 75844c9..6626796 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;
     }
diff --git a/pyuno/source/module/pyuno_callable.cxx b/pyuno/source/module/pyuno_callable.cxx
index 2f5322e..2da9968 100644
--- a/pyuno/source/module/pyuno_callable.cxx
+++ b/pyuno/source/module/pyuno_callable.cxx
@@ -255,7 +255,9 @@ PyRef PyUNO_callable_new (
     enum ConversionMode mode )
 {
     PyUNO_callable* self;
-  
+
+    OSL_ENSURE (my_inv.is(), "XInvocation must be valid");
+
     self = PyObject_New (PyUNO_callable, &PyUNO_callable_Type);
     if (self == NULL)
         return NULL; //NULL == Error!


More information about the Libreoffice-commits mailing list