Commit 9c91f0ed authored by Mathieu Faverge's avatar Mathieu Faverge

Bunch of leak cleanup

parent ab357197
......@@ -723,7 +723,6 @@ void Core::launch_action(int state, void* arg) {
case _STATE_LAUNCH_GRAPHICAL_INTERFACE :
waitGUIInit = new QEventLoop(this);
std::cout << "waitGUIInit créé"<< std::endl;
_main_window = new Interface_graphic (this);/* launch the window interface */
Message::set_interface (_main_window);/* define which interface will receive messages */
......
......@@ -170,7 +170,7 @@ Interface_graphic::~Interface_graphic(){
void Interface_graphic::load_windows(){
QUiLoader loader;
QUiLoader *loader = new QUiLoader();
QFile file_info(":/window/info_window.ui");
QFile file_selection_export(":/window/option_export_window.ui");
QFile file_help(":/window/help_window.ui");
......@@ -183,7 +183,7 @@ void Interface_graphic::load_windows(){
/* Load the informative window from a .ui file */
if ( file_info.exists() ) {
file_info.open(QFile::ReadOnly);
CKFP(_ui_info_window = loader.load(&file_info, this), "Cannot open the .ui file: " << ":/window/info_window.ui");
CKFP(_ui_info_window = loader->load(&file_info, this), "Cannot open the .ui file: " << ":/window/info_window.ui");
file_info.close();
} else {
cerr << __FILE__ << ":" << __LINE__ << ": The following .ui file doesn't exist: " << ":/window/info_window.ui" << endl;
......@@ -193,7 +193,7 @@ void Interface_graphic::load_windows(){
/* Load the _option_export_window from a .ui file */
if ( file_selection_export.exists() ) {
file_selection_export.open(QFile::ReadOnly);
CKFP(_ui_time_selection_export = loader.load(&file_selection_export, this), "Cannot open the .ui file : " << ":/window/option_export_window.ui");
CKFP(_ui_time_selection_export = loader->load(&file_selection_export, this), "Cannot open the .ui file : " << ":/window/option_export_window.ui");
file_selection_export.close();
} else {
cerr << __FILE__ << ":" << __LINE__ << ": The following .ui file doesn't exist: " << ":/window/option_export_window.ui" << endl;
......@@ -203,7 +203,7 @@ void Interface_graphic::load_windows(){
/* Load the choice counter for export box */
if ( file_counter_to_export.exists() ) {
file_counter_to_export.open(QFile::ReadOnly);
CKFP(_ui_counter_choice_to_export = loader.load(&file_counter_to_export, this), "Cannot open the .ui file : " << ":/window/list_of_counter_to_export.ui");
CKFP(_ui_counter_choice_to_export = loader->load(&file_counter_to_export, this), "Cannot open the .ui file : " << ":/window/list_of_counter_to_export.ui");
CKFP(_counter_list_names = _ui_counter_choice_to_export->findChild<QComboBox*>("combobox"), "Cannot find the svg export button in the .ui file");
file_counter_to_export.close();
} else {
......@@ -214,7 +214,7 @@ void Interface_graphic::load_windows(){
/* Load the help dialog box from a .ui file */
if ( file_help.exists() ) {
file_help.open(QFile::ReadOnly);
CKFP(_ui_help_window = loader.load(&file_help, this), "Cannot open the .ui file : " << ":/window/help_window.ui");
CKFP(_ui_help_window = loader->load(&file_help, this), "Cannot open the .ui file : " << ":/window/help_window.ui");
file_help.close();
} else {
cerr << __FILE__ << ":" << __LINE__ << ": The following .ui file doesn't exist: " << ":/window/help_window.ui" << endl;
......@@ -223,7 +223,7 @@ void Interface_graphic::load_windows(){
/* Load the export combo box choice from a .ui file */
/* file_kind_of_export.open(QFile::ReadOnly);
CKFP(_ui_kind_of_export_choice = loader.load(&file_kind_of_export, this), "Cannot open the .ui file : " << ":/window/kind_of_export.ui");
CKFP(_ui_kind_of_export_choice = loader->load(&file_kind_of_export, this), "Cannot open the .ui file : " << ":/window/kind_of_export.ui");
CKFP(_ui_svg_export_button = this->findChild(QRadioButton*), _ui_kind_of_export_choice, "svg_export"), "Cannot find the svg export button in the .ui file");
CKFP(_ui_png_export_button = this->findChild(QRadioButton*), _ui_kind_of_export_choice, "png_export"), "Cannot find the png export button in the .ui file");
CKFP(_ui_counter_export_button = this->findChild(QRadioButton*), _ui_kind_of_export_choice, "counter_export"), "Cannot find the svg export button in the .ui file");
......
......@@ -114,10 +114,6 @@ updateGL();
Hook_event::Hook_event(Render* render_instance, Core* core, QWidget *parent, const QGLFormat& format)
: QGLWidget(format, parent), _core(core) {
std::cout << "constructeur hook event" << std::endl;
// GLenum glew_code;
if (!QGLFormat::hasOpenGL ()){
QMessageBox::information(0, tr("ViTE: Fatal OpenGL error"), tr("This system does not support OpenGL."));
}
......
......@@ -140,6 +140,7 @@ Render_alternate::Render_alternate(Core* core, QWidget *parent, const QGLFormat&
Render_alternate::~Render_alternate(){
delete _wait;
delete _shader;
}
......@@ -278,7 +279,7 @@ void Render_alternate::render_text(QString text, float x, float y, float w, floa
v.add(x , y+h, 0, 0);
v.add(x+w, y+h, 1, 0);
v.config(_glsl);
glUseProgram(_wait.get_shader()->getProgramID());
glUseProgram(_wait->get_shader()->getProgramID());
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
v.lock();
......@@ -340,7 +341,7 @@ void Render_alternate::paintGL(){
/*Draw the home screen*/
if(DRAWING_STATE_WAITING == _state){
glUseProgram(_wait.get_shader()->getProgramID());
glUseProgram(_wait->get_shader()->getProgramID());
checkGlError();
glEnable(GL_BLEND);
......@@ -349,7 +350,7 @@ void Render_alternate::paintGL(){
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
checkGlError();
_wait.lock();
_wait->lock();
glBindTexture(GL_TEXTURE_2D, _textureID);
checkGlError();
......@@ -357,11 +358,11 @@ void Render_alternate::paintGL(){
std::cout << "draw wait\n";
// GL_QUADS is deprecated for Opengl greater than 3., so an invalide enum is returned by glGetError and needs to be reset
// TODO: fix that by replacing by GL_TRIANGLES
glDrawArrays(GL_TRIANGLES, 0, _wait.getNbVertex()); /*glGetError();*/
glDrawArrays(GL_TRIANGLES, 0, _wait->getNbVertex()); /*glGetError();*/
checkGlError();
glBindTexture(GL_TEXTURE_2D, 0);
checkGlError();
_wait.unlock();
_wait->unlock();
glUseProgram(0);
checkGlError();
return;
......@@ -788,27 +789,31 @@ bool Render_alternate::unbuild(){
GLuint Render_alternate::draw_wait() {
Shader *s = new Shader(_glsl, 0);
s->charger();
_wait.set_shader(s);
glGenTextures(1, &_textureID);
glBindTexture(GL_TEXTURE_2D, _textureID);
QFile texture_file(QString(":/img/img/logo") + QDate::currentDate().toString("MMdd") + QString(".png"));
if (true == texture_file.exists())/* The texture exists */
_textureID = bindTexture(QPixmap(texture_file.fileName()), GL_TEXTURE_2D);
else/* use the default picture */
_textureID = bindTexture(QPixmap(":/img/img/logo.png"), GL_TEXTURE_2D);
/* Coordinates of the two triangles storing the texture */
_wait.add(-0.25, -0.25, 0, 0);
_wait.add( 0.25, -0.25, 1, 0);
_wait.add( 0.25, 0.25, 1, 1);
_wait.add( 0.25, 0.25, 1, 1);
_wait.add(-0.25, 0.25, 0, 1);
_wait.add(-0.25, -0.25, 0, 0);
_wait.config(_glsl);
if (_wait == NULL) {
Shader *s = new Shader(_glsl, 0);
_wait = new Vbo();
s->charger();
_wait->set_shader(s);
glGenTextures(1, &_textureID);
glBindTexture(GL_TEXTURE_2D, _textureID);
QFile texture_file(QString(":/img/img/logo") + QDate::currentDate().toString("MMdd") + QString(".png"));
if (true == texture_file.exists())/* The texture exists */
_textureID = bindTexture(QPixmap(texture_file.fileName()), GL_TEXTURE_2D);
else/* use the default picture */
_textureID = bindTexture(QPixmap(":/img/img/logo.png"), GL_TEXTURE_2D);
/* Coordinates of the two triangles storing the texture */
_wait->add(-0.25, -0.25, 0, 0);
_wait->add( 0.25, -0.25, 1, 0);
_wait->add( 0.25, 0.25, 1, 1);
_wait->add( 0.25, 0.25, 1, 1);
_wait->add(-0.25, 0.25, 0, 1);
_wait->add(-0.25, -0.25, 0, 0);
_wait->config(_glsl);
}
}
......
......@@ -129,7 +129,7 @@ private:
Vbo _arrows3;
Vbo _counters;
Vbo _ruler;
Vbo _wait;
Vbo *_wait;
Vbo _selection;
Vbo _time_line;
Vbo _text;
......
......@@ -92,6 +92,7 @@ Vbo::~Vbo(){
_vboID = 0;
glDeleteVertexArrays(1, &_vaoID);
_vaoID = 0;
delete _shader;
}
......@@ -274,12 +275,17 @@ Shader * Vbo::get_shader(){
}
void Vbo::delete_shader(){
delete _shader;
if (_shader != NULL) {
delete _shader;
}
_shader = NULL;
}
/* change current shader
if precedent is not used anymore, delete_shader should be called before this function*/
void Vbo::set_shader(Shader *s){
if ( _shader != NULL ) {
delete _shader;
}
_shader = s;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment