修复队列未释放的问题.

This commit is contained in:
iaom 2022-02-16 18:13:59 +08:00
parent a51795b8bf
commit 594371c274
2 changed files with 11 additions and 12 deletions

View File

@ -38,7 +38,7 @@ public:
private:
void copyData();
//TODO: 这里是否可以改为字节对齐的写法?
DataQueue<ResultItem>* m_dataQueue = nullptr ;
// DataQueue<ResultItem>* m_dataQueue = nullptr ;
std::shared_ptr<DataQueue<ResultItem>> m_sharedDataueue = nullptr;
size_t m_searchId = 0;
QMutex m_searchIdMutex;

View File

@ -24,23 +24,22 @@ size_t SearchControllerPrivate::refreshSearchId()
DataQueue<ResultItem> *SearchControllerPrivate::refreshDataqueue()
{
if(!m_dataQueue) {
m_dataQueue = new DataQueue<ResultItem>;
m_sharedDataueue = std::shared_ptr<DataQueue<ResultItem>>(m_dataQueue);
return m_dataQueue;
if(!m_sharedDataueue.get()) {
// m_dataQueue = new DataQueue<ResultItem>;
m_sharedDataueue = std::make_shared<DataQueue<ResultItem>>();
return m_sharedDataueue.get();
}
m_dataQueue->clear();
return m_dataQueue;;
m_sharedDataueue.get()->clear();
return m_sharedDataueue.get();
}
DataQueue<ResultItem> *SearchControllerPrivate::initDataQueue()
{
if(!m_dataQueue) {
m_dataQueue = new DataQueue<ResultItem>;
m_sharedDataueue = std::shared_ptr<DataQueue<ResultItem>>(m_dataQueue);
return m_dataQueue;
if(!m_sharedDataueue.get()) {
m_sharedDataueue = std::make_shared<DataQueue<ResultItem>>();
return m_sharedDataueue.get();
}
return m_dataQueue;
return m_sharedDataueue.get();
}
void SearchControllerPrivate::addSearchDir(QString &path)