[tekui-devel] tekui: Application: does not suspend when there are still corout...
Timm S. Mueller
tmueller at schulze-mueller.de
Fri Oct 10 16:59:55 CEST 2008
details: http://hg.teklib.org/tekui/rev/bbada43fbb66
changeset: 27:bbada43fbb66
user: Timm S. Mueller <tmueller at schulze-mueller.de>
date: Fri Oct 10 16:54:06 2008 +0200
description:
Application: does not suspend when there are still coroutines around;
Pagegroup: added sanity check when switching tabs
diffs (truncated from 122 to 100 lines):
diff -r 44f37360d8ab -r bbada43fbb66 tek/ui/class/application.lua
--- a/tek/ui/class/application.lua Fri Oct 10 16:10:38 2008 +0200
+++ b/tek/ui/class/application.lua Fri Oct 10 16:54:06 2008 +0200
@@ -100,7 +100,7 @@ local unpack = unpack
local unpack = unpack
module("tek.ui.class.application", tek.ui.class.family)
-_VERSION = "Application 8.0"
+_VERSION = "Application 8.1"
-------------------------------------------------------------------------------
-- class implementation:
@@ -377,7 +377,7 @@ end
-- wait:
-------------------------------------------------------------------------------
-function Application:wait()
+function Application:waitWindows(suspend)
local ow = self.OpenWindows
local vt = self.WaitVisuals
@@ -400,8 +400,10 @@ function Application:wait()
end
end
- -- wait for open windows:
- self.Display:wait(vt, numv)
+ if suspend then
+ -- wait for open windows:
+ self.Display:wait(vt, numv)
+ end
-- service windows that have messages pending:
local ma = self.MsgActive
@@ -483,12 +485,19 @@ function Application:run()
local state = { self }
local ma = self.MsgActive
+ -- the main loop:
+
while self.Status == "running" and #self.OpenWindows > 0 do
- self:serviceCoroutines()
+
+ -- if no coroutines are left, we may actually go to sleep:
+ local suspend = self:serviceCoroutines() == 0
+
if collectgarbage then
collectgarbage("step")
end
- self:wait()
+
+ self:waitWindows(suspend)
+
while #ma > 0 do
state[2] = remove(ma, 1)
repeat
@@ -507,6 +516,7 @@ function Application:run()
state[5] = false
end
end
+
end
-- hide all windows:
@@ -533,7 +543,7 @@ end
end
-------------------------------------------------------------------------------
--- serviceCoroutine: internal
+-- numcoroutines = serviceCoroutines() - internal
-------------------------------------------------------------------------------
function Application:serviceCoroutines()
@@ -552,6 +562,7 @@ function Application:serviceCoroutines()
end
end
end
+ return #crt
end
-------------------------------------------------------------------------------
diff -r 44f37360d8ab -r bbada43fbb66 tek/ui/class/pagegroup.lua
--- a/tek/ui/class/pagegroup.lua Fri Oct 10 16:10:38 2008 +0200
+++ b/tek/ui/class/pagegroup.lua Fri Oct 10 16:54:06 2008 +0200
@@ -58,7 +58,7 @@ local unpack = unpack
local unpack = unpack
module("tek.ui.class.pagegroup", tek.ui.class.group)
-_VERSION = "PageGroup 8.0"
+_VERSION = "PageGroup 8.1"
local PageGroup = _M
-------------------------------------------------------------------------------
@@ -257,12 +257,22 @@ function PageContainerGroup:changeTab(pa
self.PageElement:connect(self)
self.Application:decodeProperties(self.PageElement)
self.PageElement:setup(self.Application, self.Window)
- self.PageElement:show(self.Display, self.Drawable)
- self:askMinMax(0, 0, self.MaxWidth, self.MaxHeight)
- local r = self.Rect
More information about the tekui-devel
mailing list