Hi,

I found a bug in ion3 (from svn last week end) trying to improve
detach.lua:

ion3: region.c:461: region_detach_manager: Assertion
`(((WRegion*)(reg))->manager)==((void *)0)' failed.
/usr/src/ion-snapshot/install/bin/ion3: Caught signal 6. Dying.

My goal was to automatically close the layer 2 non passive WFloatWS
when the last window it contains is closed.

I wrote this (that's really a draft):

function detach.maybe_leave_layer2(table)
   ioncore.exec_on(table.reg, "echo out of if "..table.mode)
   if (table.mode == "remove") then
      local fws = detach.find_ws(table.reg:screen_of(), false)
      ioncore.exec_on(table.reg, "echo it is "..table.mode..",
   fws="..fws:name()..".")
      ioncore.exec_on(table.reg, "...
   table.reg:manager()="..table.reg:manager():name())
      -- table.reg is not yet detached
      if fws and fws == table.reg:manager() then
         local l = fws:managed_list()
         local empty = true
         -- hmm, there should be a better way to check emptyness :-\
         for _, r in l do
            -- Ah, if that's me, I'm just being removed. Doesn't
   count.
            if r ~= table.reg then
               empty = false
            end
         end
         if empty then
            ioncore.exec_on(table.reg, "echo empty XXXXX")
            fws:rqclose_relocate()
         else
            ioncore.exec_on(table.reg, "echo not empty YYY")
         end
      end
   end
end

and function detach.maybe_leave_layer2(table)
   ioncore.exec_on(table.reg, "echo out of if "..table.mode)
   if (table.mode == "remove") then
      local fws = detach.find_ws(table.reg:screen_of(), false)
      ioncore.exec_on(table.reg, "echo it is "..table.mode..",
   fws="..fws:name()..".")
      ioncore.exec_on(table.reg, "...
   table.reg:manager()="..table.reg:manager():name())
      -- table.reg is not yet detached
      if fws and fws == table.reg:manager() then
         local l = fws:managed_list()
         local empty = true
         -- hmm, there should be a better way to check emptyness :-\
         for _, r in l do
            -- Ah, if that's me, I'm just being removed. Doesn't
   count.
            if r ~= table.reg then
               empty = false
            end
         end
         if empty then
            ioncore.exec_on(table.reg, "echo empty XXXXX")
            fws:rqclose_relocate()
         else
            ioncore.exec_on(table.reg, "echo not empty YYY")
         end
      end
   end
end

and added this function to frame_managed_changed_hook. Then, added a
window to the layer 2 workspace, and when I removed it, "boom".

Valgrind doesn't say anything, and the bug seems to be reproducible.

If anyone has either a better way to achieve my goal, a fix for the
bug, or both, ...

Thanks

-- 
Matthieu

Reply via email to