ui: support Window.Draw(nil) in OpsReader

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-07-15 11:42:47 +02:00
parent 5b3090b128
commit 8eb58ff2eb
+9 -2
View File
@@ -231,15 +231,22 @@ func (b BlockOp) Add(o *Ops) {
// Reset start reading from the op list.
func (r *OpsReader) Reset(ops *Ops) {
r.stack = r.stack[:0]
r.pc = pc{}
r.ops = nil
if ops == nil {
return
}
if n := len(ops.stack); n > 0 {
panic(fmt.Errorf("%d Begin(s) not matched with End", n))
}
r.ops = &ops.ops
r.stack = r.stack[:0]
r.pc = pc{}
}
func (r *OpsReader) Decode() (EncodedOp, bool) {
if r.ops == nil {
return EncodedOp{}, false
}
for {
if len(r.stack) > 0 {
b := r.stack[len(r.stack)-1]