void Close() override {
delete this; // error show heap is corrupted !!!!
}
I don't think there is any bug in U++. You are trying to delete an object within the same object. That call to TopWindow::Close() will return to its caller, which is the TopWindow itself, and it will be a freed memory address. So you get heap corruption. Never do that.
That is actually OK if it is the last thing you do to the object, regardless it being in the object's method. Both by C++ standard and U++ Close. Well, should probably be documented.. Similar approach is used here: https://www.ultimatepp.org/examples$UWord$en-us.html
In fact, "delete this" is sort of the only "delete" that is allowed in U++
Quote:
Not to mention the SMain instance (se) is allocated on stack. You don't need to delete it anyway.