Question about releasing an application to Mac OSX.



  • Hello guys we released an application in mac platform and we used Qt5.5 and built it with MAC OS 10.11. All are working good on MAC OS 10.11 but if we run the application in 10.10 there some bugs even if we know that the there is no problem with the source code? Can someone help me or what do i need to make it work in other version especially in 10.10.

    Example bug is when i open the file, the application return the wrong filename and it is opening the wrong file.

    Sorry for my bad english.



  • 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?



  • @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.


  • Lifetime Qt Champion

    Hi,

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



  • @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?


  • Lifetime Qt Champion

    Can you share the code you use to handle that ?



  • @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);
    
    }
    

  • Moderators

    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)
    


  • @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.



  • 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.


  • Lifetime Qt Champion

    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.



  • @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.


  • Lifetime Qt Champion

    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.



  • @SGaist It solved the bug. Thank you.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.