| Summary: | Database connect fails depending on memory usage and opening of a file dialog | ||
|---|---|---|---|
| Product: | LibreOffice | Reporter: | Gerhard Schaber <gerhard.schaber> |
| Component: | BASIC | Assignee: | Not Assigned <libreoffice-bugs> |
| Status: | RESOLVED WORKSFORME | ||
| Severity: | normal | CC: | xiscofauli |
| Priority: | medium | ||
| Version: | 5.4.1.2 release | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
| Crash report or crash signature: | Regression By: | ||
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,
Maybe this is related to bug 100850 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. I just tried to reproduce this with 6.0.5.1, and could not so far. Please close this bug. Thanks for retesting with the latest version. Setting to RESOLVED WORKSFORME as the commit fixing this issue hasn't been identified. |
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.