Bug 112877 - Database connect fails depending on memory usage and opening of a file dialog
Summary: Database connect fails depending on memory usage and opening of a file dialog
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
5.4.1.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-04 14:12 UTC by Gerhard Schaber
Modified: 2018-06-12 11:41 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gerhard Schaber 2017-10-04 14:12:02 UTC
When the memory usage is high on the machine, and you open a file dialog ("com.sun.star.ui.dialogs.FilePicker") prior to running "ThisDatabaseDocument.CurrentController.connect" in a BASIC macro, all subsequent calls to ThisDatabaseDocument.CurrentController.connect. Also it is then not possible to edit the database. You get an error saying that the JRE is corrupt and cannot be loaded.

It only works when you connect (ThisDatabaseDocument.CurrentController.connect) before opening the file dialog. It even works when you manually click on the "Table" view of another database document. Once the JRE is loaded it does not matter what you do.

I am using an embedded hsqldb database with a huge macro library. This is pretty hard to reproduce with a small test library.

It is not so much the fact that under low memory conditions the JRE cannot be loaded--it is just so unpredictable and almost impossible to find out why this is happening.
Comment 1 Gerhard Schaber 2017-10-04 14:14:07 UTC
Sample code:
REM  *****  BASIC  *****

Sub Main
	ThisComponent.DialogLibraries.LoadLibrary("GSCLib")
	GlobalScope.BasicLibraries.loadLibrary("Tools") 
	currentDir = DirectoryNameoutofPath(ConvertFromURL(ThisComponent.Location), getPathSeparator()) & getPathSeparator() & "work"
	filepath = OpenFileName(currentDir, "lehrgangslistemanuelltext.csv", "Lehrgangsdaten importieren")
	On Error Goto ErrorHandler
	if (not ThisDatabaseDocument.CurrentController.isConnected) then
		ThisDatabaseDocument.CurrentController.connect
	endif
	oConn = ThisDatabaseDocument.CurrentController.ActiveConnection
	On Error Goto 0
   exit sub
ErrorHandler:
	if (GetGUIType() = 1) then
		MsgBox("Es konnte keine Datenbankverbindung hergestellt werden. Vermutlich ist entweder kein 32bit (i586/x86) Java auf dem System installiert oder in LibreOffice unter Extras > Optionen > LibreOffice > Erweitert ist eine falsche Java-Version ausgewählt." & CHR(13) & CHR(13) & "Eventuell ist die aktuelle Datenbankdatei in einem anderen Programm (LibreOffice/soffice oder Java) geöffnet. In diesem Fall diese Datei und alle LibreOffice und Java-Programme beenden, gegebenenfalls den Windows Taskmanager dazu benützen.", MB_ICONSTOP + MB_OK + MB_DEFBUTTON1)
	else
		MsgBox("Es konnte keine Datenbankverbindung hergestellt werden. Vermutlich ist Java nicht richtig auf dem System installiert oder in LibreOffice unter Extras > Optionen > LibreOffice > Erweitert ist eine falsche Java-Version ausgewählt." & CHR(13) & CHR(13) & "Eventuell ist die aktuelle Datenbankdatei in einem anderen Programm (LibreOffice/soffice oder Java) geöffnet. In diesem Fall diese Datei und alle LibreOffice und Java-Programme beenden. Notfalls Java neu installieren.", MB_ICONSTOP + MB_OK + MB_DEFBUTTON1)
	endif
	Stop
End Sub

Function OpenFileName(folder, fileName, title)
  GlobalScope.BasicLibraries.loadLibrary("Tools") 
  fileOpenDlg = createUnoService("com.sun.star.ui.dialogs.FilePicker")
' fileOpenDlg.setMultiSelectionMode(false)

  Args = Array(com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_SIMPLE)
  fileOpenDlg.initialize(Args)
  fileOpenDlg.title = title
        
  if len(folder) > 0 then
    fileOpenDlg.setDisplayDirectory(ConvertToUrl(folder))
  endif
  
  if len(fileName) > 0 then
    fileOpenDlg.setDefaultName(fileName)
  endif

  fileOpenDlg.appendFilter("CSV (in UTF-8), Microsoft Excel", "*.csv;*.xls;*.xlsx;*.ods")
  fileOpenDlg.appendFilter("Alle Dateien", "*.*")
  ' fileOpenDlg.setLabel( com.sun.star.ui.dialogs.CommonFilePickerElementIds.PUSHBUTTON_OK, "Save" )
  fileOpenDlg.execute()
  files = fileOpenDlg.getFiles()
  
  if ((ubound(files) - lbound(files) + 1) > 0) then
     OpenFileName() = ConvertFromURL(files(0))
  else
     OpenFileName() = ""
  endIf
  fileOpenDlg.dispose()
End Function 

When I move the "ThisDatabaseDocument.CurrentController.connect" call above the OpenFilename call, it works always, even under low memory conditions.

If there are hints on how to handle such things better, please let me eknow,
Comment 2 Gerhard Schaber 2017-10-05 10:44:02 UTC
Maybe this is related to bug 100850
Comment 3 Xisco Faulí 2018-06-12 11:03:36 UTC
Thank you for reporting the bug.
it seems you're using an old version of LibreOffice.
from https://www.libreoffice.org/download/libreoffice-fresh/ ?
I have set the bug's status to 'NEEDINFO'. Please change it back to
'UNCONFIRMED' if the bug is still present in the latest version.
Comment 4 Gerhard Schaber 2018-06-12 11:40:08 UTC
I just tried to reproduce this with 6.0.5.1, and could not so far. Please close this bug.
Comment 5 Xisco Faulí 2018-06-12 11:41:40 UTC
Thanks for retesting with the latest version.
Setting to RESOLVED WORKSFORME as the commit fixing this issue hasn't been identified.