[Solved] loadComponentFromURL sometimes works, smt. crashes

Keyboard macros or custom scripts

[Solved] loadComponentFromURL sometimes works, smt. crashes

Postby librebuz » Mon Sep 11, 2017 3:49 pm

Hi there,

Edit: This is not really solved, but I found a way to avoid LibreOffice crashing when changing forms via loadComponentFromURL.


This was the problem:
I use loadComponentFromURL to navigate through some Writer-Documents that contain different forms that query a database.

So there are Buttons in my Writer-Documents that open the following Macro:

Code: Select all   Expand viewCollapse view
sub OpenfrmNatuerlichePersonen( oev as variant )
   OpenForm( "/home/bla/natuerliche.odt" ) 
end sub
 
sub OpenfrmJuristischePersonen( oev as variant )
   OpenForm( "/home/bla/juristische.odt" )
end sub

sub OpenfrmVerteiler( oev as variant )
   OpenForm ( "/home/bla/verteiler.odt" )
end sub

Function openForm(sFormName as string) as variant
   cUrl = ConvertToURL( sFormName )
   Dim args(3) As New com.sun.star.beans.PropertyValue
   args(0).Name = "ActiveConnection"
   args(0).Value = getConnectionTC
   args(1).Name = "OpenMode"
   args(1).Value = "open"
   args(2).Name = "MacroExecutionMode"
   args(2).Value = com.sun.star.document.MacroExecMode.ALWAYS_EXECUTE
   args(3).Name = "ReadOnly"
   args(3).Value = TRUE
   oDocFrame = ThisComponent.getCurrentController().getFrame()
   oDocFrame.loadComponentFromURL( cUrl, "_self", 0, args() )
End Function


This works for a while, but after three or four hops between the documents, Libreoffice crashes and tells me the following:
Code: Select all   Expand viewCollapse view
Application Error

Fatal exception: Signal 6
Stack:
/usr/lib/libreoffice/program/libuno_sal.so.3(+0x39430)[0x7f78cb024430]
/usr/lib/libreoffice/program/libuno_sal.so.3(+0x395a1)[0x7f78cb0245a1]
/lib/x86_64-linux-gnu/libc.so.6(+0x33030)[0x7f78cac7e030]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcf)[0x7f78cac7dfcf]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f78cac7f3fa]
/usr/lib/libreoffice/program/libmergedlo.so(+0x2d0b262)[0x7f78cdf4e262]
/usr/lib/libreoffice/program/libmergedlo.so(_ZN11Application5AbortERKN3rtl8OUStringE+0x9a)[0x7f78cded46aa]
/usr/lib/libreoffice/program/libmergedlo.so(+0x1d79d38)[0x7f78ccfbcd38]
/usr/lib/libreoffice/program/libmergedlo.so(+0x2c96ae2)[0x7f78cded9ae2]
/usr/lib/libreoffice/program/libuno_sal.so.3(+0x15192)[0x7f78cb000192]
/usr/lib/libreoffice/program/libuno_sal.so.3(+0x3955f)[0x7f78cb02455f]
/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so(+0x8c15dd)[0x7f78839745dd]
/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so(JVM_handle_linux_signal+0x1b9)[0x7f7883979279]
/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server/libjvm.so(+0x8b9fd8)[0x7f788396cfd8]
/lib/x86_64-linux-gnu/libc.so.6(+0x33030)[0x7f78cac7e030]
/usr/lib/libreoffice/program/libmergedlo.so(_ZN13DbGridControl16AdjustDataSourceEb+0x16f)[0x7f78cd7e159f]
/usr/lib/libreoffice/program/libmergedlo.so(+0x2aaec3f)[0x7f78cdcf1c3f]
/usr/lib/libreoffice/program/libmergedlo.so(_ZN17SalGenericDisplay21DispatchInternalEventEv+0x6c)[0x7f78cdf6ed4c]
/usr/lib/libreoffice/program/libvclplug_gtk3lo.so(+0x4249d)[0x7f78b7a3549d]
/usr/lib/libreoffice/program/libvclplug_gtk3lo.so(+0x42511)[0x7f78b7a35511]
/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_dispatch+0x15a)[0x7f78c8bdd6aa]
/lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x4aa60)[0x7f78c8bdda60]
/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_iteration+0x2c)[0x7f78c8bddb0c]
/usr/lib/libreoffice/program/libvclplug_gtk3lo.so(+0x41b13)[0x7f78b7a34b13]
/usr/lib/libreoffice/program/libmergedlo.so(_ZN11Application5YieldEv+0x51)[0x7f78cded4ed1]
/usr/lib/libreoffice/program/libmergedlo.so(_ZN11Application7ExecuteEv+0x45)[0x7f78cded7405]
/usr/lib/libreoffice/program/libmergedlo.so(+0x1d7fc23)[0x7f78ccfc2c23]
/usr/lib/libreoffice/program/libmergedlo.so(+0x2c97c76)[0x7f78cdedac76]
/usr/lib/libreoffice/program/libmergedlo.so(_Z6SVMainv+0x22)[0x7f78cdedad72]
/usr/lib/libreoffice/program/libmergedlo.so(soffice_main+0x91)[0x7f78ccfe3f61]
/usr/lib/libreoffice/program/soffice.bin(+0x7cb)[0x5557ab09c7cb]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1)[0x7f78cac6b2b1]
/usr/lib/libreoffice/program/soffice.bin(+0x80a)[0x5557ab09c80a]

Openoffice 3.3 had the same problem. I hoped the step to a shiny new Libreoffice would fix the issue, but it's still there. Any ideas? Or workarounds for navigating through documents?

There are some suggestions to deal with the problem mentioned below. What finally resolved the issue was changing the event the macros are bound to. The Macros for changing forms were bound to the event "Approve Action" of a push-button. When I bound the Macros to the event "Mouse Button Released" it suddenly stopped crashing. I have no clue why this worked, but perhaps this can help others who have similar problems.
Last edited by librebuz on Mon Sep 18, 2017 10:14 am, edited 1 time in total.
Libreoffice 5.2.7.2 on Debian Stretch
librebuz
 
Posts: 9
Joined: Mon Sep 11, 2017 3:26 pm

Re: loadComponentFromURL sometimes works, sometimes crashes

Postby Villeroy » Mon Sep 11, 2017 5:26 pm

librebuz wrote:This works for a while, but after three or four hops between the documents, Libreoffice crashes and tells me the following:

What happens when you open the forms manually? You could use simple hyperlinks or buttons instead of the macros with hard coded paths.
I never understood how to use the target string "_default", "_self", "_blank" properly. Did you try if it makes a difference?
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 24808
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: loadComponentFromURL sometimes works, sometimes crashes

Postby RoryOF » Mon Sep 11, 2017 5:45 pm

I'd guess some sort of a race condition, happening perhaps while OO is doing some garbage collection. Try testing for the file(s) existing, using a loop until success, and then opening. We know that the files exist, but if OO is busy in the background they may appear not to exist.
Apache OpenOffice 4.1.4 on Xubuntu 16.04.03 (mostly 64 bit version) and infrequently on Win2K/XP
14 October 2016 was Pooh's 90th birthday
User avatar
RoryOF
Moderator
 
Posts: 25716
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: loadComponentFromURL sometimes works, sometimes crashes

Postby librebuz » Mon Sep 11, 2017 9:18 pm

Thanks for the replies.

Villeroy wrote:What happens when you open the forms manually? You could use simple hyperlinks or buttons instead of the macros with hard coded paths.
I never understood how to use the target string "_default", "_self", "_blank" properly. Did you try if it makes a difference?
Opening manually always works. I tried the other targets without success.
I like the idea to use a link. Unfortunately it's not possible to replace a document with a link -- i tried and the second document was always opened in a new document window. If you use loadComponentFromURL with _self, the current document is replaced by the new one. Weird thing is: you can also use _self as target of a link, but it does not work as expected, it always opens a new document.

RoryOF wrote:I'd guess some sort of a race condition, happening perhaps while OO is doing some garbage collection. Try testing for the file(s) existing, using a loop until success, and then opening. We know that the files exist, but if OO is busy in the background they may appear not to exist.

I tried:
Code: Select all   Expand viewCollapse view
Function openForm(sFormName as string) as variant
   cUrl = ConvertToURL( sFormName )
   Dim args(3) As New com.sun.star.beans.PropertyValue
   args(0).Name = "ActiveConnection"
   args(0).Value = getConnectionTC
   args(1).Name = "OpenMode"
   args(1).Value = "open"
   args(2).Name = "MacroExecutionMode"
   args(2).Value = com.sun.star.document.MacroExecMode.ALWAYS_EXECUTE
   args(3).Name = "ReadOnly"
   args(3).Value = TRUE
   oDocFrame = ThisComponent.getCurrentController().getFrame()

   Do Until FileExists(cUrl)
   Loop

   oDocFrame.loadComponentFromURL( cUrl, "_self", 0, args() )
End Function


But it still crashes after some hops :(
Anything else I could wait for in this loop?
Perhaps it's not the document but some other element?
Libreoffice 5.2.7.2 on Debian Stretch
librebuz
 
Posts: 9
Joined: Mon Sep 11, 2017 3:26 pm

Re: loadComponentFromURL sometimes works, sometimes crashes

Postby RPG » Mon Sep 11, 2017 10:19 pm

Hello

I think the advice of Vileroy to use a link is better and more easy. When you use a link you can insert "_self" or an other option. When you use a macro then the macros must maybe stored in MyMacro's.

Romke
LibreOffice 5.3.6.1 on openSUSE Leap 42.3
RPG
Volunteer
 
Posts: 2106
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: loadComponentFromURL sometimes works, sometimes crashes

Postby librebuz » Mon Sep 11, 2017 10:45 pm

RPG wrote:Hello

I think the advice of Vileroy to use a link is better and more easy. When you use a link you can insert "_self" or an other option. When you use a macro then the macros must maybe stored in MyMacro's.

Romke


Hello. When I use link it's not possible to open the new form in the same document window.
Also I have five forms, three of them with subforms, about 80 Macros organized in various Libraries, so easy is not an option anymore :(
Libreoffice 5.2.7.2 on Debian Stretch
librebuz
 
Posts: 9
Joined: Mon Sep 11, 2017 3:26 pm

Re: loadComponentFromURL sometimes works, sometimes crashes

Postby Villeroy » Mon Sep 11, 2017 10:52 pm

:shock: Why?
Code: Select all   Expand viewCollapse view
   Do Until FileExists(cUrl)
   Loop
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 24808
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: loadComponentFromURL sometimes works, sometimes crashes

Postby librebuz » Mon Sep 11, 2017 10:53 pm

But: I found a strange way to avoid the problem.
The Macros for changing forms were bound to the event "Approve Action" of a push-button.
After I bound the Macros to the event "Mouse Button Released" it suddenly stopped crashing.

Should I add "solved" to the title? It's not crashing anymore, but ... it should work also if it's bound to "Approve Action".
Last edited by librebuz on Mon Sep 11, 2017 10:55 pm, edited 2 times in total.
Libreoffice 5.2.7.2 on Debian Stretch
librebuz
 
Posts: 9
Joined: Mon Sep 11, 2017 3:26 pm

Re: loadComponentFromURL sometimes works, sometimes crashes

Postby RoryOF » Mon Sep 11, 2017 10:55 pm

Villeroy wrote::shock: Why?
Code: Select all   Expand viewCollapse view
   Do Until FileExists(cUrl)
   Loop


I suggested that might be a solution for some race condition, where Openoffice could not find the target file because it was doing some internal housekeeping. But if it doesn't help, there is no reason to keep it in the code.
Apache OpenOffice 4.1.4 on Xubuntu 16.04.03 (mostly 64 bit version) and infrequently on Win2K/XP
14 October 2016 was Pooh's 90th birthday
User avatar
RoryOF
Moderator
 
Posts: 25716
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 2 guests