add null drawable support

This commit is contained in:
houzh 2023-09-06 09:43:14 +08:00
parent 250fded617
commit 888092eb5b
3 changed files with 11 additions and 2 deletions

View File

@ -350,7 +350,7 @@ Drawable* Assets::getDrawable(const std::string&fullresid) {
Drawable* d = nullptr;
std::string resname,package;
ZIPArchive* pak = getResource(fullresid,&resname,&package);
if(fullresid.empty()) {
if(fullresid.empty()||(fullresid.compare("null")==0)) {
return d;
} else {
auto it = mDrawables.find(fullresid);

View File

@ -8,6 +8,7 @@
#include <string.h>
#include <textutils.h>
#include <core/attributeset.h>
#include <core/iostreams.h>
namespace cdroid{
@ -58,9 +59,16 @@ void Preferences::load(const std::string&fname){
if(fin.good()){
mFileName=fname;
load(fin);
}else{
load(fname.c_str(),fname.length());
}
}
void Preferences::load(const char*buf,size_t len){
MemoryInputStream stream(buf,len);
load(stream);
}
void Preferences::load(std::istream&istream){
XML_Parser parser=XML_ParserCreate(nullptr);
std::string curKey;
@ -73,7 +81,7 @@ void Preferences::load(std::istream&istream){
XML_SetCharacterDataHandler(parser,CharacterHandler);
do {
std::string str;
std::getline(istream,str);//fin.read(buf,sizeof(buf));
std::getline(istream,str);
len=str.length();
if (XML_Parse(parser, str.c_str(),len,len==0) == XML_STATUS_ERROR) {
const char*es=XML_ErrorString(XML_GetErrorCode(parser));

View File

@ -18,6 +18,7 @@ public:
void save(const std::string&fname);
void load(std::istream&istream);
void save(std::ostream&ostream);
void load(const char*,size_t);
int getSectionCount()const;
int getSections(std::vector<std::string>&mbs);
int getUpdates()const;