Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7919361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:50:18+00:00 2026-06-03T15:50:18+00:00

Is it possible for this Qt code to run into an infinite loop? QNetworkAccessManager

  • 0

Is it possible for this Qt code to run into an infinite loop?

QNetworkAccessManager m;
QNetworkReply *reply = m.get(QNetworkRequest(QUrl("http://www.example.org/")));
QEventLoop loop;
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
qDebug() << reply->readAll();
delete reply;

This is basically a “synchronous” way to display the contents of a webpage.

I have not observed any issues using it, but I considered the following scenario:

  • The finished signal of reply is emitted before the event loop is created and the signal-slot connection between finished and quit is made
  • No signal will be emitted from that point forward thus never triggering quit
  • loop.exec() will continually loop

Is it possible for that to occur, or am I not understanding something about how the Qt event loop works?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T15:50:20+00:00Added an answer on June 3, 2026 at 3:50 pm

    While Qt executes your own code (the code above, for example), it can’t process new signals and call slots. Every signal was emitted while your method is executing will be processed later. If you want to force processing of signals in middle of your method, you can call QCoreApplication::processEvents to process signals in your current event loop or QEventLoop::exec to do it in another loop.

    So this code is safe. If a signal comes too fast, it will wait in the event queue.

    If you’re emitting a signal and there are slots connected to this signal using Qt::DirectConnection, these slots will be executed immediately. But this doesn’t match your case. Qt have to execute some internal code before the singal will be emitted. It can’t execute this code while your method is executing. There are only one thread and only one call stack.

    Note that when you’re using Qt threads event loops’ behaviour is more complicated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is this code possible? switch (rule) { case 'email' || 'valid_email': valid = this.validate_email(field);
Is it possible to code this sequence of events once an iPhone app has
Possible Duplicate: Python list append behavior Why does this code: x = [[]]*3 x[0].append('a')
Possible Duplicate: Comparing Strings in Cocoa Why is this code not recognising the NSString
Is it possible to convert this java code snippet to php? public void testBalanceReturnsToZeroOnVending()
Possible Duplicate: Returning reference to a local variable I happened to find this code
Is it possible to change PowerPacks.LineShape smoothingMode? I tried to use this code(a class
Possible Duplicate: PHP: “Notice: Undefined variable” and “Notice: Undefined index” This code shows warnings
Is this possible to do the following in ExpressionEngine: (code taken from here )
Is it possible to make this line of code valid? description, content, state, city,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.