I'm facing an odd problem with a code of mine. I have a menu item "Open File" which has a shortcut Ctrl+C. If I run the program and hit Ctrl+C, the program works like a charm, no problems. However, if I instead go to the menu item and click it, the function itself also works like a charm, but at the end of it, the program crashes. Here's the code:

Qt Code:
  1. Canvas::Canvas(const QPoint& Position, const QSize& Size,QWidget* Parent) :
  2. QSFMLCanvas(Parent, Position, Size),
  3. MenuBar(this)
  4. {
  5. setMouseTracking(true);
  6. setAttribute(Qt::WA_DeleteOnClose);
  7. points.reserve(3000);
  8.  
  9. EqualizeSize=0;
  10. PointsVisible=true;
  11.  
  12. QMenu* menu = MenuBar.addMenu("File");
  13. menu->addAction("&Open",this,SLOT(OpenFile()),QKeySequence::Open);
  14. menu->addAction("&Save",this,SLOT(SaveFile()),QKeySequence::Save);
  15. menu->addAction("&Quit",QCoreApplication::instance(),SLOT(quit()),QKeySequence::Quit);
  16. //...
To copy to clipboard, switch view to plain text mode 

The shortcut is never redefined anywhere else in the code (the code above is, in fact, the only time the function OpenFile() is called).

Am I doing anything wrong here? Why does using "Ctrl+C" work, but using the menu-button crash, at the end of the OpenFile() function? Does the fact that I set the menu ("File") as a temporary variable have anything to do with this?