Print a warning when trying to destroy the same notification multiple time. (#2662)
* notification: Print a warning when destroying more than once. * doc: Fix a copy paste issue.
This commit is contained in:
parent
698fce9b4e
commit
dd3c270819
|
@ -65,14 +65,14 @@ local notification = {}
|
||||||
-- @beautiful beautiful.notification_height
|
-- @beautiful beautiful.notification_height
|
||||||
-- @tparam int notification_height
|
-- @tparam int notification_height
|
||||||
|
|
||||||
--- Unique identifier of the notification.
|
-- Unique identifier of the notification.
|
||||||
-- This is the equivalent to a PID as allows external applications to select
|
-- This is the equivalent to a PID as allows external applications to select
|
||||||
-- notifications.
|
-- notifications.
|
||||||
-- @property text
|
-- @property id
|
||||||
-- @param string
|
-- @param string
|
||||||
-- @see title
|
-- @see title
|
||||||
|
|
||||||
--- Text of the notification.
|
-- Text of the notification [[deprecated]]
|
||||||
-- @property text
|
-- @property text
|
||||||
-- @param string
|
-- @param string
|
||||||
-- @see title
|
-- @see title
|
||||||
|
@ -237,14 +237,23 @@ local notification = {}
|
||||||
|
|
||||||
--FIXME add methods such as persist
|
--FIXME add methods such as persist
|
||||||
|
|
||||||
--- Destroy notification by notification object
|
--- Destroy notification by notification object.
|
||||||
--
|
--
|
||||||
-- @tparam string reason One of the reasons from `notification_closed_reason`
|
-- @tparam string reason One of the reasons from `notification_closed_reason`
|
||||||
-- @tparam[opt=false] boolean keep_visible If true, keep the notification visible
|
-- @tparam[opt=false] boolean keep_visible If true, keep the notification visible
|
||||||
-- @return True if the popup was successfully destroyed, nil otherwise
|
-- @return True if the popup was successfully destroyed, false otherwise
|
||||||
function notification:destroy(reason, keep_visible)
|
function notification:destroy(reason, keep_visible)
|
||||||
|
if self._private.is_destroyed then
|
||||||
|
gdebug.print_warning("Trying to destroy the same notification twice. It"..
|
||||||
|
" was destroyed because: "..self._private.destroy_reason)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
self:emit_signal("destroyed", reason, keep_visible)
|
self:emit_signal("destroyed", reason, keep_visible)
|
||||||
|
|
||||||
|
self._private.is_destroyed = true
|
||||||
|
self._private.destroy_reason = reason
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue