Suppress message about absolute measurement path

Issue #504 resolved
Holger Pandel created an issue

I get the attached message very often during loading, saving, re-calculating measurements or even resizing the view. Is there any possibility to suppress it?

Comments (20)

  1. Roman Telezhynskyi repo owner

    Please, post an example pattern file and measurement file. I never get this warning.

  2. Holger Pandel reporter

    Oh, I thought the message is of any special interest for you, that's why I posted this issue...

    It seems to have something to do with the whole file path and name and how QFileInfo deals with it (I searched the source to find the origin of the message). I had some language specific characters and space characters within the names at first. Now I eliminated the use of those characters and the message nearly disappeared completely.

    I'll check on another PC (with another OS) first. If it still happens I'll post an example...

  3. Roman Telezhynskyi repo owner

    I asked for example because i have a theory why this happening. You file will quickly prove it or deny it.

  4. Roman Telezhynskyi repo owner

    This message come from this method.

    QString AbsoluteMPath(const QString &patternPath, const QString &relativeMPath)
    {
        if (patternPath.isEmpty() || relativeMPath.isEmpty())
        {
            return relativeMPath;
        }
    
        if (QFileInfo(relativeMPath).isAbsolute())
        {
            qWarning() << QApplication::tr("The path to the measurments is already absolute.");
            return relativeMPath;
        }
    
        return QFileInfo(QFileInfo(patternPath).absoluteDir(), relativeMPath).absoluteFilePath();
    }
    

    Why this happens? I think because in your pattern file the path to measurements is absolute somehow, but the program expect a relative path.

    Can you post here string from your pattern file? Something like this.

    <measurements>../../../../../src/app/valentina/bin/tables/standard/GOST_man_ru.vst</measurements>
    
  5. Holger Pandel reporter

    You are right, the path has been absolute before in the pattern file and because of that, it was one of the first things I changed to see if this helps. But I felt that this wasn't the solution and that's why I also changed the characters used for the file names.

    Currently, the entry is as follows (both files are in the same folder):

    <measurements>Holger.vit</measurements>
    

    I still have to try on another PC how it works, just to be sure...

    But generelly, do you think that this warning is really necessary (I thought about simply commenting it out) ? Convert the path or, if it is ok, leave it as it is - no message needed ;)

  6. Roman Telezhynskyi repo owner

    But generelly, do you think that this warning is really necessary (I thought about simply commenting it out) ? Convert the path or, if it is ok, leave it as it is - no message needed ;)

    First of all i want to see a string that trigger the message before to do something. If it is not an absolute path we should submit a bug report to Qt team.

    We should left a warning because according to a pattern format a path should be relative. Yes, absolute path will also work. But relative path has more flexibility, the main reason why we moved to relative path in the end.

  7. Holger Pandel reporter

    Ok. I modified both path related functions (just to be sure) as follows (sorry for the .noquote(), but quotes in general look disgusting in a dialog box, don't know why QDebug is doing this by default):

    //---------------------------------------------------------------------------------------------------------------------
    QString RelativeMPath(const QString &patternPath, const QString &absoluteMPath)
    {
        if (patternPath.isEmpty() || absoluteMPath.isEmpty())
        {
            return absoluteMPath;
        }
    
        if (QFileInfo(absoluteMPath).isRelative())
        {
            qWarning().noquote() << QApplication::tr("The path to the measurements is already relative:\n\n") << absoluteMPath;
            return absoluteMPath;
        }
    
        return QFileInfo(patternPath).absoluteDir().relativeFilePath(absoluteMPath);
    }
    
    //---------------------------------------------------------------------------------------------------------------------
    QString AbsoluteMPath(const QString &patternPath, const QString &relativeMPath)
    {
        if (patternPath.isEmpty() || relativeMPath.isEmpty())
        {
            return relativeMPath;
        }
    
        if (QFileInfo(relativeMPath).isAbsolute())
        {
            qWarning().noquote() << QApplication::tr("The path to the measurements is already absolute:\n\n") << relativeMPath;
            return relativeMPath;
        }
    
        return QFileInfo(QFileInfo(patternPath).absoluteDir(), relativeMPath).absoluteFilePath();
    }
    

    Sadly, I'm no C++ dev (I develop under Python+Qt), but I wanted to see what is going on when the message comes up. I'm at work at the moment and the PC where the message comes up all the time is not here. I'll check that and also have a look on the installed Qt version.

  8. Holger Pandel reporter

    I don't really know why, but the message seems to have disappeared completely...

    What I did, was made my changes to def.cpp, recompile everything, remove the older install and any additional Valentina-related infos from my machine (every directory, registry entry, and such), packed it with my new installer script and installed it regularly again. But now, I don't get the message again.

    So I think, we can mark it as "closed". When it ever comes back, I'll try to investigate myself before opening any further support request... Sorry for that!

  9. Holger Pandel reporter

    Hey Roman!

    Sadly, I have to ask you to re-open this issue. The dialog suddenly appears again, even if I only i.e. change from draw mode to detail mode, open table of variables, etc. I modified both path functions again and made a screenshot:

    Error Valentina.jpg

    The corresponding line in the pattern file is

    <measurements>Holger.vit</measurements>
    

    My Qt version is 5.5.1 at the moment.

    Regards, Holger

  10. Roman Telezhynskyi repo owner

    Ok, i will change level to debug. Or maybe even better, will show warnings only in the Debug mode.

  11. Holger Pandel reporter

    Ok. The last thing I'll try is to use the current Qt 5.7.0 version to see if that changes anything. I'll post my results...

  12. Roman Telezhynskyi repo owner

    Resolved issue #504. Suppress message about absolute measurement path.

    I decided to completely eliminate warning strings because they do not change anything.

    → <<cset 42f91d940da6>>

  13. Log in to comment