Skip to content
Snippets Groups Projects
Commit cd4510c7 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Fix for GLTexture memory leak

parent 3dd88305
No related branches found
No related tags found
1 merge request!316Resolves #343 GUI and Frame Refactor
Pipeline #28282 failed
......@@ -182,9 +182,10 @@ int main(int argc, char **argv) {
#endif
return -1;
}
}
// Must be after ~FTLGui since it destroys GL context.
nanogui::shutdown();
}
// Save config changes and delete final objects
ftl::config::cleanup();
......
......@@ -466,6 +466,9 @@ void ftl::gui2::ImageView::writePixelInfo(NVGcontext* ctx, const Vector2f& cellP
////////////////////////////////////////////////////////////////////////////////
FTLImageView::~FTLImageView() {
}
void FTLImageView::draw(NVGcontext* ctx) {
if (texture_.isValid()) { ImageView::draw(ctx); }
}
......
......@@ -35,7 +35,7 @@ namespace gui2 {
class NANOGUI_EXPORT ImageView : public nanogui::Widget {
public:
ImageView(nanogui::Widget* parent, GLuint imageID = -1);
~ImageView();
virtual ~ImageView();
void bindImage(GLuint imageId);
......@@ -187,6 +187,10 @@ public:
class FTLImageView : public ImageView {
public:
using ImageView::ImageView;
FTLImageView(nanogui::Widget* parent, GLuint imageID = -1) : ImageView(parent, imageID) {}
~FTLImageView();
virtual void draw(NVGcontext* ctx) override;
virtual nanogui::Vector2i preferredSize(NVGcontext* ctx) const override;
......
......@@ -27,7 +27,7 @@ GLTexture::GLTexture() {
}
GLTexture::~GLTexture() {
//glDeleteTextures(1, &glid_);
free(); // Note: Do not simply remove this...
}
void GLTexture::make(int width, int height, Type type) {
......
......@@ -172,7 +172,7 @@ class Frame {
protected:
// Only Feed class should construct
Frame(Pool *ppool, Session *parent, FrameID pid, int64_t ts) : timestamp_(ts), id_(pid), pool_(ppool), parent_(parent), status_(FrameStatus::CREATED) {};
Frame(Pool *ppool, Session *parent, FrameID pid, int64_t ts);
int64_t timestamp_=0;
FrameID id_;
......
......@@ -67,10 +67,20 @@ void ftl::data::setTypeEncoder(size_t type, const std::function<bool(const ftl::
//==============================================================================
//static std::atomic_int frame_count = 0;
Frame::Frame(Pool *ppool, Session *parent, FrameID pid, int64_t ts)
: timestamp_(ts), id_(pid), pool_(ppool), parent_(parent), status_(FrameStatus::CREATED) {
//LOG(INFO) << "Frames: " << ++frame_count;
};
Frame::~Frame() {
if (status_ == FrameStatus::CREATED) store();
if (status_ == FrameStatus::STORED) flush();
if (status_ != FrameStatus::RELEASED && pool_) pool_->release(*this);
if (status_ != FrameStatus::RELEASED && pool_) {
pool_->release(*this);
//--frame_count;
}
};
bool ftl::data::Frame::hasAll(const std::unordered_set<ftl::codecs::Channel> &cs) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment