Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » TopWindow&PopUp, TrayIcon » TopWindow when Close override show exception unduly
Re: TopWindow when Close override show exception unduly [message #56182 is a reply to message #56181] Thu, 04 February 2021 16:21 Go to previous messageGo to previous message
Oblivion is currently offline  Oblivion
Messages: 1226
Registered: August 2007
Senior Contributor
Hello BetoValle,

    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. Smile

Not to mention the SMain instance (se) is allocated on stack. You don't need to delete it anyway.

TopWindow::Close() method is useful for cleaning up your code, if required. It is not where you delete a window. In fact, unless it is absolutely necessary, we avoid using 'delete' in U++.

Best regards,
Oblivion


[Updated on: Thu, 04 February 2021 16:34]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to remove the button [X] that closes the window?
Next Topic: same layout with different dimensions
Goto Forum:
  


Current Time: Sat Aug 23 07:18:08 CEST 2025

Total time taken to generate the page: 0.04992 seconds