2 Commits

Author SHA1 Message Date
nou 2e74d94641 Fix bug in XISFModify that corrupted files 2025-10-20 17:51:43 +02:00
nou 556bb22d26 Do not use bundled zlib by default 2025-08-12 18:37:58 +02:00
2 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
option(USE_BUNDLED_LIBS "Use bundled LZ4 PugiXML and Zlib. You can still exclude some" ON) option(USE_BUNDLED_LIBS "Use bundled LZ4 PugiXML and Zlib. You can still exclude some" ON)
cmake_dependent_option(USE_BUNDLED_LZ4 "Use bundled LZ4" ON "USE_BUNDLED_LIBS" OFF) cmake_dependent_option(USE_BUNDLED_LZ4 "Use bundled LZ4" ON "USE_BUNDLED_LIBS" OFF)
cmake_dependent_option(USE_BUNDLED_PUGIXML "Use bundled PugiXML" ON "USE_BUNDLED_LIBS" OFF) cmake_dependent_option(USE_BUNDLED_PUGIXML "Use bundled PugiXML" ON "USE_BUNDLED_LIBS" OFF)
cmake_dependent_option(USE_BUNDLED_ZLIB "Use bundled Zlib" ON "USE_BUNDLED_LIBS" OFF) cmake_dependent_option(USE_BUNDLED_ZLIB "Use bundled Zlib" OFF "USE_BUNDLED_LIBS" OFF)
find_package(PkgConfig) find_package(PkgConfig)
+3 -2
View File
@@ -1383,7 +1383,6 @@ private:
pugi::xml_document _doc; pugi::xml_document _doc;
pugi::xml_node _root; pugi::xml_node _root;
std::map<int, std::pair<uint64_t, uint64_t>> _attachmentPos;// pair contain position and size std::map<int, std::pair<uint64_t, uint64_t>> _attachmentPos;// pair contain position and size
std::map<int, std::pair<uint64_t, uint64_t>> _attachmentPosNew;
}; };
@@ -1446,6 +1445,8 @@ void XISFModifyPrivate::save(std::ostream &io)
doc.append_child(pugi::node_comment).set_value("\nExtensible Image Serialization Format - XISF version 1.0\nCreated with libXISF - https://nouspiro.space\n"); doc.append_child(pugi::node_comment).set_value("\nExtensible Image Serialization Format - XISF version 1.0\nCreated with libXISF - https://nouspiro.space\n");
pugi::xml_node root_copy = doc.append_copy(_root); pugi::xml_node root_copy = doc.append_copy(_root);
parseAttachmentPos(_root);
uint32_t size = 0; uint32_t size = 0;
std::string header; std::string header;
while(true) while(true)
@@ -1601,6 +1602,7 @@ void XISFModifyPrivate::readXISFHeader()
void XISFModifyPrivate::parseAttachmentPos(pugi::xml_node &root) void XISFModifyPrivate::parseAttachmentPos(pugi::xml_node &root)
{ {
_attachmentPos.clear();
pugi::xpath_node_set locationAttributes = root.select_nodes("//@location"); pugi::xpath_node_set locationAttributes = root.select_nodes("//@location");
int i = 0; int i = 0;
for(auto &attr : locationAttributes) for(auto &attr : locationAttributes)
@@ -1625,7 +1627,6 @@ void XISFModifyPrivate::updateAttachmentPos(pugi::xml_node &root, size_t offset)
pugi::xml_attribute attr = locationAttributes[pos.first].attribute(); pugi::xml_attribute attr = locationAttributes[pos.first].attribute();
uint64_t attachmentSize = pos.second.second; uint64_t attachmentSize = pos.second.second;
std::string locationStr = "attachment:" + std::to_string(offset) + ":" + std::to_string(attachmentSize); std::string locationStr = "attachment:" + std::to_string(offset) + ":" + std::to_string(attachmentSize);
_attachmentPosNew[pos.first] = pos.second;
offset += attachmentSize; offset += attachmentSize;
attr.set_value(locationStr.c_str()); attr.set_value(locationStr.c_str());
} }