PDA

View Full Version : Application crashes after adding a new class



wallace_000
19th March 2010, 17:06
Hi

I'm trying to implement an OpenGL application with Qt. As a starting point I used an example I found on the web (http://blog.lugru.com/2009/03/qtdesigner-and-qglwidget/)

But always when I try to extend the functions by adding a new class my application crashs before startup. It crashes always somewhere in the Events part of the Qt libraries

here the code how i coneted my class with the existing parts.

Thanks in advance for any help

mainwindow constructor


MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), m_ui(new Ui::MainWindowClass)
{
...
// get an instance of the globalManager
m_Manager = GlobalManager::GetInstance();
...
}



definition of m_Manager

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
MainWindow(QWidget *parent = 0);
~MainWindow();

private:
/// \brief our GlobalManager which controls the rendering - we pass all data to it
GlobalManager *m_Manager;

};


The header of the GlobalManager Class



class GlobalManager{
private:
static GlobalManager* m_Instance;

int m_Testvar;

/// \brief private constructor for our manager
GlobalManager();
/// \brief make asssigment operator private
GlobalManager& operator=(GlobalManager&);
/// \brief make copy constructor private
GlobalManager(const GlobalManager&);

public:
static GlobalManager* GetInstance();
void GetRTImage();

};

and the according cpp


/// Static memeber initialisation
GlobalManager* GlobalManager::m_Instance = 0;

/// \brief constructor implementation
GlobalManager ::GlobalManager()
{
int m_Testvar = 10;
}

/// \brief function return the only instance of the object
GlobalManager* GlobalManager::GetInstance()
{
if(m_Instance==0)
{
m_Instance=new GlobalManager();
}
return m_Instance;
}

Lykurg
19th March 2010, 19:42
Can you send a backtrace of your debugger. And are you sure using m_Manager only after your posted line in the c-tor?