mpc.lua: Fix "connection closed"-detection

Thanks to SammysHP for reporting this on IRC.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2017-01-29 11:30:05 +01:00
parent dfc23755e3
commit a0898fc6b7
1 changed files with 3 additions and 3 deletions

View File

@ -76,9 +76,9 @@ function mpc:_connect()
self._input:read_line_async(GLib.PRIORITY_DEFAULT, nil, function(obj, res)
local line, err = obj:read_line_finish(res)
-- Ugly API. On success we get string, length-of-string
-- and on error we get nil, error
--if tostring(line) == "" and err == 1 then
if tostring(line) == "" then
-- and on error we get nil, error. Other versions of lgi
-- behave differently.
if line == nil or tostring(line) == "" then
err = "Connection closed"
end
if type(err) ~= "number" then