Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::controllers::ProjectSaver Class Reference

Handles saving of Zrythm projects to disk. More...

#include <src/controllers/project_saver.h>

Static Public Member Functions

static QFuture< QString > save (const structure::project::Project &project, const structure::project::ProjectUiState &ui_state, const undo::UndoStack &undo_stack, utils::Version app_version, const fs::path &path, bool is_backup)
 Saves the project asynchronously to the specified directory.
static int autosave_cb (void *data)
 Autosave callback.
static void make_project_dirs (const fs::path &project_directory)
 Creates the project directories.
static void compress_or_decompress (bool compress, char **_dest, size_t *_dest_size, const QByteArray &src)
 Compresses or decompresses project data using zstd.
static void compress (char **_dest, size_t *_dest_size, const QByteArray &src)
static void decompress (char **_dest, size_t *_dest_size, const QByteArray &src)
static std::string get_existing_uncompressed_text (const fs::path &project_dir)
 Returns the uncompressed text representation of the saved project file.

Detailed Description

Handles saving of Zrythm projects to disk.

This class provides static methods for project saving operations.

Definition at line 35 of file project_saver.h.

Member Function Documentation

◆ autosave_cb()

int zrythm::controllers::ProjectSaver::autosave_cb ( void * data)
static

Autosave callback.

This will keep getting called at regular short intervals, and if enough time has passed and it's okay to save it will autosave, otherwise it will wait until the next interval and check again.

◆ compress()

void zrythm::controllers::ProjectSaver::compress ( char ** _dest,
size_t * _dest_size,
const QByteArray & src )
inlinestatic

Definition at line 102 of file project_saver.h.

◆ compress_or_decompress()

void zrythm::controllers::ProjectSaver::compress_or_decompress ( bool compress,
char ** _dest,
size_t * _dest_size,
const QByteArray & src )
static

Compresses or decompresses project data using zstd.

Parameters
compressTrue to compress, false to decompress.
[out]_destPointer to a location to allocate memory.
[out]_dest_sizePointer to a location to store the size of the allocated memory.
srcInput bytes to compress/decompress.
Exceptions
ZrythmExceptionIf the compression/decompression fails.

◆ decompress()

void zrythm::controllers::ProjectSaver::decompress ( char ** _dest,
size_t * _dest_size,
const QByteArray & src )
inlinestatic

Definition at line 108 of file project_saver.h.

◆ get_existing_uncompressed_text()

std::string zrythm::controllers::ProjectSaver::get_existing_uncompressed_text ( const fs::path & project_dir)
static

Returns the uncompressed text representation of the saved project file.

Parameters
project_dirThe project directory.
Exceptions
ZrythmExceptionIf an error occurs.

◆ make_project_dirs()

void zrythm::controllers::ProjectSaver::make_project_dirs ( const fs::path & project_directory)
static

Creates the project directories.

Parameters
project_directoryThe root project directory.
Exceptions
ZrythmExceptionIf the directories cannot be created.

◆ save()

QFuture< QString > zrythm::controllers::ProjectSaver::save ( const structure::project::Project & project,
const structure::project::ProjectUiState & ui_state,
const undo::UndoStack & undo_stack,
utils::Version app_version,
const fs::path & path,
bool is_backup )
staticnodiscard

Saves the project asynchronously to the specified directory.

Parameters
projectThe core project data to save.
ui_stateThe UI state to save.
undo_stackThe undo history to save.
app_versionVersion of the application.
pathThe directory to save the project in (including the title).
is_backupTrue if this is a backup. Backups will be saved as <original filename>.bak<num>.
Returns
A QFuture that resolves to the project path on success.
Exceptions
ZrythmExceptionIf any step failed.
Warning
The returned QFuture uses continuations that run on the main thread. Do NOT call waitForFinished() on the main thread without processing Qt events, as this will cause a deadlock. Instead:
  • Use QFutureWatcher with signals/slots, or
  • Process events while waiting (e.g., QEventLoop), or
  • Wait from a non-main thread

The documentation for this class was generated from the following file: