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. Question about releasing an application to Mac OSX.
Forum Updated to NodeBB v4.3 + New Features

Question about releasing an application to Mac OSX.

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 5 Posters 3.0k 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.
  • V Offline
    V Offline
    VRHans
    wrote on last edited by
    #2

    When you say "wrong filename" do you mean you get the name of a different file? Or, do you mean that the filename is corrupted?

    CarLoowwwwC 1 Reply Last reply
    0
    • V VRHans

      When you say "wrong filename" do you mean you get the name of a different file? Or, do you mean that the filename is corrupted?

      CarLoowwwwC Offline
      CarLoowwwwC Offline
      CarLoowwww
      wrote on last edited by
      #3

      @VRHans ok i figured out what exactly is happening. The problem is in the recent file opening, im saving the recent file list to the Qsettings,but since i thought it came from the Qsettings i changed it to rcpath.bin(Textfile),but it is still happening. Yeah, all are working fine in 10.11 (MAC OSX). but when i ran it on 10.10 and open a sample file the file will be putted in the list after that i opened another file after path as usual it will be putted on the open recent file. But when i close the application, open it again and open a file again, it displaying the wrong list probably something like cache or history, i dont know.But when i look at the textfile that i written it displaying the correct list.

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

        Hi,

        Can you show what you are expecting and what your are currently getting ?

        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
        • CarLoowwwwC Offline
          CarLoowwwwC Offline
          CarLoowwww
          wrote on last edited by CarLoowwww
          #5

          @SGaist Ok for example i opened 3 files. path/cube.stl,path/pyramid.stl,path/sphere.stl. So this three will be putted on my open recently list which is the .plist.

          This should be the output from my open recent menu.
          path/cube.stl
          path/pyramid.stl
          path/sphere.stl

          After i closed my application on mac 10.10 and opened it again. I noticed a changes. First of all the font size of my menu inside open recent get smaller. And next if i opened a file again let say the path/roof.stl so my open recent menu should look like this.

          This should be the output from my open recent menu.
          path/roof.stl
          path/cube.stl
          path/pyramid.stl
          path/sphere.stl

          But the 10.10 returned me this open recent menu(I looked at the .plist file where im retrieving my list for Open recent, and the .plist is listing the correct list.).
          path/roof.stl --> path/filename.stl(something that i opened before)
          path/cube.stl
          path/cube.stl // duplicate items even if i have a code that will remove duplicate paths.
          path/sphere.stl
          path/roof.stl ->> this should be the one that i added since the font size of this menu is bigger than the others. but it also return the wrong filename, some file that i opened before.

          I dont know what is happening, i know that there are no errors on my code since all of this is working well on mac 10.11.

          Another question. Do you think there are some possibilities that the bug occured because i build the application using the MAC 10.11?

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

            Can you share the code you use to handle that ?

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

            CarLoowwwwC 1 Reply Last reply
            0
            • SGaistS SGaist

              Can you share the code you use to handle that ?

              CarLoowwwwC Offline
              CarLoowwwwC Offline
              CarLoowwww
              wrote on last edited by
              #7

              @SGaist

              void MainWindow::UpdateRecentOpenFile(QString strPath){ // this is for updating the list

              QSettings settings("XYZmaker","XYZmaker");
              settings.beginGroup("RecentFiles");
              QStringList files = settings.value("recentFileList").toStringList();
              files.removeAll(strPath);
              files.prepend(strPath);
              while(files.size() > 10)
                  files.removeLast();   
              
              //settings.remove("recentFileList");
              settings.setValue("recentFileList",files);
              settings.endGroup();
              LoadRecentOpenFile();
              

              }

              void MainWindow::LoadRecentOpenFile()
              {
                  QSettings settings("XYZmaker","XYZmaker");
                  settings.beginGroup("RecentFiles");
                  QStringList files = settings.value("recentFileList").toStringList();
                  QStringList nonExistingFile;
                  enum { MaxRecentFiles = 11 };
                  QAction *recentFileActs[MaxRecentFiles];
                  int numRecentFiles = qMin(files.size(),(int)MaxRecentFiles);
                  for(int i = 0; i < numRecentFiles ; ++i)
                  {
                      QFile file(files[i]);
                      if (!file.exists()){
                         nonExistingFile.prepend(files[i]);
                      }
                  }
                  for(int k = 0; k < nonExistingFile.size(); k++){
                      files.removeAll(nonExistingFile[k]);
                  }
                  settings.setValue("recentFileList",files);
                  files = settings.value("recentFileList").toStringList();
                  numRecentFiles = qMin(files.size(),(int)MaxRecentFiles);
                  settings.endGroup();
              
                  if(numRecentFiles > 0){
                      ui->menuOpen_Recent->setEnabled(true);
                      // recentFileActs[10]->setVisible(true);
                  }
                  else
                  {
                      ui->menuOpen_Recent->setEnabled(false);
                  }
                  recentFileActs[0] = ui->actionSM0;
                  recentFileActs[1] = ui->actionSM1;
                  recentFileActs[2] = ui->actionSM2;
                  recentFileActs[3] = ui->actionSM3;
                  recentFileActs[4] = ui->actionSM4;
              
                  recentFileActs[5] = ui->actionSM5;
                  recentFileActs[6] = ui->actionSM6;
                  recentFileActs[7] = ui->actionSM7;
                  recentFileActs[8] = ui->actionSM8;
                  recentFileActs[9] = ui->actionSM9;
                  recentFileActs[10] = ui->actionClear_Recent_Files;
              
              
                  for(int c = 0; c < numRecentFiles ; ++c)
                  {
                      QString text = tr("%1").arg(files[c]);
                      recentFileActs[c]->setVisible(true);
                      recentFileActs[c]->setText(text);
                      recentFileActs[c]->setToolTip(text);
                  }
                  for(int q = numRecentFiles; q < 10; ++q)
                      recentFileActs[q]->setVisible(false);
              
              }
              
              1 Reply Last reply
              0
              • jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #8

                Unrelated comment:

                while(files.size() > 10)
                    files.removeLast();
                

                is not efficient (especially if the list is big). You should do this instead:

                files = files.mid(0, 10)
                

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                CarLoowwwwC 1 Reply Last reply
                0
                • jsulmJ jsulm

                  Unrelated comment:

                  while(files.size() > 10)
                      files.removeLast();
                  

                  is not efficient (especially if the list is big). You should do this instead:

                  files = files.mid(0, 10)
                  
                  CarLoowwwwC Offline
                  CarLoowwwwC Offline
                  CarLoowwww
                  wrote on last edited by
                  #9

                  @jsulm i will try that one, but i think it will not affect the problem. Since when i look at the plist, it display the correct list of path, the only thing that i didnt know is why the open recent files is showing the wrong list even my source is correct.

                  1 Reply Last reply
                  0
                  • SeeLookS Offline
                    SeeLookS Offline
                    SeeLook
                    wrote on last edited by
                    #10

                    You might try to use ini format of settings:

                    QSettings settings(QSettings::IniFormat, QSettings::UserScope, "XYZmaker","XYZmaker");
                    

                    then it will be stored into:
                    /Users/someone/.config/XYZmarker/XYZmarker.ini

                    Probably it is more predictable way among different Mac Os versions.
                    Qt creator itself stores settings that way.

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

                      One thing I can see is that you are modifying your settings in one function and trying to access them directly from another function without flushing the content before.

                      By the way, that doesn't really make sense to update a recent file list like that. The list itself should rather be loaded at startup, modified "live" during the application activity and only stored when closing it.

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

                      CarLoowwwwC 1 Reply Last reply
                      0
                      • SGaistS SGaist

                        One thing I can see is that you are modifying your settings in one function and trying to access them directly from another function without flushing the content before.

                        By the way, that doesn't really make sense to update a recent file list like that. The list itself should rather be loaded at startup, modified "live" during the application activity and only stored when closing it.

                        CarLoowwwwC Offline
                        CarLoowwwwC Offline
                        CarLoowwww
                        wrote on last edited by
                        #12

                        @SGaist said:

                        By the way, that doesn't really make sense to update a recent file list like that. The list itself is loaded at startup, modified "live" during the application activity and only stored when closing it.

                        Are you referring to my code or to your first sentence?

                        Still wondering why and how i am going to solve it.

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

                          About your code.

                          About how to make it work: don't call LoadRecentOpenFile from UpdateRecentOpenFile. The changes you made to the settings object are not necessarily flushed immediately for your other QSettings object to grab. OS X uses a cache for its settings system that influences there.

                          Your handling of recent files looks a bit over engineered. Take for the Recent File Example. You have there a pretty simple handling of the recent files. There you can simply add a pair of read/writeSettings method that you will call e.g. from the constructor and the destructor to load and save the list of recent files.

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

                          CarLoowwwwC 1 Reply Last reply
                          1
                          • SGaistS SGaist

                            About your code.

                            About how to make it work: don't call LoadRecentOpenFile from UpdateRecentOpenFile. The changes you made to the settings object are not necessarily flushed immediately for your other QSettings object to grab. OS X uses a cache for its settings system that influences there.

                            Your handling of recent files looks a bit over engineered. Take for the Recent File Example. You have there a pretty simple handling of the recent files. There you can simply add a pair of read/writeSettings method that you will call e.g. from the constructor and the destructor to load and save the list of recent files.

                            CarLoowwwwC Offline
                            CarLoowwwwC Offline
                            CarLoowwww
                            wrote on last edited by
                            #14

                            @SGaist It solved the bug. Thank you.

                            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