moved more objects to shared ptrs
This commit is contained in:
@@ -50,7 +50,7 @@ void RendererProcessor::Start()
|
||||
threads_.resize(QThread::idealThreadCount());
|
||||
|
||||
for (int i=0;i<threads_.size();i++) {
|
||||
threads_[i] = new RendererThread();
|
||||
threads_[i] = std::make_shared<RendererThread>();
|
||||
threads_[i]->run();
|
||||
}
|
||||
|
||||
@@ -67,13 +67,12 @@ void RendererProcessor::Stop()
|
||||
|
||||
for (int i=0;i<threads_.size();i++) {
|
||||
threads_[i]->Cancel();
|
||||
delete threads_[i];
|
||||
}
|
||||
|
||||
threads_.clear();
|
||||
}
|
||||
|
||||
RendererThread *RendererProcessor::CurrentThread()
|
||||
RendererThread* RendererProcessor::CurrentThread()
|
||||
{
|
||||
return dynamic_cast<RendererThread*>(QThread::currentThread());
|
||||
}
|
||||
|
||||
@@ -79,10 +79,10 @@ public:
|
||||
* This function attempts a dynamic_cast on QThread::currentThread() to RendererThread, which will return nullptr if
|
||||
* the cast fails (e.g. if this function is called from the main thread rather than a RendererThread).
|
||||
*/
|
||||
static RendererThread* CurrentThread();
|
||||
static RendererThread *CurrentThread();
|
||||
|
||||
private:
|
||||
QVector<RendererThread*> threads_;
|
||||
QVector<RendererThreadPtr> threads_;
|
||||
|
||||
bool started_;
|
||||
};
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#ifndef RENDERTHREAD_H
|
||||
#define RENDERTHREAD_H
|
||||
|
||||
#include <memory>
|
||||
#include <QMutex>
|
||||
#include <QOffscreenSurface>
|
||||
#include <QOpenGLContext>
|
||||
@@ -65,4 +66,6 @@ private:
|
||||
bool cancelled_;
|
||||
};
|
||||
|
||||
using RendererThreadPtr = std::shared_ptr<RendererThread>;
|
||||
|
||||
#endif // RENDERTHREAD_H
|
||||
|
||||
Reference in New Issue
Block a user