Commit ac48435a authored by Sylvain Thery's avatar Sylvain Thery

resolve crash of SCHNApps at exit()

parent c1c330dd
......@@ -33,6 +33,7 @@ SET( QT_USE_QTXML TRUE )
SET( QT_USE_QTDESIGNER TRUE )
SET( QT_USE_QTGUI TRUE )
SET( QT_USE_QTPLUGIN TRUE )
SET( QT_USE_QTSVG TRUE )
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
......
......@@ -16,8 +16,7 @@ class Surface_Import_Plugin : public PluginProcessing
public:
Surface_Import_Plugin()
{
}
{}
~Surface_Import_Plugin()
{}
......
......@@ -4,8 +4,6 @@
#include <QtPlugin>
#include <QAction>
#include <GL/glew.h>
#include "types.h"
namespace CGoGN
......@@ -21,24 +19,18 @@ class Plugin : public QObject
friend class SCHNApps;
public:
Plugin() : m_schnapps(NULL)
{
glewInit();
}
virtual ~Plugin() {}
const QString& getName() const { return m_name; }
Plugin();
virtual ~Plugin();
public slots:
QString getName() { return m_name; }
const QString& getFilePath() { return m_filePath; }
SCHNApps* getSCHNApps() { return m_schnapps; }
QString getName();
QString getFilePath();
SCHNApps* getSCHNApps();
private:
void setName(const QString& name) { m_name = name; }
void setFilePath(const QString& f) { m_filePath = f; }
void setSCHNApps(SCHNApps* s) { m_schnapps = s; }
void setName(const QString& name);
void setFilePath(const QString& f);
void setSCHNApps(SCHNApps* s);
virtual bool enable() = 0;
virtual void disable() = 0;
......
......@@ -29,11 +29,11 @@ int main(int argc, char* argv[])
// CGoGN::SCHNApps::SCHNApps schnapps(app.applicationDirPath(), pythonContext, pythonConsole);
PythonQtScriptingConsole* pythonConsole = new PythonQtScriptingConsole(NULL, pythonContext);
CGoGN::SCHNApps::SCHNApps schnapps(app.applicationDirPath(), pythonContext, *pythonConsole);
CGoGN::SCHNApps::SCHNApps* schnapps = new CGoGN::SCHNApps::SCHNApps(app.applicationDirPath(), pythonContext, *pythonConsole);
schnapps.show();
schnapps->show();
pythonContext.addObject("schnapps", &schnapps);
pythonContext.addObject("schnapps", schnapps);
if(argc > 1)
{
......@@ -43,8 +43,8 @@ int main(int argc, char* argv[])
pythonContext.evalFile(fi.filePath());
}
splash->finish(&schnapps);
splash->finish(schnapps);
delete splash;
return app.exec();
return app.exec();;
}
......@@ -108,8 +108,7 @@ void View::unlinkPlugin(PluginInteraction* plugin)
{
plugin->unlinkView(this);
emit(pluginUnlinked(plugin));
// removed because of crash when application close
// updateGL();
updateGL();
}
}
......@@ -160,8 +159,7 @@ void View::unlinkMap(MapHandlerGen* map)
emit(mapUnlinked(map));
updateCurrentCameraBB();
// removed because of crash when application close
// updateGL();
updateGL();
disconnect(map->getFrame(), SIGNAL(modified()), this, SLOT(updateGL()));
disconnect(map, SIGNAL(selectedCellsChanged(CellSelectorGen*)), this, SLOT(updateGL()));
......
......@@ -66,7 +66,7 @@ public:
static unsigned int CURRENT_OGL_VERSION;
static std::set< std::pair<void*, GLSLShader*> > m_registeredShaders;
static std::set< std::pair<void*, GLSLShader*> >* m_registeredShaders;
// static glm::mat4* s_current_matrices;
static Utils::GL_Matrices* s_current_matrices;
......
......@@ -66,7 +66,8 @@ std::string* GLSLShader::DEFINES_GL = NULL;
std::vector<std::string> GLSLShader::m_pathes;
std::set< std::pair<void*, GLSLShader*> > GLSLShader::m_registeredShaders;
//std::set< std::pair<void*, GLSLShader*> > GLSLShader::m_registeredShaders;
std::set< std::pair<void*, GLSLShader*> >* GLSLShader::m_registeredShaders = NULL;
//glm::mat4* GLSLShader::s_current_matrices=NULL;
......@@ -90,16 +91,19 @@ GLSLShader::GLSLShader() :
DEFINES_GL = &DEFINES_GL2;
m_nbMaxVertices = 16;
if (m_registeredShaders==NULL)
m_registeredShaders = new std::set< std::pair<void*, GLSLShader*> >;
}
void GLSLShader::registerShader(void* ptr, GLSLShader* shader)
{
m_registeredShaders.insert(std::pair<void*,GLSLShader*>(ptr, shader));
m_registeredShaders->insert(std::pair<void*,GLSLShader*>(ptr, shader));
}
void GLSLShader::unregisterShader(void* ptr, GLSLShader* shader)
{
m_registeredShaders.erase(std::pair<void*,GLSLShader*>(ptr, shader));
m_registeredShaders->erase(std::pair<void*,GLSLShader*>(ptr, shader));
}
std::string GLSLShader::defines_Geom(const std::string& primitivesIn, const std::string& primitivesOut, int maxVert)
......@@ -657,7 +661,7 @@ GLSLShader::~GLSLShader()
if (m_geom_shader_source != NULL)
delete[] m_geom_shader_source;
// m_registeredShaders.erase(this);
// m_registeredShaders->erase(this);
}
std::string GLSLShader::findFile(const std::string filename)
......@@ -1138,7 +1142,7 @@ void GLSLShader::updateCurrentMatrices()
currentPMV() = currentProjection() * model;
currentNormalMatrix() = glm::gtx::inverse_transpose::inverseTranspose(model);
for(std::set< std::pair<void*, GLSLShader*> >::iterator it = m_registeredShaders.begin(); it != m_registeredShaders.end(); ++it)
for(std::set< std::pair<void*, GLSLShader*> >::iterator it = m_registeredShaders->begin(); it != m_registeredShaders->end(); ++it)
it->second->updateMatrices(currentProjection(), model, currentPMV(), currentNormalMatrix());
}
......@@ -1165,7 +1169,7 @@ void GLSLShader::updateAllFromGLMatrices()
currentPMV() = proj * model;
currentNormalMatrix() = glm::gtx::inverse_transpose::inverseTranspose(model);
for(std::set< std::pair<void*, GLSLShader*> >::iterator it = m_registeredShaders.begin(); it != m_registeredShaders.end(); ++it)
for(std::set< std::pair<void*, GLSLShader*> >::iterator it = m_registeredShaders->begin(); it != m_registeredShaders->end(); ++it)
it->second->updateMatrices(proj, model, currentPMV(), currentNormalMatrix());
}
......
......@@ -445,8 +445,8 @@ void SimpleQGLV::cb_updateMatrix()
}
else
{
for(std::set< std::pair<void*, GLSLShader*> >::iterator it = GLSLShader::m_registeredShaders.begin();
it != GLSLShader::m_registeredShaders.end();
for(std::set< std::pair<void*, GLSLShader*> >::iterator it = GLSLShader::m_registeredShaders->begin();
it != GLSLShader::m_registeredShaders->end();
++it)
{
if ((it->first == NULL) || (it->first == this))
......
......@@ -439,8 +439,8 @@ void SimpleQT::cb_updateMatrix()
}
else
{
for(std::set< std::pair<void*, GLSLShader*> >::iterator it = GLSLShader::m_registeredShaders.begin();
it != GLSLShader::m_registeredShaders.end();
for(std::set< std::pair<void*, GLSLShader*> >::iterator it = GLSLShader::m_registeredShaders->begin();
it != GLSLShader::m_registeredShaders->end();
++it)
{
if ((it->first == NULL) || (it->first == this))
......
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