Permalink
Browse files

Fixes a bug involving calling the base class via 'error(SUPER)'.

Consider the following:

local edit = QTextEdit.new_local()
function edit:keyPressEvent(e)
	-- do something
	error(SUPER)
end

This causes the base class QTextEdit::keyPressEvent(e) to be called twice since
the generated virtual method has the following form:

void lqt_shell_QTextEdit::keyPressEvent (QKeyEvent* arg1) {
  // ...
  if (lua_isfunction(L, -1)) {
    // ...
    if (!lqtL_pcall(L, 2, 0, 0)) {
      // ...
    } else {
      if (lqtL_is_super(L, lua_gettop(L))) {
        // ...
        this->QTextEdit::keyPressEvent(arg1);
      } else
         lua_error(L);
    }
  }
  // ...
  this->QTextEdit::keyPressEvent(arg1);
}
  • Loading branch information...
1 parent 58efaa7 commit e706c52a255db68332edfdabebf8b0a61976963f @henux committed Sep 10, 2011
Showing with 5 additions and 2 deletions.
  1. +5 −2 generator/virtuals.lua
View
@@ -105,9 +105,12 @@ function virtual_overload(v)
} else
lua_error(L);
}
+ } else {
+ lua_settop(L, oldtop);
+ ]]..fallback..[[
}
- lua_settop(L, oldtop);
- ]] .. fallback .. '\n}\n'
+}
+]]
v.virtual_overload = ret
v.virtual_proto = string.gsub(proto, ';;', '', 1)
return v

0 comments on commit e706c52

Please sign in to comment.