提交 ff9987b0 编写于 作者: L liqiang

fix ui log print error bug

Signed-off-by: Nliqiang <liqiang121@huawei.com>
Change-Id: Iae24bb0e27dd8907fbb0b0085a0b3af6c0c5d376
上级 ca5fbe31
......@@ -65,8 +65,9 @@ UIView::UIView()
UIView::~UIView()
{
if (parent_ != nullptr) {
GRAPHIC_LOGE("UIView::~UIView failed, parent is not nullptr! Need to remove from parent component first");
if (IsOnViewTree()) {
GRAPHIC_LOGW("View still on tree, might cause wild ptr! ViewType : %{public}d, View addr : %{public}p.\r\n",
static_cast<uint8_t>(view->GetViewType()), this);
}
if (transMap_ != nullptr) {
delete transMap_;
......@@ -1027,4 +1028,16 @@ bool UIView::GetBitmap(ImageInfo& bitmap)
rect_.SetPosition(tempX, tempY);
return true;
}
bool UIView::IsOnViewTree()
{
UIView* par = this;
while (par->GetParent() != nullptr) {
par = par->GetParent();
}
if (par->GetViewType() != UI_ROOT_VIEW) {
return false;
}
return true;
}
} // namespace OHOS
......@@ -75,8 +75,8 @@ void RotateInputDevice::DispatchEvent(const DeviceData& data)
}
view->OnRotateEvent(data.rotate);
rotateStart_ = true;
GRAPHIC_LOGI("RotateInputDevice dispatched rotate event, targetView Type = %d, rotate value = %d\n!",
static_cast<uint8_t>(view->GetViewType()), data.rotate);
GRAPHIC_LOGI("RotateInputDevice dispatched rotate event, targetView Type = %{public}d,\
rotate value = %{public}d\n!", static_cast<uint8_t>(view->GetViewType()), data.rotate);
}
} // namespace OHOS
#endif
......@@ -1708,6 +1708,8 @@ public:
*/
bool GetBitmap(ImageInfo& bitmap);
bool IsOnViewTree();
protected:
bool touchable_ : 1;
bool visible_ : 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册