Fix memory leak of wxClipboard data on exit
When wxClipboard is destroyed as part of the program shutdown, gdk_selection_owner_get() doesn't return our clipboard widget as owner any more, so we don't reset the owner when Clear() is called and hence never free the data. Do it explicitly if we don't have clipboard ownership in Clear() any longer to avoid memory leaks -- even though they are mostly harmless (as they happen only once, on exit), they still show up in LSAN and similar tools reports.
This commit is contained in:
parent
e1e2e982e3
commit
b52728a62a
1 changed files with 9 additions and 0 deletions
|
|
@ -587,6 +587,15 @@ void wxClipboard::Clear()
|
|||
// it will free our data
|
||||
SetSelectionOwner(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We need to free our data directly to avoid leaking memory.
|
||||
delete m_dataPrimary;
|
||||
m_dataPrimary = nullptr;
|
||||
|
||||
delete m_dataClipboard;
|
||||
m_dataClipboard = nullptr;
|
||||
}
|
||||
|
||||
m_targetRequested = nullptr;
|
||||
m_formatSupported = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue