Issue 111642

Summary: pyuno: Python-implemented Interface attribute is not writeable
Product: udk Reporter: gurfle <gurfler>
Component: codeAssignee: joergbudi
Status: CLOSED DUPLICATE QA Contact: issues@udk <issues>
Severity: Trivial    
Priority: P3 CC: issues
Version: OOo 3.2   
Target Milestone: ---   
Hardware: PC   
OS: All   
URL: http://user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=30543&p=139231#p139231
Issue Type: DEFECT Latest Confirmation in: ---
Developer Difficulty: ---
Issue Depends on:    
Issue Blocks: 111641    

Description gurfle 2010-05-17 01:42:30 UTC
Confirmed on Debian Linux 5.03 and Windows XP, so suspect it crosses all OS
platforms - URL is to a - so far inconclusive - OO Community Forum topic I
started on the issue that also lists the same code examples included below.

As illstrated in the OO Basic macro at the very bottom of this desciption,
assigning a value to a Python-implemeted readwrite attribute of a (UNOIDL)
user-defined Interface causes OO to freeze - soffice process must be killed
before any activity can be resumed.

This can be reproduced using the following example UNOIDL and python modules:

Contents of XTestOOPythonComp.idl (compiled .rdb file to be added as OO
Extension UNO RDB Type Library):

#ifndef __names_nick_openoffice_TestOOPythonComp_idl__
#define __names_nick_openoffice_TestOOPythonComp_idl__

module names { module nick { module openoffice { module TestOOPythonComp {

    interface XTestOOPythonComp
    {
       [attribute] double TestOOPyDouble;
       [attribute] long TestOOPyLong;
       [attribute] string TestOOPyString;

       double OOCompFunction( [in] double a, [in] double b  );

//  The following should not be necessary to properly implement the Interface
with the above attributes
/////////////
       double getTestOOPyDouble( );
       void setTestOOPyDouble( [in] double newTestOOPyDouble );

       long getTestOOPyLong( );
       void setTestOOPyLong( [in] long newTestOOPyLong );

       string getTestOOPyString( );
       void setTestOOPyString( [in] string newTestOOPyString );
/////////////

    };

    service STestOOPythonComp: XTestOOPythonComp;
}; }; }; };
#endif


Contents of TestOOPythonComp.py (to be added as OO Extension UNO Python Component):

import uno
import unohelper

from com.sun.star.lang import XServiceName
from com.sun.star.lang import XServiceInfo

from names.nick.openoffice.TestOOPythonComp import XTestOOPythonComp

class TestOOPythonComp(unohelper.Base, XServiceName, XServiceInfo,
XTestOOPythonComp):

  TestOOPyDouble=47.3
  TestOOPyLong=60000
  TestOOPyString="MyStr"

  ServiceName="STestOOPythonComp"
  ImplementationName="OTestOOPythonComp"

  def __init__(self,newctx=None):
    self.ctx=newctx

  def OOCompFunction(self,a,b):
    return a+b

  #  The following should not be necessary to properly implement the Interface
with the above attributes
  ############
  def getTestOOPyDouble(self):
    return self.TestOOPyDouble
  def setTestOOPyDouble(self,newTestOOPyDouble):
    self.TestOOPyDouble=newTestOOPyDouble

  def getTestOOPyLong(self):
    return self.TestOOPyLong
  def setTestOOPyLong(self,newTestOOPyLong):
    self.TestOOPyLong=newTestOOPyLong

  def getTestOOPyString(self):
    return self.TestOOPyString
  def setTestOOPyString(self,newTestOOPyString):
    self.TestOOPyString=newTestOOPyString
  ############

  def getServiceName(self):
    return self.ServiceName

  def getImplementationName(self):
    return self.ImplementationName

  def getSupportedServiceNames(self):
    return (self.ServiceName,)

g_ImplementationHelper = unohelper.ImplementationHelper()
g_ImplementationHelper.addImplementation(TestOOPythonComp,"names.nick.openoffice.TestOOPythonCompImpl",("com.sun.star.task.Job",),)

OO Basic Macro to test the issue (CAUTION:  As written, it WILL freeze soffice)

Option Explicit

Sub TestOOPythonComp
  Dim x as Object
  Dim y as Double
  x = createUnoService( "names.nick.openoffice.TestOOPythonCompImpl" )
  print x.TestOOPyDouble '  Displays value (47.3) without a problem
  y=23.7
  setTestOOPythonDouble(y) '  This works, as does "print getTestOOpythonDouble()"
  x.TestOOPyDouble=y '  CAUTION:  This causes OO to freeze:  Only killing the
soffice process frees OO up again
End Sub
Comment 1 Olaf Felka 2010-05-17 11:41:39 UTC
dupe

*** This issue has been marked as a duplicate of 111641 ***
Comment 2 Olaf Felka 2010-05-17 11:41:58 UTC
...