title: Getting Pixmap is a null pixmap on calling a function 500 times
body: <p>I am showing a image in qt label. Below is my code: </p>
  
  <pre><code>void MyClass::onPushButtonClicked(QString myurl)
  {
      this-&gt;setCursor(Qt::WaitCursor);
      ui.qtImageLabel-&gt;clear();
      qDebug()&lt;&lt;QTime::currentTime()&lt;&lt;"MyClass: onPushButtonClicked";
      QNetworkAccessManager *qnam_push_button_clicked_show_image;
      QNetworkReply *reply;
      QNetworkRequest request;
      request.setHeader( QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded" );
      QUrl url(myurl);
      request.setUrl(url);
      qnam_push_button_clicked_show_image = new QNetworkAccessManager(this);
      if(qnam_push_button_clicked_show_image)
      {
          QObject::connect(qnam_push_button_clicked_show_image, SIGNAL(finished(QNetworkReply*)),
                           this, SLOT(onPushButtonClickedRequestCompleted(QNetworkReply*)));
          reply = qnam_push_button_clicked_show_image-&gt;post(request, url.encodedQuery());
          QEventLoop loop;
          QObject::connect(reply, SIGNAL(finished()), &amp;loop, SLOT(quit()));
          loop.exec();
      }
  }
  
  void MyClass::onPushButtonClickedRequestCompleted(QNetworkReply *reply)
  {
      qDebug()&lt;&lt;QTime::currentTime()&lt;&lt;"MyClass: onPushButtonClickedRequestCompleted request completed";
      if (reply-&gt;error() != QNetworkReply::NoError)
      {
          qDebug() &lt;&lt; "Error in" &lt;&lt; reply-&gt;url() &lt;&lt; ":" &lt;&lt; reply-&gt;errorString();
          this-&gt;setCursor(Qt::ArrowCursor);
          return;
      }
      QByteArray data = reply-&gt;readAll();
      QPixmap pixmap;
      pixmap.loadFromData(data);
      int width;
      int height;
      //application size can be changed
      QRect rec = QApplication::desktop()-&gt;screenGeometry();
      height = rec.height();
      width = rec.width();
      qDebug()&lt;&lt;QTime::currentTime()&lt;&lt;width&lt;&lt;","&lt;&lt;height;
      QSize *size = new QSize(width,height);
      if(size)
      {
          QPixmap scaledPixmap = pixmap.scaled(*size);
          ui.qtImageLabel-&gt;setPixmap(scaledPixmap);
      }
      if(size)
      {
          delete size;
          size = NULL;
      }
      data.clear();
      this-&gt;setCursor(Qt::ArrowCursor);
      reply-&gt;deleteLater();
      return;
  }
  </code></pre>
  
  <p>On clicking push button It will send a request to server and will show a different image received from server. It is working fine if it does't exceeds 500 times. If it exceeds that first this error has been shown</p>
  
  <pre><code>QPixmap::scaled: Pixmap is a null pixmap
  </code></pre>
  
  <p>and it doesn't show the image. Then if someone again sends a request for an image then it shows the following error:
  Qt has caught an exception thrown from an event handler. Throwing
  exceptions from an event handler is not supported in Qt. You must
  re implement <code>QApplication::notify()</code> and catch all exceptions there.</p>
  
  <p>I am not getting what is the error in the above code. Can someone please tell me how to solve this?</p>