diff --git a/frameworks/common/text.cpp b/frameworks/common/text.cpp index 546abc380246743b59028bae5f80347e06ab69bf..c9899ce825559a99e9c047faaf70d9b2846e7ce2 100644 --- a/frameworks/common/text.cpp +++ b/frameworks/common/text.cpp @@ -430,7 +430,7 @@ uint32_t Text::CalculateLineWithEllipsis(uint32_t begin, uint32_t textLen, int16 uint32_t Text::GetTextStrLen() { - return strlen(text_); + return (text_ != nullptr) ? (strlen(text_)) : 0; } uint32_t Text::GetTextLine(uint32_t begin, uint32_t textLen, int16_t width, uint16_t lineNum, uint8_t letterSpace, diff --git a/frameworks/imgdecode/cache_manager.cpp b/frameworks/imgdecode/cache_manager.cpp index a9fb4037fea0391c76b67afbf7db90406b0253b1..043e1b883606d52781a7ab8b6c483eed1cd8ae64 100644 --- a/frameworks/imgdecode/cache_manager.cpp +++ b/frameworks/imgdecode/cache_manager.cpp @@ -132,7 +132,7 @@ RetCode CacheManager::Open(const char* path, const Style& style, CacheEntry& ent } SelectEntryToReplace(indexHitted); - if (entryArr_[indexHitted].dsc_.path != nullptr) { + if ((entryArr_[indexHitted].dsc_.path != nullptr) && (entryArr_[indexHitted].dsc_.decoder != nullptr)) { entryArr_[indexHitted].dsc_.decoder->Close(entryArr_[indexHitted].dsc_); } @@ -161,13 +161,11 @@ RetCode CacheManager::Close(const char* path) continue; } if (strcmp(entryArr_[index].dsc_.path, path) == 0) { - entryArr_[index].dsc_.decoder->Close(entryArr_[index].dsc_); Clear(entryArr_[index]); break; } } else { if (entryArr_[index].dsc_.path == path) { - entryArr_[index].dsc_.decoder->Close(entryArr_[index].dsc_); Clear(entryArr_[index]); break; } @@ -199,7 +197,6 @@ RetCode CacheManager::Reset() for (uint16_t index = 0; index < GetSize(); index++) { if (entryArr_[index].dsc_.path != nullptr) { - entryArr_[index].dsc_.decoder->Close(entryArr_[index].dsc_); Clear(entryArr_[index]); } } @@ -209,6 +206,9 @@ RetCode CacheManager::Reset() RetCode CacheManager::ReadToCache(CacheEntry& entry) { + if (entry.dsc_.decoder == nullptr) { + return RetCode::FAIL; + } return entry.dsc_.decoder->ReadToCache(entry.dsc_); } diff --git a/interfaces/kits/components/ui_canvas.h b/interfaces/kits/components/ui_canvas.h index 44cfe304a3481e1d79ea7264ecb92f9a795448ec..819e15a7e89008a268c4514ea990e72028480059 100644 --- a/interfaces/kits/components/ui_canvas.h +++ b/interfaces/kits/components/ui_canvas.h @@ -482,8 +482,14 @@ protected: uint8_t fontOpa; FontStyle fontStyle; Text* textComment; - TextParam() + TextParam() : text(nullptr), position({0, 0}), fontOpa(0) { + fontColor.full = 0; + fontStyle.direct = UITextLanguageDirect::TEXT_DIRECT_LTR; + fontStyle.align = UITextLanguageAlignment::TEXT_ALIGNMENT_LEFT; + fontStyle.fontSize = 0; + fontStyle.letterSpace = 0; + fontStyle.fontName = nullptr; textComment = new Text; } diff --git a/tools/qt/simulator/uitest/main_widget.cpp b/tools/qt/simulator/uitest/main_widget.cpp index 4b9db5c6a669ad194fec276fc9ab1715a69a970e..c2f6b71bd841202004dca6533faf9d0d7f88dfb5 100644 --- a/tools/qt/simulator/uitest/main_widget.cpp +++ b/tools/qt/simulator/uitest/main_widget.cpp @@ -19,15 +19,19 @@ namespace OHOS { MainWidget::MainWidget(QWidget* parent) : QWidget(parent), guiThread_(nullptr), taskThread_(nullptr) { - ui_->setupUi(this); - CreateGUIThread(); - CreateTaskThread(); - CreateSocketThread(); + if (ui_ != nullptr) { + ui_->setupUi(this); + CreateGUIThread(); + CreateTaskThread(); + CreateSocketThread(); + } } MainWidget::~MainWidget() { - delete ui_; + if (ui_ != nullptr) { + delete ui_; + } if (guiThread_ != nullptr) { guiThread_->Quit(); guiThread_->wait();