[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master a67848a 1/3: Use 'new(wx)' to allocate memory
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master a67848a 1/3: Use 'new(wx)' to allocate memory that will be freed by wx |
Date: |
Sat, 6 Feb 2021 14:47:06 -0500 (EST) |
branch: master
commit a67848aded268036c620da89601ef47ed8e8e9b1
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Use 'new(wx)' to allocate memory that will be freed by wx
s/new/new(wx)/ in appropriate cases that had been overlooked.
---
census_view.cpp | 2 +-
docmanager_ex.cpp | 4 ++--
pdf_command_wx.cpp | 7 ++++---
pdf_writer_wx.cpp | 3 ++-
skeleton.cpp | 7 +++++--
transferor.cpp | 3 ++-
6 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/census_view.cpp b/census_view.cpp
index 994d5ed..93179fa 100644
--- a/census_view.cpp
+++ b/census_view.cpp
@@ -574,7 +574,7 @@ class CensusViewGridCellAttrProvider
{
public:
explicit CensusViewGridCellAttrProvider(wxGrid const* grid)
- :attrForOddRows_{new wxGridCellAttr()}
+ :attrForOddRows_{new(wx) wxGridCellAttr()}
{
// Determine the alternate rows colour automatically from the
// background colour.
diff --git a/docmanager_ex.cpp b/docmanager_ex.cpp
index 84c07dc..f611dfa 100644
--- a/docmanager_ex.cpp
+++ b/docmanager_ex.cpp
@@ -151,7 +151,7 @@ void DocManagerEx::UponPreview(wxCommandEvent&)
);
return;
}
- PreviewFrameEx* frame = new PreviewFrameEx(preview);
+ PreviewFrameEx* frame = new(wx) PreviewFrameEx(preview);
frame->Center(wxBOTH);
frame->Initialize();
frame->Show(true);
@@ -210,7 +210,7 @@ wxDocTemplate* DocManagerEx::SelectDocumentType
)
{
wxArrayString strings;
- wxDocTemplate** data = new wxDocTemplate*[noTemplates];
+ wxDocTemplate** data = new(wx) wxDocTemplate*[noTemplates];
int i;
int n = 0;
diff --git a/pdf_command_wx.cpp b/pdf_command_wx.cpp
index 4af19ef..58d2ec3 100644
--- a/pdf_command_wx.cpp
+++ b/pdf_command_wx.cpp
@@ -42,6 +42,7 @@
#include "report_table.hpp" // paginator
#include "safely_dereference_as.hpp"
#include "ssize_lmi.hpp"
+#include "wx_new.hpp"
#include "wx_table_generator.hpp"
#include <wx/pdfdc.h>
@@ -723,7 +724,7 @@ TAG_HANDLER_BEGIN(scaled_image, "IMG")
if(image.IsOk())
{
m_WParser->GetContainer()->InsertCell
- (new scaled_image_cell(image, src, scale_factor)
+ (new(wx) scaled_image_cell(image, src, scale_factor)
);
}
@@ -1716,7 +1717,7 @@ TAG_HANDLER_BEGIN(numeric_summary_table,
"NUMERIC_SUMMARY_TABLE")
// the compiler from admonishing us.
(void)&(tag);
- m_WParser->GetContainer()->InsertCell(new
numeric_summary_table_cell());
+ m_WParser->GetContainer()->InsertCell(new(wx)
numeric_summary_table_cell());
// This tag isn't supposed to have any inner contents, so return true
// to not even try parsing it.
@@ -1831,7 +1832,7 @@ class page_with_tabular_report
void pre_render() override
{
- table_gen_.reset(new wx_table_generator {create_table_generator()});
+ table_gen_.reset(new(wx) wx_table_generator
{create_table_generator()});
numbered_page::pre_render();
}
diff --git a/pdf_writer_wx.cpp b/pdf_writer_wx.cpp
index cfd3f7d..01def2c 100644
--- a/pdf_writer_wx.cpp
+++ b/pdf_writer_wx.cpp
@@ -28,6 +28,7 @@
#include "contains.hpp"
#include "global_settings.hpp"
#include "html.hpp"
+#include "wx_new.hpp"
#include <wx/filesys.h>
#include <wx/html/htmlcell.h>
@@ -126,7 +127,7 @@ pdf_writer_wx::pdf_writer_wx
// Create the virtual file system object for loading images referenced from
// HTML and interpret relative paths from the data directory.
- html_vfs_.reset(new wxFileSystem());
+ html_vfs_.reset(new(wx) wxFileSystem());
html_vfs_->ChangePathTo
(global_settings::instance().data_directory().string()
,true // argument is a directory, not file path
diff --git a/skeleton.cpp b/skeleton.cpp
index 18e4494..22e96d3 100644
--- a/skeleton.cpp
+++ b/skeleton.cpp
@@ -222,7 +222,7 @@ wxMDIChildFrame* Skeleton::CreateChildFrame
frame_->GetActiveChild()
&& frame_->GetActiveChild()->IsMaximized()
;
- wxDocMDIChildFrame* child_frame = new wxDocMDIChildFrame
+ wxDocMDIChildFrame* child_frame = new(wx) wxDocMDIChildFrame
(doc
,view
,frame_
@@ -683,7 +683,7 @@ bool Skeleton::OnInit()
}
};
- wxLog::SetActiveTarget(new DebugStderrLog);
+ wxLog::SetActiveTarget(new(wx) DebugStderrLog);
#endif // defined __WXMSW__
if(false == ProcessCommandLine())
@@ -1081,6 +1081,9 @@ void
Skeleton::UponTestFloatingPointEnvironment(wxCommandEvent&)
void Skeleton::UponTestPasting(wxCommandEvent&)
{
+ // This uses 'new' rather than 'new(wx)' because the object is
+ // explicitly deleted by calling Destroy(); yet the Destroy()
+ // call isn't reached if an exception is thrown.
InputSequenceEntry* z = new InputSequenceEntry(frame_, wxID_ANY,
"Testing...");
LMI_ASSERT(z);
wxTextCtrl& t = z->text_ctrl();
diff --git a/transferor.cpp b/transferor.cpp
index 5d530fd..0324612 100644
--- a/transferor.cpp
+++ b/transferor.cpp
@@ -35,6 +35,7 @@
#include "calendar_date.hpp"
#include "input_sequence_entry.hpp"
#include "numeric_io_cast.hpp"
+#include "wx_new.hpp"
#include "wx_utility.hpp"
#include <wx/button.h>
@@ -93,7 +94,7 @@ Transferor::Transferor(std::string& data, std::string const&
name)
wxObject* Transferor::Clone() const
{
- return new Transferor(data_, name_);
+ return new(wx) Transferor(data_, name_);
}
std::string const& Transferor::name() const