diff --git a/frameworks/components/ui_button.cpp b/frameworks/components/ui_button.cpp index 27c27b0c776a2f0b6c61bb9279176a2a8f42ab8b..d96b5c4f5782ff636c0cf88426abfff3d13da3d3 100755 --- a/frameworks/components/ui_button.cpp +++ b/frameworks/components/ui_button.cpp @@ -249,6 +249,7 @@ void UIButton::Enable() void UIButton::SetState(ButtonState state) { state_ = state; + style_ = buttonStyles_[state_]; Invalidate(); } diff --git a/frameworks/components/ui_time_picker.cpp b/frameworks/components/ui_time_picker.cpp index f8306ce5fc4b1a3558fd148bd64ff608a01f3a14..9420a7c63caaa8115093b6c1d09594f3e335274b 100755 --- a/frameworks/components/ui_time_picker.cpp +++ b/frameworks/components/ui_time_picker.cpp @@ -53,6 +53,9 @@ UITimePicker::UITimePicker() } else { style_ = &(StyleDefault::GetPickerHighlightStyle()); } +#if ENABLE_FOCUS_MANAGER + focusable_ = true; +#endif highlightFontId_ = style_->font_; highlightColor_ = style_->textColor_; diff --git a/frameworks/font/ui_font.cpp b/frameworks/font/ui_font.cpp index bde3a51241f87eca1e1b445057064341fb35ed76..d87dec4512d2d3843d68c262568356eaef849be8 100755 --- a/frameworks/font/ui_font.cpp +++ b/frameworks/font/ui_font.cpp @@ -27,6 +27,7 @@ #endif namespace OHOS { +bool UIFont::setFontAllocFlag_ = false; UIFont::UIFont() : instance_(nullptr), defaultInstance_(nullptr){}; UIFont::~UIFont(){}; @@ -38,11 +39,13 @@ UIFont* UIFont::GetInstance() if (instance.instance_ == nullptr) { instance.defaultInstance_ = new UIFontVector(); instance.instance_ = instance.defaultInstance_; + setFontAllocFlag_ = true; } #else if (instance.instance_ == nullptr) { instance.defaultInstance_ = new UIFontBitmap(); instance.instance_ = instance.defaultInstance_; + setFontAllocFlag_ = true; } #endif return &instance; @@ -51,9 +54,10 @@ UIFont* UIFont::GetInstance() void UIFont::SetFont(BaseFont* font) { if (font != nullptr) { - if (defaultInstance_ != nullptr) { + if (defaultInstance_ != nullptr && setFontAllocFlag_) { delete defaultInstance_; defaultInstance_ = nullptr; + setFontAllocFlag_ = false; } defaultInstance_ = font; instance_ = font; diff --git a/frameworks/themes/theme_manager.cpp b/frameworks/themes/theme_manager.cpp index 19a35293d0858330dcd595200d41c1e43402ff8d..b8fe84211a252fdcd9b6b8ebaace4b3aee906a3f 100755 --- a/frameworks/themes/theme_manager.cpp +++ b/frameworks/themes/theme_manager.cpp @@ -24,9 +24,6 @@ ThemeManager& ThemeManager::GetInstance() void ThemeManager::SetCurrent(Theme* theme) { - if (theme_ != nullptr) { - delete theme_; - } theme_ = theme; } } // namespace OHOS \ No newline at end of file diff --git a/interfaces/kits/font/ui_font.h b/interfaces/kits/font/ui_font.h index e1ef36c7114c7353f26159ff435ef33a800453d4..26af872b55ae198388c4ec4e2c121f825636e9af 100755 --- a/interfaces/kits/font/ui_font.h +++ b/interfaces/kits/font/ui_font.h @@ -233,6 +233,7 @@ private: BaseFont* instance_; BaseFont* defaultInstance_; + static bool setFontAllocFlag_; }; } // namespace OHOS #endif diff --git a/interfaces/kits/themes/theme_manager.h b/interfaces/kits/themes/theme_manager.h index 3dca85f543c7956d7896b444434b841c9dbef066..162eb510e92760f724bb51aa26d15e7bf99c444e 100755 --- a/interfaces/kits/themes/theme_manager.h +++ b/interfaces/kits/themes/theme_manager.h @@ -78,7 +78,10 @@ public: private: ThemeManager() : theme_(nullptr) {} - ~ThemeManager() {} + virtual ~ThemeManager() + { + theme_ = nullptr; + } Theme* theme_; }; diff --git a/test/unittest/common/focus_manager_unit_test.cpp b/test/unittest/common/focus_manager_unit_test.cpp index 919983874147d7dfc278102c708f82d0a68a83f8..cdf19efef88cf7959728d00893e53dda12cee57c 100755 --- a/test/unittest/common/focus_manager_unit_test.cpp +++ b/test/unittest/common/focus_manager_unit_test.cpp @@ -57,6 +57,7 @@ void FocusManagerTest::SetUpTestCase(void) void FocusManagerTest::TearDownTestCase(void) { + FocusManager::GetInstance()->ClearFocus(); if (viewGroup_ != nullptr) { viewGroup_->Remove(label1_); viewGroup_->Remove(label2_); @@ -71,7 +72,6 @@ void FocusManagerTest::TearDownTestCase(void) delete label2_; label2_ = nullptr; } - FocusManager::GetInstance()->ClearFocus(); } /** diff --git a/test/unittest/font/ui_font_unit_test.cpp b/test/unittest/font/ui_font_unit_test.cpp index 3af76e728a3380ecb459cf676636a994a0e0425c..2ffe23c6ddfcc6e20d2df1175c45b44ac2aeb497 100755 --- a/test/unittest/font/ui_font_unit_test.cpp +++ b/test/unittest/font/ui_font_unit_test.cpp @@ -80,7 +80,6 @@ HWTEST_F(UIFontTest, Graphic_Font_Test_GetInstance_001, TestSize.Level0) */ HWTEST_F(UIFontTest, Graphic_Font_Test_IsVectorFont_001, TestSize.Level1) { - UIFont::GetInstance()->SetFont(font_); #if ENABLE_VECTOR_FONT bool ret = UIFont::GetInstance()->IsVectorFont(); EXPECT_EQ(ret, true);