c++ - QNetworkAccessManager `get` method crashes on restart -


I am currently adding a functionality to my app which will allow it to be restarted.

This is the main look

  int main (int argc, char * argv []) {const int RESTART_CODE = 1000; Int return_from_event_loop_code; QPointer & LT; QApplication & gt; Application; QPointer & LT; Foo & gt; main window; Delete the {if (main_window) main_window; Delete the app; App = new QApplication (argc, argv); Main_window = new foo (); Main_window-> Show (); App- & gt; SetActiveWindow (main_window); Return_from_event_loop_code = app- & gt; Exec (); } While (return_from_event_loop_code == RESTART_CODE); Return return_from_event_loop_code; }   

is now running fine for the first time, but when the application has been restarted using the RestartApp method below QNetworkAccessManager Get the method to return a lock error. This is my code that looks like

  void foo :: MethodA () {.... .... KUR URL ("some url"); QNetworkRequest request; Request.setUrl (url); NetworkManager = New QNetworkAccessManager (this); QObject :: Connect (NetworkManager, sign (end (QNetworkReply *), this, slot (replyFinished (QNetworkReply *)), static_cast & lt; qt :: ConnectionType & gt; (QT :: QueuedConnection | QT :: UniqueConnection) ; CurrentReply = networkManager- & gt; Received (request); // When the crash app resume resume (currentReply, signal (error (QNetworkReply :: NetworkError), this, slot (slotNetworkError (QNetworkReply :: NetworkError), QT :: UniqueConnection); } // slot void foo: replyFinished (QNetworkReply * rply) {.... ......... ... rply->; DeleteLater (); } // slot void foo: RestartApp () {QCoreApplication :: exit (1000); }   

Now this happens when the app starts for the first time, everything is fine. Although the RestartApp method is called and is done when return_from_event_loop_code = app- & gt; Executive (); The method in the main statement is called at this time currentReply = networkManager-> (Request) is received; The app crashes in and ends in

  mlock.c zero __cdecl _unlock {} * {* * Skip important section * / holiday icon (_locktable [ Locknum]. Lock); }   

Why get the QNetworkAccessManager statement on the App crash when any application on the app is given to restart the instruction?

I did some check on the accident. This is actually caused by the destruction of QApplication QNetworkAccessManager internally uses a qnetworkconfigurationManagerPrivate object when this object is created And until the application is finished. qNetworkConfigurationManagerPrivate is used to create or obtain existing objects.

QApplication is destroyed, it executes all post routines including, connManager_cleanup . This function indirectly destroys the QNetworkConfigurationManagerPrivate object and set app shutdown local flag. When this flag is set, the qNetworkConfigurationManagerPrivate function will no longer create the new QNetworkConfigurationManagerPrivate objects. Then the QApplication QNetworkAccessManager after the destruction of becomes non-functional.

I thought it's the QApplication object, but recently a misuse I found a proof link which is right to use.

State of Qt:

Question [Core] Application is a Singleton Class. There can be an example only at one time, however, that example can be destroyed and can be made a new one.

Then this problem should be considered as a QT bug.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -