From aa94af4382aabbfd6cbd37dbf477f2fdce11758f Mon Sep 17 00:00:00 2001 From: YiFang Xiao Date: Wed, 21 Jun 2023 02:14:20 +0800 Subject: [PATCH] fix: fix double release pointer --- src/ui/editdictionaries.cc | 12 +++++------- src/ui/editdictionaries.hh | 4 ++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/ui/editdictionaries.cc b/src/ui/editdictionaries.cc index a98847ac..88f12193 100644 --- a/src/ui/editdictionaries.cc +++ b/src/ui/editdictionaries.cc @@ -21,7 +21,7 @@ EditDictionaries::EditDictionaries( QWidget * parent, origCfg( cfg ), sources( this, cfg ), orderAndProps( new OrderAndProps( this, cfg.dictionaryOrder, cfg.inactiveDictionaries, dictionaries ) ), - groups( std::make_shared< Groups >( this, dictionaries, cfg.groups, orderAndProps->getCurrentDictionaryOrder() ) ), + groups( new Groups( this, dictionaries, cfg.groups, orderAndProps->getCurrentDictionaryOrder() ) ), dictionariesChanged( false ), groupsChanged( false ), helpAction( this ) @@ -208,8 +208,8 @@ void EditDictionaries::acceptChangedSources( bool rebuildGroups ) // free them. ui.tabs->setUpdatesEnabled( false ); - groups.reset(); - orderAndProps.reset(); + groups.clear(); + orderAndProps.clear(); loadDictionaries( this, true, cfg, dictionaries, dictNetMgr ); @@ -238,10 +238,8 @@ void EditDictionaries::acceptChangedSources( bool rebuildGroups ) if ( rebuildGroups ) { ui.tabs->removeTab( 1 ); ui.tabs->removeTab( 1 ); - orderAndProps.reset( new OrderAndProps( this, savedOrder, savedInactive, dictionaries ) ); - std::shared_ptr< Groups > other = - std::make_shared< Groups >( this, dictionaries, savedGroups, orderAndProps->getCurrentDictionaryOrder() ); - groups.swap( other ); + orderAndProps = new OrderAndProps( this, savedOrder, savedInactive, dictionaries ); + groups = new Groups( this, dictionaries, savedGroups, orderAndProps->getCurrentDictionaryOrder() ); ui.tabs->insertTab( 1, orderAndProps.get(), QIcon( ":/icons/book.svg" ), tr( "&Dictionaries" ) ); diff --git a/src/ui/editdictionaries.hh b/src/ui/editdictionaries.hh index 9050bc62..f6b5754a 100644 --- a/src/ui/editdictionaries.hh +++ b/src/ui/editdictionaries.hh @@ -78,8 +78,8 @@ private: Ui::EditDictionaries ui; Sources sources; - QScopedPointer< OrderAndProps > orderAndProps; - sptr< Groups > groups; + QPointer< OrderAndProps > orderAndProps; + QPointer< Groups > groups; bool dictionariesChanged; bool groupsChanged;