Stop using wxList in wxZipOutputStream
Use a vector of std::unique_ptr<> instead for simplicity and safety. As wxZipEntryList_ was never exposed in the public API, it should be safe to just remove it, as this commit does.
This commit is contained in:
parent
7c14da0576
commit
ddd4d54b2b
2 changed files with 8 additions and 13 deletions
|
|
@ -16,6 +16,9 @@
|
|||
#include "wx/archive.h"
|
||||
#include "wx/filename.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
// some methods from wxZipInputStream and wxZipOutputStream stream do not get
|
||||
// exported/imported when compiled with Mingw versions before 3.4.2. So they
|
||||
// are imported/exported individually as a workaround
|
||||
|
|
@ -287,8 +290,6 @@ private:
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// wxZipOutputStream
|
||||
|
||||
WX_DECLARE_LIST_WITH_DECL(wxZipEntry, wxZipEntryList_, class WXDLLIMPEXP_BASE);
|
||||
|
||||
class WXDLLIMPEXP_BASE wxZipOutputStream : public wxArchiveOutputStream
|
||||
{
|
||||
public:
|
||||
|
|
@ -354,7 +355,7 @@ private:
|
|||
class wxStoredOutputStream *m_store;
|
||||
class wxZlibOutputStream2 *m_deflate;
|
||||
class wxZipStreamLink *m_backlink;
|
||||
wxZipEntryList_ m_entries;
|
||||
std::vector<std::unique_ptr<wxZipEntry>> m_entries;
|
||||
char *m_initialData;
|
||||
size_t m_initialSize;
|
||||
wxZipEntry *m_pending;
|
||||
|
|
|
|||
|
|
@ -2151,9 +2151,6 @@ size_t wxZipInputStream::OnSysRead(void *buffer, size_t size)
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Output stream
|
||||
|
||||
#include "wx/listimpl.cpp"
|
||||
WX_DEFINE_LIST(wxZipEntryList_)
|
||||
|
||||
wxZipOutputStream::wxZipOutputStream(wxOutputStream& stream,
|
||||
int level /*=-1*/,
|
||||
wxMBConv& conv /*=wxConvUTF8*/)
|
||||
|
|
@ -2192,7 +2189,6 @@ void wxZipOutputStream::Init(int level)
|
|||
wxZipOutputStream::~wxZipOutputStream()
|
||||
{
|
||||
Close();
|
||||
WX_CLEAR_LIST(wxZipEntryList_, m_entries);
|
||||
delete m_store;
|
||||
delete m_deflate;
|
||||
delete m_pending;
|
||||
|
|
@ -2419,7 +2415,7 @@ void wxZipOutputStream::CreatePendingEntry(const void *buffer, size_t size)
|
|||
m_lasterror = m_parent_o_stream->GetLastError();
|
||||
|
||||
if (IsOk()) {
|
||||
m_entries.push_back(spPending.release());
|
||||
m_entries.push_back(std::move(spPending));
|
||||
OnSysWrite(m_initialData, m_initialSize);
|
||||
}
|
||||
|
||||
|
|
@ -2471,7 +2467,7 @@ void wxZipOutputStream::CreatePendingEntry()
|
|||
m_headerSize = spPending->WriteLocal(*m_parent_o_stream, GetConv(), m_format);
|
||||
|
||||
if (m_parent_o_stream->IsOk()) {
|
||||
m_entries.push_back(spPending.release());
|
||||
m_entries.push_back(std::move(spPending));
|
||||
m_comp = m_store;
|
||||
m_store->Write(m_initialData, m_initialSize);
|
||||
}
|
||||
|
|
@ -2500,12 +2496,10 @@ bool wxZipOutputStream::Close()
|
|||
endrec.SetOffset(m_headerOffset);
|
||||
endrec.SetComment(m_Comment);
|
||||
|
||||
wxZipEntryList_::iterator it;
|
||||
wxFileOffset size = 0;
|
||||
|
||||
for (it = m_entries.begin(); it != m_entries.end(); ++it) {
|
||||
size += (*it)->WriteCentral(*m_parent_o_stream, GetConv());
|
||||
delete *it;
|
||||
for (const auto& it : m_entries) {
|
||||
size += it->WriteCentral(*m_parent_o_stream, GetConv());
|
||||
}
|
||||
m_entries.clear();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue