From 93095014fd87f1a33bdeaeb1f05eaab9342320bc Mon Sep 17 00:00:00 2001 From: "Daniel T. Borelli" Date: Wed, 6 May 2015 20:37:25 -0300 Subject: [PATCH] Fix segment violation MINIZIP_ENABLED --- core/io/file_access_pack.cpp | 4 +++- main/main.cpp | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index bf1211f2b31..339a6d0528a 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -92,7 +92,9 @@ void PackedData::add_path(const String& pkg_path, const String& path, uint64_t o void PackedData::add_pack_source(PackSource *p_source) { - sources.push_back(p_source); + if (p_source != NULL) { + sources.push_back(p_source); + } }; PackedData *PackedData::singleton=NULL; diff --git a/main/main.cpp b/main/main.cpp index aa4a4b89190..1469ce4618e 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -251,7 +251,14 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas packed_data = memnew(PackedData); #ifdef MINIZIP_ENABLED + + //XXX: always get_singleton() == 0x0 zip_packed_data = ZipArchive::get_singleton(); + //TODO: remove this temporary fix + if (!zip_packed_data) { + zip_packed_data = memnew(ZipArchive); + } + packed_data->add_pack_source(zip_packed_data); #endif @@ -748,10 +755,12 @@ Error Main::setup(const char *execpath,int argc, char *argv[],bool p_second_phas if (file_access_network_client) memdelete(file_access_network_client); -#ifdef MINIZIP_ENABLED - if (zip_packed_data) - memdelete( zip_packed_data ); -#endif +// Note 1: *zip_packed_data live into *packed_data +// Note 2: PackedData::~PackedData destroy this. +//#ifdef MINIZIP_ENABLED +// if (zip_packed_data) +// memdelete( zip_packed_data ); +//#endif unregister_core_types();