QSqlDatabase open() crashes when db cannot be accessed ?
-
At the end of what loop ?
-
@SGaist said in QSqlDatabase open() crashes when db cannot be accessed ?:
At the end of what loop ?
It's a thread with a while loop that emits images to another window for display. The thread (with the loop) is running while the database is opened...
-
Some sort of splash screen ?
In any case, it looks like that thread implementation might need a look into it to avoid future issues.
-
@SGaist said in QSqlDatabase open() crashes when db cannot be accessed ?:
Some sort of splash screen ?
In any case, it looks like that thread implementation might need a look into it to avoid future issues.
No, its a live video. The basic flow is like this:
//On MainWindow Load... //Database class is created which contains database settings. //Create thread class and start the thread. //Thread runs a while() loop that captures an image and emits the image to MainWindow via a signal. //MainWindow receives the signal with the image and displays it inside a label. //User clicks a button inside MainWindow... //Open database using the database class. //Do something... //Close database.
I don't really see anything very wrong with the above program flow. Yet having
QCoreApplication::processEvents();
inside the loop breaks the database opening. Very strange. -
The fact that processEvent is called in a thread is usually the sign of something off.
-
@SGaist said in QSqlDatabase open() crashes when db cannot be accessed ?:
The fact that processEvent is called in a thread is usually the sign of something off.
It was actually being called inside the slot in MainWindow to ensure that the label renders the image. But you are correct, it shouldn't be there. Is there any danger in using it ?
-
I have usually seen processEvent called from the main thread directly which forces processing of events however calling it from a different thread is the first time. As you can see there's some strange interaction. I currently wonder whether you have an event that is processed by the wrong event loop.