Skip to content

Commit

Permalink
TIL: Truncate doesn't truncate if nothing is written
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Dec 27, 2024
1 parent 7bed9b1 commit 2dc78ad
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/core/positioning/positioningsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@ void PositioningSource::setBackgroundMode( bool backgroundMode )

if ( mBackgroundMode )
{
QFile file( QStringLiteral( "%1.information" ).arg( backgroundFilePath ) );
file.open( QFile::Truncate );
file.close();
if ( QFile::exists( QStringLiteral( "%1.information" ).arg( backgroundFilePath ) ) )
{
// Remove previously collected position information
QFile::remove( QStringLiteral( "%1.information" ).arg( backgroundFilePath ) );
}
}

emit backgroundModeChanged();
Expand Down

0 comments on commit 2dc78ad

Please sign in to comment.