Skip to content

Commit

Permalink
- NSM open and save operation failures are now replied with an
Browse files Browse the repository at this point in the history
  error status (was always OK before). (EXPERIMENTAL)
  • Loading branch information
rncbc committed Feb 12, 2023
1 parent 761fdd5 commit d5a6e14
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 16 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ ChangeLog

GIT HEAD

- NSM open and save operation failures are now replied with an
error status (was always OK before). (EXPERIMENTAL)
- JACK client watchdog introduced for automatic reactivation and
resilience (standalone only). (EXPERIMENTAL)
- NSM announcement reply/error messages now relegated to debug
Expand Down
17 changes: 12 additions & 5 deletions src/drumkv1_jack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1087,19 +1087,23 @@ void drumkv1_jack_application::openSession (void)
if (!dir.exists())
dir.mkpath(path_name);

bool bOpen = false;

QFileInfo fi(path_name, "session." DRUMKV1_TITLE);
if (!fi.exists())
fi.setFile(path_name, display_name + '.' + DRUMKV1_TITLE);
if (fi.exists()) {
const QString& sFilename = fi.absoluteFilePath();
if (m_pWidget) {
m_pWidget->loadPreset(sFilename);
bOpen = m_pWidget->loadPreset(sFilename);
} else {
drumkv1_param::loadPreset(m_pDrumk, sFilename);
bOpen = drumkv1_param::loadPreset(m_pDrumk, sFilename);
}
}

m_pNsmClient->open_reply();
m_pNsmClient->open_reply(bOpen
? drumkv1_nsm::ERR_OK
: drumkv1_nsm::ERR_GENERAL);
m_pNsmClient->dirty(false);

if (m_pWidget)
Expand Down Expand Up @@ -1127,9 +1131,12 @@ void drumkv1_jack_application::saveSession (void)
// const QFileInfo fi(path_name, display_name + '.' + DRUMKV1_TITLE);
const QFileInfo fi(path_name, "session." DRUMKV1_TITLE);

drumkv1_param::savePreset(m_pDrumk, fi.absoluteFilePath(), true);
const bool bSave
= drumkv1_param::savePreset(m_pDrumk, fi.absoluteFilePath(), true);

m_pNsmClient->save_reply();
m_pNsmClient->save_reply(bSave
? drumkv1_nsm::ERR_OK
: drumkv1_nsm::ERR_GENERAL);
m_pNsmClient->dirty(false);
}

Expand Down
30 changes: 21 additions & 9 deletions src/drumkv1widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ void drumkv1widget::newPreset (void)


// Preset file I/O slots.
void drumkv1widget::loadPreset ( const QString& sFilename )
bool drumkv1widget::loadPreset ( const QString& sFilename )
{
#ifdef CONFIG_DEBUG
qDebug("drumkv1widget::loadPreset(\"%s\")", sFilename.toUtf8().constData());
Expand All @@ -1094,29 +1094,41 @@ void drumkv1widget::loadPreset ( const QString& sFilename )
resetParamKnobs(drumkv1::NUM_PARAMS);
resetParamValues(drumkv1::NUM_PARAMS);

bool bLoad = false;

drumkv1_ui *pDrumkUi = ui_instance();
if (pDrumkUi)
pDrumkUi->loadPreset(sFilename);
bLoad = pDrumkUi->loadPreset(sFilename);

if (bLoad)
updateLoadPreset(QFileInfo(sFilename).completeBaseName());
else
updateDirtyPreset(true);

updateLoadPreset(QFileInfo(sFilename).completeBaseName());
return bLoad;
}


void drumkv1widget::savePreset ( const QString& sFilename )
bool drumkv1widget::savePreset ( const QString& sFilename )
{
#ifdef CONFIG_DEBUG
qDebug("drumkv1widget::savePreset(\"%s\")", sFilename.toUtf8().constData());
#endif

bool bSave = false;

drumkv1_ui *pDrumkUi = ui_instance();
if (pDrumkUi)
pDrumkUi->savePreset(sFilename);
bSave = pDrumkUi->savePreset(sFilename);

const QString& sPreset
= QFileInfo(sFilename).completeBaseName();
if (bSave) {
const QString& sPreset
= QFileInfo(sFilename).completeBaseName();
m_ui.StatusBar->showMessage(tr("Save preset: %1").arg(sPreset), 5000);
}
updateDirtyPreset(!bSave);

m_ui.StatusBar->showMessage(tr("Save preset: %1").arg(sPreset), 5000);
updateDirtyPreset(false);
return bSave;
}


Expand Down
4 changes: 2 additions & 2 deletions src/drumkv1widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ class drumkv1widget : public QWidget
public slots:

// Preset file I/O.
void loadPreset(const QString& sFilename);
void savePreset(const QString& sFilename);
bool loadPreset(const QString& sFilename);
bool savePreset(const QString& sFilename);

// Direct note-on/off slot.
void directNoteOn(int iNote, int iVelocity);
Expand Down

0 comments on commit d5a6e14

Please sign in to comment.