Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Application hung after dialog opened during startup on macOS
Qt 6.11 is out! See what's new in the release blog

Application hung after dialog opened during startup on macOS

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 274 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote last edited by Perdrix
    #1

    My application's main contains:

    		deleteRemainingTempFiles();
    		mainWindow.show();
    

    if the dialog in deleteRemainingTempFiles() is displayed on macOS, then the application is unresponsive after clicking on "Yes".
    Here's what's in deleteRemainingTempFiles()

    	void	deleteRemainingTempFiles()
    	{
    		ZFUNCTRACE_RUNTIME();
    		std::vector<QString> vFiles;
    		qint64	totalSize = 0;
    
    		QString folder(CAllStackingTasks::GetTemporaryFilesFolder());
    
    		QStringList nameFilters("DSS*.tmp");
    
    		QDir dir(folder);
    		dir.setNameFilters(nameFilters);
    
    		for (QFileInfo item : dir.entryInfoList())
    		{
    			if (item.isFile())
    			{
    				vFiles.emplace_back(item.absoluteFilePath());
    				totalSize += item.size();
    			}
    		}
    
    		if (!vFiles.empty())
    		{
    			QString			strMsg;
    			QString			strSize;
    
    			ZTRACE_RUNTIME("Remove remaining %d temp files", vFiles.size());
    
    			SpaceToQString(totalSize, strSize);
    
    			strMsg = QString("One or more temporary files created by DeepSkyStacker are still in the working directory."
    				"\n\nDo you want to remove them?\n\n(%1 file(s) using %2)")
    				.arg(vFiles.size()).arg(strSize);
    
    			QMessageBox msgBox(QMessageBox::Question, QString(""), strMsg, (QMessageBox::Yes | QMessageBox::No));
    
    			msgBox.setDefaultButton(QMessageBox::Yes);
    
    			if (QMessageBox::Yes == msgBox.exec())
    			{
    				QFile file;
    				for (size_t i = 0; i < vFiles.size(); i++)
    				{
    					file.setFileName(vFiles[i]);
    					file.remove();
    				}
    			};
    
    		};
    
    
    	};
    

    What am I doing wrong, and what do I need to do to fix this?

    Thanks, David

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote last edited by
      #2

      IIRC, ALL Qt apps have to actually start the event loop running with a call to exec().

      The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote last edited by
        #3

        Hi,

        Which version of Qt are you using ?
        On which version of macOS ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • PerdrixP Offline
          PerdrixP Offline
          Perdrix
          wrote last edited by
          #4

          @SGaist Qt 6.10, macOS Tahoe 26.3.1.
          @Kent-Dorfman AFAIK, and I could be wrong, QMessageBox::exec() runs it own local event loop.

          J.HilkJ 1 Reply Last reply
          0
          • PerdrixP Perdrix

            @SGaist Qt 6.10, macOS Tahoe 26.3.1.
            @Kent-Dorfman AFAIK, and I could be wrong, QMessageBox::exec() runs it own local event loop.

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote last edited by
            #5

            @Perdrix QMessageBox::exec() does run its own event loop, but your call to deleteRemainingTempFiles is after the creation of Q(Core)Application?


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            1 Reply Last reply
            0
            • PerdrixP Offline
              PerdrixP Offline
              Perdrix
              wrote last edited by Perdrix
              #6

              @J.Hilk Yes, most certainly. QCoreApplication instance is created over a 100 lines earlier.
              app.exec() is called immediately after mainWindow.show().

              The main window is fully displayed while that dialog is running. So it almost seems that the dlg operates asynchronously.

              1 Reply Last reply
              0
              • PerdrixP Offline
                PerdrixP Offline
                Perdrix
                wrote last edited by
                #7

                Hmmm Should I set that QMessageBox to be "application modal"?

                Kent-DorfmanK 1 Reply Last reply
                0
                • PerdrixP Offline
                  PerdrixP Offline
                  Perdrix
                  wrote last edited by
                  #8

                  Hmmm I can't recreate the problem - I was running under the debugger at the time I hit it. Perhaps that might explain it.

                  1 Reply Last reply
                  0
                  • PerdrixP Perdrix

                    Hmmm Should I set that QMessageBox to be "application modal"?

                    Kent-DorfmanK Offline
                    Kent-DorfmanK Offline
                    Kent-Dorfman
                    wrote last edited by
                    #9

                    @Perdrix said in Application hung after dialog opened during startup on macOS:

                    Hmmm Should I set that QMessageBox to be "application modal"?

                    @Perdrix As I understand your flow, yes, the dialog should be modal since it is first and exclusive before doing mainwindow processing.

                    The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved