Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-103301

QTextStream writes extra text at the end of a file

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • Not Evaluated
    • None
    • 6.3.0
    • Core: I/O
    • None
    • Windows, x64, Visual Studio 2022
    • Windows

    Description

      Running this file produces an extra double quote at the end.  I have other characters other than the single double quote.  The last line should not be present in the text file.

       

      Windows Registry Editor Version 5.00[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers]
      "C:\\Users\\Roger\\source\\repos\\Projects\\ImageViewers\\Tinta\\debug\\Tinta.exe"="RUNASADMIN"
      "
      

       

       

      QString writeRegistry()
      {
          const QDir writableQDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);    
      QString applicationPath     = QDir().toNativeSeparators(QCoreApplication::applicationDirPath());
      QString applicationFilePath = QCoreApplication::applicationFilePath();    
      QString registryLocation = writableQDir.absolutePath();    
      QString registryFileName = registryLocation + "/RegisterTinta.reg";    applicationFilePath.replace("/", "\\\\");    
      QFile file(registryFileName);
          if (file.open(QIODevice::ReadWrite))
          {
              QTextStream stream(&file);
              stream << "Windows Registry Editor Version 5.00\n\n";
              stream << "[HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers]\n";
              QString registryEntry = QString('"') + applicationFilePath + "\"=\"RUNASADMIN\"\n";        stream << registryEntry;        file.close();
              return registryFileName;
          }
          else
          {
              return {};
          }
      }
      

       

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            manordheim Mårten Nordheim
            doug_rogers Doug Rogers
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes