[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwrite-devel
Subject:    Re: [Bug 68248] improve cooperation with cvs (too many warnings
From:       Andras Mantia <amantia () freemail ! hu>
Date:       2004-03-11 18:11:49
Message-ID: 20040311181128.225D0197E0 () smtp ! zappmobile ! ro
[Download RAW message or body]

I saw this bug, so here is my comment. ;-) In Quanta I verify with a simple
comparsion if the file has really changed or not. Helped a lot to reduce
false warnings (many of them occurred with NFS). The code is:

      //check if the file is changed, also by file content. Might help to
reduce
      //unwanted warning on NFS
      QFile f(fileName); //the original file
      QFile tmpFile(m_tempFileName); //we save every file to a temporary
place on opening (and update the temp file on saving as well)
      if (f.open(IO_ReadOnly) && tmpFile.open(IO_ReadOnly))
      {
        QString encoding =
dynamic_cast<KTextEditor::EncodingInterface*>(m_doc)->encoding(); //the
encoding of the opened document
        QString content;
        QTextStream stream(&f);
        stream.setCodec(QTextCodec::codecForName(encoding));
        content = stream.read();
        QString tmpContent;
        QTextStream tmpStream(&tmpFile);
        tmpStream.setCodec(QTextCodec::codecForName(encoding));
        tmpContent = tmpStream.read();
        if (content == tmpContent)
        {
          m_dirty = false;
        }
        f.close();
      }

MD5 checking might be more elegant (you don't need the temp file), but this
does the job and is fairly easy to implement.
_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic