From 45fc5b7d969a6bb102bb0dbb0fea69d2a821f834 Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 6 Jan 2020 18:16:29 +0000 Subject: [PATCH] Don't allow NSM without project, be clear when NSM cant be used Signed-off-by: falkTX --- resources/ui/carla_add_jack.ui | 74 +++++++++++++++++-- source/backend/CarlaBackend.h | 2 +- source/backend/CarlaStandalone.cpp | 2 +- source/backend/engine/CarlaEngine.cpp | 2 +- source/frontend/carla_backend.py | 2 +- source/frontend/carla_database.cpp | 37 ++++++++-- source/frontend/carla_database.hpp | 2 +- source/frontend/carla_database.py | 26 +++++-- source/frontend/carla_host.cpp | 2 +- source/frontend/carla_host.py | 4 +- source/frontend/carla_widgets.py | 2 +- .../water/processors/AudioProcessorGraph.cpp | 4 +- 12 files changed, 130 insertions(+), 29 deletions(-) diff --git a/resources/ui/carla_add_jack.ui b/resources/ui/carla_add_jack.ui index 1eb8bc5f0..3da4c5570 100644 --- a/resources/ui/carla_add_jack.ui +++ b/resources/ui/carla_add_jack.ui @@ -6,8 +6,8 @@ 0 0 - 487 - 572 + 458 + 546 @@ -15,7 +15,7 @@ - + Note: Features not implemented yet are greyed out @@ -54,7 +54,14 @@ - + + + + 0 + 0 + + + @@ -468,7 +475,7 @@ - + Workarounds @@ -536,6 +543,63 @@ + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + 16 + 16 + + + + + 16 + 16 + + + + + + + :/16x16/dialog-cancel.svgz + + + true + + + + + + + Error here + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + diff --git a/source/backend/CarlaBackend.h b/source/backend/CarlaBackend.h index 3cf51f486..b8b070d60 100644 --- a/source/backend/CarlaBackend.h +++ b/source/backend/CarlaBackend.h @@ -1,6 +1,6 @@ /* * Carla Plugin Host - * Copyright (C) 2011-2019 Filipe Coelho + * Copyright (C) 2011-2020 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/source/backend/CarlaStandalone.cpp b/source/backend/CarlaStandalone.cpp index 10828b80c..281c6f1d3 100644 --- a/source/backend/CarlaStandalone.cpp +++ b/source/backend/CarlaStandalone.cpp @@ -1,6 +1,6 @@ /* * Carla Standalone - * Copyright (C) 2011-2019 Filipe Coelho + * Copyright (C) 2011-2020 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/source/backend/engine/CarlaEngine.cpp b/source/backend/engine/CarlaEngine.cpp index 4edc6d3ed..15c6677bd 100644 --- a/source/backend/engine/CarlaEngine.cpp +++ b/source/backend/engine/CarlaEngine.cpp @@ -1,6 +1,6 @@ /* * Carla Plugin Host - * Copyright (C) 2011-2019 Filipe Coelho + * Copyright (C) 2011-2020 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/source/frontend/carla_backend.py b/source/frontend/carla_backend.py index fcc5a6fbd..981ef5dd6 100644 --- a/source/frontend/carla_backend.py +++ b/source/frontend/carla_backend.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # Carla Backend code -# Copyright (C) 2011-2019 Filipe Coelho +# Copyright (C) 2011-2020 Filipe Coelho # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as diff --git a/source/frontend/carla_database.cpp b/source/frontend/carla_database.cpp index dde8712fb..913451444 100644 --- a/source/frontend/carla_database.cpp +++ b/source/frontend/carla_database.cpp @@ -1,6 +1,6 @@ /* * Carla plugin database code - * Copyright (C) 2011-2019 Filipe Coelho + * Copyright (C) 2011-2020 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -326,11 +326,16 @@ enum UiSessionManager { struct JackApplicationW::PrivateData { Ui::Dialog ui; - PrivateData(JackApplicationW* const dialog) - : ui() + const QString fProjectFilename; + + PrivateData(JackApplicationW* const dialog, const QString& projectFilename) + : ui(), + fProjectFilename(projectFilename) { ui.setupUi(dialog); + ui.group_error->setVisible(false); + // ------------------------------------------------------------------------------------------------------------ // Load settings @@ -342,10 +347,29 @@ struct JackApplicationW::PrivateData { static QList badFirstChars = { '.', '/' }; bool enabled = text.length() > 0; + QCarlaString showErr; // NSM applications must not be abstract or absolute paths, and must not contain arguments if (enabled && index == UI_SESSION_NSM) - enabled = ! (badFirstChars.contains(text[0]) || text.contains(' ')); + { + if (badFirstChars.contains(text[0])) + showErr = tr("NSM applications cannot use abstract or absolute paths"); + else if (text.contains(' ') || text.contains(';') || text.contains('&')) + showErr = tr("NSM applications cannot use CLI arguments"); + else if (fProjectFilename.isEmpty()) + showErr = tr("You need to save the current Carla project before NSM can be used"); + } + + if (showErr.isNotEmpty()) + { + enabled = false; + ui.l_error->setText(showErr); + ui.group_error->setVisible(true); + } + else + { + ui.group_error->setVisible(false); + } if (QPushButton* const button = ui.buttonBox->button(QDialogButtonBox::Ok)) button->setEnabled(enabled); @@ -396,10 +420,11 @@ struct JackApplicationW::PrivateData { CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PrivateData) }; -JackApplicationW::JackApplicationW(QWidget* parent) +JackApplicationW::JackApplicationW(QWidget* parent, const QString& projectFilename) : QDialog(parent), - self(new PrivateData(this)) + self(new PrivateData(this, projectFilename)) { + adjustSize(); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); // ---------------------------------------------------------------------------------------------------------------- diff --git a/source/frontend/carla_database.hpp b/source/frontend/carla_database.hpp index 1052894c8..cfa2632b2 100644 --- a/source/frontend/carla_database.hpp +++ b/source/frontend/carla_database.hpp @@ -139,7 +139,7 @@ class JackApplicationW : public QDialog Q_OBJECT public: - JackApplicationW(QWidget* parent); + JackApplicationW(QWidget* parent, const QString& projectFilename); ~JackApplicationW() override; void getCommandAndFlags(QString& command, QString& name, QString& labelSetup); diff --git a/source/frontend/carla_database.py b/source/frontend/carla_database.py index 01076a9b3..9d4837d40 100755 --- a/source/frontend/carla_database.py +++ b/source/frontend/carla_database.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # Carla plugin database code -# Copyright (C) 2011-2019 Filipe Coelho +# Copyright (C) 2011-2020 Filipe Coelho # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -2112,16 +2112,15 @@ class JackApplicationW(QDialog): FLAG_MIDI_OUTPUT_CHANNEL_MIXDOWN = 0x20 FLAG_EXTERNAL_START = 0x40 - def __init__(self, parent, host): + def __init__(self, parent, projectFilename): QDialog.__init__(self, parent) - self.host = host self.ui = ui_carla_add_jack.Ui_Dialog() self.ui.setupUi(self) - if False: - # kdevelop likes this :) - self.host = host = CarlaHostNull() + self.fProjectFilename = projectFilename + self.ui.group_error.setVisible(False) + self.adjustSize() self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) # -------------------------------------------------------------------------------------------------------------- @@ -2175,10 +2174,23 @@ class JackApplicationW(QDialog): def checkIfButtonBoxShouldBeEnabled(self, index, text): enabled = len(text) > 0 + showErr = "" # NSM applications must not be abstract or absolute paths, and must not contain arguments if enabled and index == self.UI_SESSION_NSM: - enabled = text[0] not in (".", "/") and " " not in text + if text[0] in (".", "/"): + showErr = self.tr("NSM applications cannot use abstract or absolute paths") + elif " " in text or ";" in text or "&" in text: + showErr = self.tr("NSM applications cannot use CLI arguments") + elif len(self.fProjectFilename) == 0: + showErr = self.tr("You need to save the current Carla project before NSM can be used") + + if showErr: + enabled = False + self.ui.l_error.setText(showErr) + self.ui.group_error.setVisible(True) + else: + self.ui.group_error.setVisible(False) self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled) diff --git a/source/frontend/carla_host.cpp b/source/frontend/carla_host.cpp index 137dbe4fb..7ff103455 100644 --- a/source/frontend/carla_host.cpp +++ b/source/frontend/carla_host.cpp @@ -1,6 +1,6 @@ /* * Carla plugin host - * Copyright (C) 2011-2019 Filipe Coelho + * Copyright (C) 2011-2020 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/source/frontend/carla_host.py b/source/frontend/carla_host.py index 0f5eb717f..d4c27da56 100644 --- a/source/frontend/carla_host.py +++ b/source/frontend/carla_host.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # Carla host code -# Copyright (C) 2011-2019 Filipe Coelho +# Copyright (C) 2011-2020 Filipe Coelho # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -1099,7 +1099,7 @@ class HostWindow(QMainWindow): return (btype, ptype, filename, label, uniqueId, extraPtr) def showAddJackAppDialog(self): - dialog = JackApplicationW(self.fParentOrSelf, self.host) + dialog = JackApplicationW(self.fParentOrSelf, self.fProjectFilename) if not dialog.exec_(): return diff --git a/source/frontend/carla_widgets.py b/source/frontend/carla_widgets.py index 74dc6b3bf..78c18f31f 100755 --- a/source/frontend/carla_widgets.py +++ b/source/frontend/carla_widgets.py @@ -68,7 +68,7 @@ class CarlaAboutW(QDialog): self.ui.l_about.setText(self.tr("" "
Version %s" "
Carla is a fully-featured audio plugin host%s.
" - "
Copyright (C) 2011-2019 falkTX
" + "
Copyright (C) 2011-2020 falkTX
" "" % (VERSION, extraInfo))) if self.ui.about.palette().color(QPalette.Background).blackF() < 0.5: diff --git a/source/modules/water/processors/AudioProcessorGraph.cpp b/source/modules/water/processors/AudioProcessorGraph.cpp index 745bce203..9d4797202 100644 --- a/source/modules/water/processors/AudioProcessorGraph.cpp +++ b/source/modules/water/processors/AudioProcessorGraph.cpp @@ -3,7 +3,7 @@ This file is part of the Water library. Copyright (c) 2015 ROLI Ltd. - Copyright (C) 2017-2018 Filipe Coelho + Copyright (C) 2017-2020 Filipe Coelho Permission is granted to use this software under the terms of the GNU General Public License as published by the Free Software Foundation; @@ -1121,11 +1121,11 @@ void AudioProcessorGraph::Node::prepare (const double newSampleRate, const int n { if (! isPrepared) { - isPrepared = true; setParentGraph (graph); processor->setRateAndBufferSizeDetails (newSampleRate, newBlockSize); processor->prepareToPlay (newSampleRate, newBlockSize); + isPrepared = true; } }