1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-26 14:41:14 +01:00

Clone functions required by wxWidgets base classes can use safenew

This commit is contained in:
Paul Licameli
2016-03-31 01:13:29 -04:00
parent 456c8fb01e
commit 83e9e7de97
6 changed files with 22 additions and 14 deletions

View File

@@ -9,6 +9,7 @@
*******************************************************************/
#include "Screenshot.h"
#include "MemoryX.h"
#include "commands/ScreenshotCommand.h"
#include "commands/CommandTargets.h"
#include "commands/CommandDirectory.h"
@@ -140,20 +141,20 @@ class ScreenFrameTimer final : public wxTimer
wxEvent & event)
{
screenFrame = frame;
evt = event.Clone();
evt.reset(event.Clone());
}
void Notify() override
{
// Process timer notification just once, then destroy self
evt->SetEventObject(NULL);
screenFrame->ProcessEvent(*evt);
delete evt;
delete this;
}
private:
ScreenFrame *screenFrame;
wxEvent *evt;
std::unique_ptr<wxEvent> evt;
};
////////////////////////////////////////////////////////////////////////////////
@@ -463,7 +464,8 @@ bool ScreenFrame::ProcessEvent(wxEvent & e)
e.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED &&
id >= IdAllDelayedEvents && id <= IdLastDelayedEvent &&
e.GetEventObject() != NULL) {
ScreenFrameTimer *timer = new ScreenFrameTimer(this, e);
// safenew because it's a one-shot that deletes itself
ScreenFrameTimer *timer = safenew ScreenFrameTimer(this, e);
timer->Start(5000, true);
return true;
}