mirror of
https://gitee.com/houstudio/Cdroid.git
synced 2024-12-05 21:58:44 +08:00
fix ImageView's crrash
This commit is contained in:
parent
c023361b1f
commit
ab3c8aa067
@ -81,19 +81,18 @@ void ImageView::resolveUri(){
|
||||
if (mDrawable != nullptr) {
|
||||
return;
|
||||
}
|
||||
Drawable* d = nullptr;
|
||||
if (!mResource.empty()) {
|
||||
d = getContext()->getDrawable(mResource);
|
||||
int loaded = d!=nullptr;
|
||||
const int bNotNull = mResource.compare("@null");
|
||||
if((d==nullptr)&&bNotNull){
|
||||
if(strpbrk(mResource.c_str(),"@:")==nullptr){
|
||||
RefPtr<Cairo::ImageSurface>bitmap = getContext()->getImage(mResource);
|
||||
if(bitmap){
|
||||
setImageBitmap(bitmap);
|
||||
loaded ++;
|
||||
}
|
||||
}else updateDrawable(d);
|
||||
LOGW_IF((loaded==0)&&bNotNull,"Unable to find resource: %s",mResource.c_str());
|
||||
setImageBitmap(bitmap);
|
||||
LOGW_IF(bitmap==nullptr,"Unable to find resource: %s",mResource.c_str());
|
||||
}else if(mResource.compare("@null")){
|
||||
Drawable* d = getContext()->getDrawable(mResource);
|
||||
LOGW_IF(d==nullptr,"Unable to find resource: %s",mResource.c_str());
|
||||
updateDrawable(d);
|
||||
}else{
|
||||
updateDrawable(nullptr);
|
||||
}
|
||||
}
|
||||
//updateDrawable(d);
|
||||
}
|
||||
@ -625,8 +624,6 @@ void ImageView::updateDrawable(Drawable*d){
|
||||
if ( !sameDrawable && isAttachedToWindow()) {
|
||||
mDrawable->setVisible(false, false);
|
||||
}
|
||||
if(!sameDrawable)
|
||||
delete mDrawable;
|
||||
}
|
||||
|
||||
mDrawable = d;
|
||||
|
Loading…
Reference in New Issue
Block a user