modify looper

This commit is contained in:
侯歌 2023-02-28 03:51:04 +00:00
parent 1d215d213d
commit 3d1621d4fc
4 changed files with 11 additions and 5 deletions

View File

@ -42,7 +42,10 @@ App::App(int argc,const char*argv[],const struct option*extoptions){
mQuitFlag = false;
mExitCode = 0;
mInst = this;
if(argc>0){
const char*p = strrchr(argv[0],'/');
if(p)setName(p+1);
}
LOGD("App %s started",(argc&&argv)?argv[0]:"");
cla.addArguments(ARGS,sizeof(ARGS)/sizeof(CLA::Argument));
cla.setSwitchChars("-");

View File

@ -72,9 +72,12 @@ Looper::~Looper() {
delete hdl;
}mEventHandlers.clear();
}
Looper*Looper::mInst=nullptr;
Looper*Looper::getDefault(){
if(mInst==nullptr)mInst=new Looper(false);
static thread_local Looper*mInst=nullptr;
if(mInst==nullptr){
mInst=new Looper(false);
//LOGI("*Looper::getDefault=%p",mInst);
}
return mInst;
}

View File

@ -124,7 +124,6 @@ private:
std::vector<Response> mResponses;
size_t mResponseIndex;
nsecs_t mNextMessageUptime;
static Looper*mInst;
private:
int pollEvents(int timeoutMillis);
int pollInner(int timeoutMillis);

View File

@ -73,7 +73,8 @@ View* LayoutInflater::inflate(const std::string&resource,ViewGroup*root,bool att
if(mContext){
std::string package;
std::unique_ptr<std::istream>stream=mContext->getInputStream(resource,&package);
if(stream && stream->good()) v=inflate(package,*stream,root,attachToRoot && (root!=nullptr));
if(stream && stream->good()) v = inflate(package,*stream,root,attachToRoot && (root!=nullptr));
LOGE_IF(stream==nullptr||stream->good()==false,"faild to load resource %s",resource.c_str());
}else{
std::ifstream fin(resource);
v=inflate(resource,fin,root,root!=nullptr);