1

I turn on the PC, the code compiles, the application runs. I close the application, and run again, but it crashes with error A I close and run again, it just hangs while trying to create MainWindow. I restart PC, and back to top, the application runs one time.

Even if I remove the members initialization list, it doesn't change. The error might be something strange. I am using boost::interprocess to create shared memory, but I tried commenting this out, and still the same.

I am compiling against Qt 4.8.6.

so from the point of constructor parameters, should be fine.

ideas?

main.cpp:

... 
cout<< "something"; //this prints
MainWindow w(ce); //hangs when reaching this line
cout<< "whatever"; //this does NOT print
...

mainwindow.h:

explicit MainWindow(CreateEvents *ce, QWidget *parent = 0);

MainWindow.cpp:

//includes etc
...
//MainWindow constructor here:

MainWindow::MainWindow(CreateEvents *ce, QWidget *parent) :
 QMainWindow(parent),
 ui(new Ui::MainWindow),
 shWriter() {

 qDebug("MainWindow CONSTRUCTOR!"); //this does NOT print
...
meleneemil
  • 21
  • 4
  • What does the constructor for shWriter do? It's possible that it is getting stuck there. Also your constructor expects two arguments but you are only providing one, are you in fact calling a different constructor? – James Elderfield Apr 20 '16 at 15:42
  • shWriter constructor: creates a ShareMemoryWriter. It includes: new boost::interprocess::managed_shared_memory ( boost::interprocess::open_or_create, "name_of_memory",size_of_memory) – meleneemil Apr 20 '16 at 15:45
  • Move `shWriter()` after the debug statement to verify that it is hanging. – dtech Apr 20 '16 at 15:49
  • I asked too soon perhaps. Even if I comment out the member initializations, I still don't go into the debug command... *I'm new in StackOverflow. Should I make new question? – meleneemil Apr 20 '16 at 15:51
  • If possible edit your current question, as a newb you have a limit on new questions until you establish as a trusty user. You can also delete this one, while it is still unanswered. – dtech Apr 20 '16 at 15:53
  • I did. thanks for the tips, all. – meleneemil Apr 20 '16 at 16:19
  • You really need to provide a test case that reproduces the issue. Keep minimizing the problem until you absolutely can't, move all the code into a single `main.cpp` with class declared and defined in one go Java-style. See e.g. [this answer](http://stackoverflow.com/a/36625107/1329652) for inspiration. As it is, the question is off-topic since you don't show the failing code. – Kuba hasn't forgotten Monica Apr 20 '16 at 17:01

0 Answers0