diff --git a/libsearch/searchinterface/search-controller-private.h b/libsearch/searchinterface/search-controller-private.h index 7fae89c..7211461 100644 --- a/libsearch/searchinterface/search-controller-private.h +++ b/libsearch/searchinterface/search-controller-private.h @@ -38,7 +38,7 @@ public: private: void copyData(); //TODO: 这里是否可以改为字节对齐的写法? - DataQueue* m_dataQueue = nullptr ; +// DataQueue* m_dataQueue = nullptr ; std::shared_ptr> m_sharedDataueue = nullptr; size_t m_searchId = 0; QMutex m_searchIdMutex; diff --git a/libsearch/searchinterface/search-controller.cpp b/libsearch/searchinterface/search-controller.cpp index c6a0481..0ec48b0 100644 --- a/libsearch/searchinterface/search-controller.cpp +++ b/libsearch/searchinterface/search-controller.cpp @@ -24,23 +24,22 @@ size_t SearchControllerPrivate::refreshSearchId() DataQueue *SearchControllerPrivate::refreshDataqueue() { - if(!m_dataQueue) { - m_dataQueue = new DataQueue; - m_sharedDataueue = std::shared_ptr>(m_dataQueue); - return m_dataQueue; + if(!m_sharedDataueue.get()) { +// m_dataQueue = new DataQueue; + m_sharedDataueue = std::make_shared>(); + return m_sharedDataueue.get(); } - m_dataQueue->clear(); - return m_dataQueue;; + m_sharedDataueue.get()->clear(); + return m_sharedDataueue.get(); } DataQueue *SearchControllerPrivate::initDataQueue() { - if(!m_dataQueue) { - m_dataQueue = new DataQueue; - m_sharedDataueue = std::shared_ptr>(m_dataQueue); - return m_dataQueue; + if(!m_sharedDataueue.get()) { + m_sharedDataueue = std::make_shared>(); + return m_sharedDataueue.get(); } - return m_dataQueue; + return m_sharedDataueue.get(); } void SearchControllerPrivate::addSearchDir(QString &path)