VirtualBox

Changeset 95665 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Jul 15, 2022 3:50:58 PM (3 years ago)
Author:
vboxsync
Message:

Recording/Main: Fixed a file sharing violation when closing recorded WebM files, which don't contain any clusters and thus getting deleted again. This needs to be done by the recording stream and not in the WebM writer class, as the WebM writer only inherited the file handle. ​bugref:9286

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/WebMWriter.h

    r93115 r95665  
    553553    uint64_t GetAvailableSpace(void);
    554554
     555    /**
     556     * Returns the number of written WebM clusters.
     557     *
     558     * @returns Number of written WebM clusters; 0 when no clusters written (empty file).
     559     */
     560    uint64_t GetClusters(void) const { return CurSeg.cClusters; }
     561
    555562protected:
    556563
  • trunk/src/VBox/Main/src-client/RecordingStream.cpp

    r94966 r95665  
    800800            vrc = File.pWEBM->OpenEx(pszFile, &this->File.hFile,
    801801#ifdef VBOX_WITH_AUDIO_RECORDING
    802                                     fAudioEnabled ? WebMWriter::AudioCodec_Opus : WebMWriter::AudioCodec_None,
     802                                     fAudioEnabled ? WebMWriter::AudioCodec_Opus : WebMWriter::AudioCodec_None,
    803803#else
    804                                     WebMWriter::AudioCodec_None,
    805 #endif
    806                                     fVideoEnabled ? WebMWriter::VideoCodec_VP8 : WebMWriter::VideoCodec_None);
     804                                     WebMWriter::AudioCodec_None,
     805#endif
     806                                     fVideoEnabled ? WebMWriter::VideoCodec_VP8 : WebMWriter::VideoCodec_None);
    807807            if (RT_FAILURE(vrc))
    808808            {
     
    941941            }
    942942
    943             if (this->File.pWEBM)
    944             {
    945                 delete this->File.pWEBM;
     943            WebMWriter *pWebMWriter = this->File.pWEBM;
     944            AssertPtr(pWebMWriter);
     945
     946            if (pWebMWriter)
     947            {
     948                /* If no clusters (= data) was written, delete the file again. */
     949                if (pWebMWriter->GetClusters() == 0)
     950                {
     951                    int vrc2 = RTFileDelete(this->ScreenSettings.File.strName.c_str());
     952                    AssertRC(vrc2); /* Ignore rc on non-debug builds. */
     953                }
     954
     955                delete pWebMWriter;
     956                pWebMWriter = NULL;
     957
    946958                this->File.pWEBM = NULL;
    947959            }
  • trunk/src/VBox/Main/src-client/WebMWriter.cpp

    r94962 r95665  
    151151    close();
    152152
    153     int vrc = VINF_SUCCESS;
    154 
    155     /* If no clusters (= data) was written, delete the file again. */
    156     if (!CurSeg.cClusters)
    157         vrc = RTFileDelete(strFileName.c_str());
    158 
    159     LogFlowFuncLeaveRC(vrc);
    160     return vrc;
     153    return VINF_SUCCESS;
    161154}
    162155
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette