Apache OpenOffice (AOO) Bugzilla – Issue 52057
starbasic:Global of userdefined type gets lost
Last modified: 2017-05-20 10:44:13 UTC
The workaround is: save in in an array. <<<<<<<<<<<<<<<<BASIC>>>>>>>>>>>>>>>>>> Option Explicit Type myObj2 Document EventListener End Type Global aObj(0) Global oMyObj as myObj2 ' Run this routine several times Sub Main() Main2() Main3() End Sub Sub Main2 if isEmpty(oMyObj) then oMyObj = createObject("myObj2") if IsEmpty(oMyObj.Document) then MsgBox("oMyObj.Document was Empty") oMyObj.Document = 10 MsgBox("oMyObj.Document now " & oMyObj.Document) else MsgBox("oMyObj.Document was " & oMyObj.Document) oMyObj.Document = oMyObj.Document +5 end if End Sub Sub Main3 if isEmpty(aObj(0)) then aObj(0) = createObject("myObj2") if IsEmpty(aObj(0).Document) then MsgBox("aObj(0).Document was Empty") aObj(0).Document = 10 MsgBox("aObj(0).Document now " & aObj(0).Document) else MsgBox("aObj(0).Document was " & aObj(0).Document) aObj(0).Document = aObj(0).Document +5 end if End Sub <<<<<<<<<<<<<<<<<END BASIC>>>>>>>>>>>>>>>>>>>>>>>>>>>
reassign to ab
Started
OS: Linux -> Windows,all as this is no Linux specific problem.
Simpler workaround: Global oMyObj As Variant and initialize at runtime, as in your code. Same bug and solution with a Uno structure Global aDate As New com.sun.star.util.Date replace with : Global aDate As Object Sub initalize aDate = New com.sun.star.util.Date aDate.Year = 2015 .... End Sub
Reset the assignee to the default "issues@openoffice.apache.org".