2014-04-17 14:50 GMT-03:00 Mattias Gaertner <[email protected]>:

> On Thu, 17 Apr 2014 14:35:07 -0300
> silvioprog <[email protected]> wrote:
>
> > 2014-04-16 22:07 GMT-03:00 waldo kitty <[email protected]>:
> > [...]
> >
> > > and you don't get any kind of exception or other error results??
> > >
> >
> > No error occurs, and it doesn't opens file. :/
> >
> > I'm trying to debug LCL in trying to figure out the problem ...
>
> The OpenDocument function does not raise exceptions under Linux. It
> returns false if no application was found.
>
> It should be improved to raise an exception for the errors it can spot.
> Like not finding the application or if the program returns bytes on
> Stderr or if the ExitCode<>0.


I found the error. In a terminal, when I call:

$ xdg-open test.txt

The "test.txt" file is opened into terminal. But when I call:

$ gnome-open test.txt

The "test.txt" file is opened into Pluma Editor (native text editor on
Linux Mint, like GEdit in Ubuntu).

Then seems a problem in Linux Mint (Mate).

To solve my problem, I changed the function from:

[code]
function OpenDocument(APath: String): Boolean;
var
  lApp: string;
begin
  // Android uses this
  if Assigned(OpenDocumentWidgetsetImplementation) then
  begin
    Result := OpenDocumentWidgetsetImplementation(APath);
    Exit;
  end;

  Result := True;
  if not FileExistsUTF8(APath) then exit(false);

  lApp:=FindFilenameOfCmd('xdg-open'); // Portland OSDL/FreeDesktop
standard on Linux
  if lApp='' then
    lApp:=FindFilenameOfCmd('kfmclient'); // KDE command
  if lApp='' then
    lApp:=FindFilenameOfCmd('gnome-open'); // GNOME command
  if lApp='' then
    Exit(False);

  if (APath<>'') and (APath[1]<>'"') then
    APath:=QuotedStr(APath);
  RunCmdFromPath(lApp,APath);
end;
[/code]

To:

[code]
function OpenDocument(const APath: String): Boolean;
var
  lApp: string;
begin
  // Android uses this
  if Assigned(OpenDocumentWidgetsetImplementation) then
  begin
    Result := OpenDocumentWidgetsetImplementation(APath);
    Exit;
  end;

  Result := True;
  if not FileExistsUTF8(APath) then exit(false);

  lApp:=FindFilenameOfCmd('gnome-open'); // GNOME command
  if lApp='' then
    lApp:=FindFilenameOfCmd('kfmclient') // KDE command
  else
  if lApp='' then
    lApp:=FindFilenameOfCmd('xdg-open') // Portland OSDL/FreeDesktop
standard on Linux
  else
  if lApp='' then
    Exit(False);

  if (APath<>'') and (APath[1]<>'"') then
    APath:=QuotedStr(APath);
  RunCmdFromPath(lApp,APath);
end;
[/code]

Quick fix! :p

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to