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