Solved QDateEdit: emitted signal dateChanged(const QDate&) freezes the desktop
-
Hello together,
i hope, anybody can help me here. I've got a strange problem, that I've observed never before. I'm running Qt 5.11.1 on an OpenSuse Leap 15 system.
I want to connect the signal dateChanged(const QDate&) from a dynamically created QDateEdit to a slot in my own class:
toDateEditName = QString("ToDateEdit_%1").arg(i,2,10,QLatin1Char('0')); ... QDateEdit *toDateEdit = new QDateEdit(end); toDateEdit->setDisplayFormat(tr("yyyy-MM-dd")); toDateEdit->setObjectName(toDateEditName); toDateEdit->setCalendarPopup(false); ... connect(toDateEdit, &QDateEdit::dateChanged, this, &MdiChild::vacationEndDateChanged);
The objectname of the dateEdit is set to toDateEdit_xx where xx is an integer with 2 fields. Additionally, I save the pointer to the toDateEdit in QList. The Slot connected to looks like that:
void MdiChild::vacationEndDateChanged(const QDate &date) { qDebug() << "ENTER: void MdiChild::vacationEndDateChanged(const QDate &date)"; QDateEdit *senderObj = qobject_cast<QDateEdit *>( sender()); if (senderObj != nullptr) { QString senderName = senderObj->objectName(); bool ok; int senderNum = senderName.right(2).toInt(&ok); if (ok) { QDate endBegin = date; hcalc.changeVacationEndDate(senderNum,endBegin); } else { // TODO: Errorhandling qDebug() << "the sender number " << senderNum << " of " << senderName << " is NOT valid"; } } setDocumentModified(true); updateCurriculumInformation(); updateCurriculumLayout(); qDebug() << "LEAVE: void MdiChild::vacationEndDateChanged(const QDate &date)"; }
when I edit the date, my program jumps into the slot-function and freezes not only the program but my entire desktop occasionally. The mouse is still working, but there is no reaction on mouse- or keyboardevents anymore. If QtCreator and a debugger is connected, QTCreator freezes to. So, it's quite difficult for me, the analyze this problem. To solve this, I've to switch to a text console and kill the programm manually. The desktop is responsive again afterwards.
During my tests, I've made some observation, that my help to isolate the problem:
- when setting calenderPopup to true, the program and the desktop freeze a lot more often.
- the freezing happens also, when my slot-function is completely empty.
- the freezing happens nearly everytime, when I change the year part of the date.
- as long, as the program is not freezed, I can monitor the system calls with strace, when the program is not responsive any more, I get the message, that the process runs in x32 mode. I can't see any syscalls anymore then:
ralf@chaos:~> strace -p 2218 strace: Process 2218 attached strace: [ Process PID=2218 runs in x32 mode. ]
I'd be really happy, if someone knows this kind of problem and could help me with that.
Greetings,
Ralf -
Hi,
Do you observe the same behaviour if you use your distribution provided Qt ?
-
currently, the only version installed, is the one I downloaded from www.qt.io. So I can't tell that. I've had this prob never before though.
-
Then can you try with the previous version of Qt ?
-
I'll do that tomorrow. Which version of Qt would you recommend?
-
Start by 5.11.0, if it's still happening then continue back.
But first you should test the version of OpenSuse to eliminate that's not your system that's doing something funky somehow.
-
To exclude that my Linux is responsible, I have also translated the program under Windows with minGW. The same problem occurs there. You can change the date a couple of times, but eventually, the program freezes. One difference between Linux and Windows: Under Linux, additionally the whole desktop freezes, when calenderPopup ist true.
I've also tried, to compile the program with some older versions, 5.11.0, 5.10.0 and 5.8.0.
Always the same problem.When running the program with the debugger, I can see, that the program enters the connected slot (see above) and freezes BEFORE executing any entered command. When that happens, QTCreator and the debugger freeze too.
-
@RalfSchaefer
2 ideas you could test as wellspecify the 5th connect parameter as Qt::DirectConnection, maybe the autoconnect makes a blockingconnection which would deadlock your program, unlikly, burt worth a shot.
connect to lambda in the connect instead of a slot
maybe this gives you/us more information
-
This post is deleted! -
@J.Hilk : Thanks for the advice. I'll try that. But it will take till next sunday, before I can do that. I'll keep you up to date then.
-
I was able to solve the problem in the meantime. It was some sort of a signal loop.
I've got a couple of QDateEdits in my program. When I change the date in one of my QDateEdits, it sets the mimimumDate or the maximumDate of another QDateEdit. This could change the date in the second QDateEdit who sent another signal around, which again sets mimimumDate or the maximumDate. The program somehow looped.
A little bit strange is, that I could not see this in the debugger.
Thanks a lot for all the help.
Ralf