Qt Signal Slot Infinite Loop

3/25/2022by admin
Qt Signal Slot Infinite Loop Average ratng: 3,7/5 3812 reviews
  • Status:Closed
  • Resolution: Cannot Reproduce
  • Fix Version/s:5.0.2
  • Labels:
  • Environment:

I have a QWebView that opens a local web page on my computer, and everything works perfectly in Qt4.8. (It also works with a browser). But after porting the software to Qt5.0.2 (and making the change from QWebView to QtWebKitWidgets/QWebView, the program appears to hang, then crashes with the following output:

The signal slot mechanism of the thread needs to turn on the event loop mechanism of the thread, that is to call the qthread:: exec function to start the event loop of the thread. The prototype of QT signal slot connection function is as follows: bool QObject::connect ( const QObject. sender, const char. signal, const. Signals and slots are loosely coupled: A class which emits a signal neither knows nor cares which slots receive the signal. Qt's signals and slots mechanism ensures that if you connect a signal to a slot, the slot will be called with the signal's parameters at the right time. Signals and slots can take any number of arguments of any type.

QIODevice::read: maxSize argument exceeds QByteArray size limit.
terminate called after throwing an instance of ‘std::bad_alloc’
what(): std::bad_alloc

Here’s the code:

I have a QWebView that opens a local web page on my computer, and everything works perfectly in Qt4.8. (It also works with a browser). But after porting the software to Qt5.0.2 (and making the change from QWebView to QtWebKitWidgets/QWebView, the program appears to hang, then crashes with the following output. Fix stack overflow due to signal infinite loop #444 rp- merged 1 commit into sqlitebrowser: master from unknown repository Nov 18, 2015 Conversation 2 Commits 1 Checks 0 Files changed.

HelpManager::HelpManager(QObject *parent) :
QObject(parent)

{ view = new QWebView(); connect (view, SIGNAL(loadStarted()), SLOT(loadIsStarted())); connect (view, SIGNAL(loadProgress(int)), SLOT(loadInProgress(int))); connect (view, SIGNAL(loadFinished(bool)), SLOT(loadIsFinisehd(bool))); view->load(QUrl('../Help/IDTNVMeMgr-web/index.html')); view->setWindowTitle('IDTVMeMgr Help Information'); view->show(); }

void HelpManager::loadIsStarted()

{ qDebug() << 'loadIsStarted'; }

void HelpManager::loadInProgress(int progress)

{ qDebug() << 'loadInProgress, progress =' << progress; }LoopSignal

Qt Signal Slot Infinite Loop Tool

void HelpManager::loadIsFinisehd(bool isOk)

{ qDebug() << 'loadIsFinshed, status = ' << isOk; }

Here is the successful output using Qt4.8

loadIsStarted
loadInProgress, progress = 10
loadInProgress, progress = 10
loadInProgress, progress = 27
loadInProgress, progress = 29
loadInProgress, progress = 32
loadInProgress, progress = 36
loadInProgress, progress = 36
loadInProgress, progress = 36
loadInProgress, progress = 90
loadInProgress, progress = 90
loadInProgress, progress = 90
loadInProgress, progress = 90
loadInProgress, progress = 90
loadInProgress, progress = 100
loadIsFinshed, status = true

Attachments

Gerrit Reviews

SlotTool
No reviews matched the request. Check your Options in the drop-down menu of this sections header.
Assignee:
Michael Bruning
Reporter:
Robert Felten

Qt Signal Slot Infinite Loop Maker

Votes:
0Vote for this issue
Watchers:
3Start watching this issue
Comments are closed.