[Libreoffice-bugs] [Bug 112877] Database connect fails depending on memory usage and opening of a file dialog
bugzilla-daemon at bugs.documentfoundation.org
bugzilla-daemon at bugs.documentfoundation.org
Wed Oct 4 14:14:07 UTC 2017
https://bugs.documentfoundation.org/show_bug.cgi?id=112877
--- Comment #1 from Gerhard Schaber <gerhard.schaber at gmx.at> ---
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,
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20171004/6381af22/attachment.html>
More information about the Libreoffice-bugs
mailing list