Skip to content

Commit

Permalink
[cleanup] Bring in a lot of changes I did on the Mac to reduce warnin…
Browse files Browse the repository at this point in the history
…gs. This is somewhat a bigger impact than I thought.
  • Loading branch information
christofmuc committed Jul 29, 2022
1 parent f72f63a commit 497aeb4
Show file tree
Hide file tree
Showing 33 changed files with 72 additions and 62 deletions.
6 changes: 4 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Checks:
+ '*'
- modernize-use-override
'+ *,
- modernize-use-nodiscard,
- modernize-use-override,
- modernize-return-braced-init-list'
CheckOptions:
- key: modernize-use-nullptr.NullMacros
value: NULL,CUSTOM_NULL
2 changes: 1 addition & 1 deletion MidiKraft-librarian
2 changes: 1 addition & 1 deletion The-Orm/AutoThumbnailingDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class AutoThumbnailingDialog : public ThreadWithProgressWindow, private ChangeListener {
public:
AutoThumbnailingDialog(PatchView &patchView, RecordingView &recordingView);
virtual ~AutoThumbnailingDialog();
virtual ~AutoThumbnailingDialog() override;

virtual void run() override;

Expand Down
6 changes: 3 additions & 3 deletions The-Orm/BCR2000_Component.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Synth;
class BCR2000_Component: public Component, public midikraft::BCR2000Proxy, private ChangeListener {
public:
BCR2000_Component(std::shared_ptr<midikraft::BCR2000> bcr);
virtual ~BCR2000_Component();
virtual ~BCR2000_Component() override;

virtual void resized() override;

Expand Down Expand Up @@ -62,7 +62,7 @@ class BCR2000_Component: public Component, public midikraft::BCR2000Proxy, priva
class UpdateSynthListener : public ValueTree::Listener {
public:
UpdateSynthListener(BCR2000_Component* papa);
~UpdateSynthListener();
virtual ~UpdateSynthListener() override;

void valueTreePropertyChanged(ValueTree& treeWhosePropertyHasChanged, const Identifier& property) override;
void listenForMidiMessages(MidiInput* source, MidiMessage message);
Expand All @@ -77,7 +77,7 @@ class BCR2000_Component: public Component, public midikraft::BCR2000Proxy, priva
class UpdateControllerListener : public ValueTree::Listener {
public:
UpdateControllerListener(BCR2000_Component* papa);
~UpdateControllerListener();
virtual ~UpdateControllerListener() override;

void listenForMidiMessages(MidiInput* source, MidiMessage message);
void valueTreePropertyChanged(ValueTree& treeWhosePropertyHasChanged, const Identifier& property) override;
Expand Down
2 changes: 1 addition & 1 deletion The-Orm/CurrentPatchDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CurrentPatchDisplay : public Component,
CurrentPatchDisplay(midikraft::PatchDatabase &database,
std::vector<CategoryButtons::Category> categories,
std::function<void(std::shared_ptr<midikraft::PatchHolder>)> favoriteHandler);
virtual ~CurrentPatchDisplay();
virtual ~CurrentPatchDisplay() override;

std::function<void(std::shared_ptr<midikraft::PatchHolder>)> onCurrentPatchClicked;

Expand Down
10 changes: 5 additions & 5 deletions The-Orm/EditCategoryDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,27 @@ class CategoryListModel: public ListBoxModel {
};


EditCategoryDialog::EditCategoryDialog(midikraft::PatchDatabase &database) : propsTree_("categoryTree")
EditCategoryDialog::EditCategoryDialog() : propsTree_("categoryTree")
{
//parameters_.setRowHeight(60);
parameters_ = std::make_unique<ListBox>();
addAndMakeVisible(*parameters_);

propsTree_.addListener(this);

add_.onClick = [this, &database]() {
add_.onClick = [this]() {
int nextID = nextId_++;
addCategory({ nextID, true, "New category", Colour::fromString("191926")});
//parameters_.setModel(new CategoryListModel(props_));
};
add_.setButtonText("Add new category");
addAndMakeVisible(add_);

ok_.onClick = [this]() { sWindow_->exitModalState(true); };
ok_.onClick = []() { sWindow_->exitModalState(true); };
ok_.setButtonText("Save");
addAndMakeVisible(ok_);

cancel_.onClick = [this]() { sWindow_->exitModalState(false); };
cancel_.onClick = []() { sWindow_->exitModalState(false); };
cancel_.setButtonText("Cancel");
addAndMakeVisible(cancel_);

Expand Down Expand Up @@ -163,7 +163,7 @@ static void dialogClosed(int modalResult, EditCategoryDialog* dialog)
void EditCategoryDialog::showEditDialog(midikraft::PatchDatabase &db, Component *centeredAround, TCallback callback)
{
if (!sEditCategoryDialog_) {
sEditCategoryDialog_= std::make_unique<EditCategoryDialog>(db);
sEditCategoryDialog_= std::make_unique<EditCategoryDialog>();
}
sCallback_ = callback;
sEditCategoryDialog_->nextId_ = db.getNextBitindex(); // This is where we'll continue, but the user could press cancel using none of the newly made IDs
Expand Down
2 changes: 1 addition & 1 deletion The-Orm/EditCategoryDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class EditCategoryDialog : public Component, private ValueTree::Listener {
public:
typedef std::function<void(std::vector < midikraft::CategoryDefinition> const &)> TCallback;
EditCategoryDialog(midikraft::PatchDatabase &database);
EditCategoryDialog();
virtual ~EditCategoryDialog() override;

virtual void resized() override;
Expand Down
2 changes: 1 addition & 1 deletion The-Orm/ElectraOneRouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void ElectraOneRouter::enable(bool enabled)
if (routerCallback_.isNull()) {
// Install handler
routerCallback_ = midikraft::MidiController::makeOneHandle();
midikraft::MidiController::instance()->addMessageHandler(routerCallback_, [this](MidiInput *source, MidiMessage const &message) {
midikraft::MidiController::instance()->addMessageHandler(routerCallback_, [](MidiInput *source, MidiMessage const &message) {
if (source->getName() == "Electra Controller") {
auto toWhichSynthToForward = UIModel::currentSynth();
if (toWhichSynthToForward) {
Expand Down
4 changes: 2 additions & 2 deletions The-Orm/ExportDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ ExportDialog::ExportDialog()
parameters_.setProperties(props_);
addAndMakeVisible(parameters_);

ok_.onClick = [this]() { sWindow_->exitModalState(true); };
ok_.onClick = []() { sWindow_->exitModalState(true); };
ok_.setButtonText("Export");
addAndMakeVisible(ok_);

cancel_.onClick = [this]() { sWindow_->exitModalState(false); };
cancel_.onClick = []() { sWindow_->exitModalState(false); };
cancel_.setButtonText("Cancel");
addAndMakeVisible(cancel_);

Expand Down
2 changes: 1 addition & 1 deletion The-Orm/ImportFromSynthDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ImportFromSynthDialog : public Component, private Button::Listener
typedef std::function<void(std::vector<MidiBankNumber> bankNo)> TSuccessHandler;

ImportFromSynthDialog(midikraft::Synth *synth, TSuccessHandler onOk);
virtual ~ImportFromSynthDialog() = default;
virtual ~ImportFromSynthDialog() override = default;

void resized() override;
void buttonClicked(Button*) override;
Expand Down
2 changes: 1 addition & 1 deletion The-Orm/KeyboardMacroView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class RecordProgress : public ThreadWithProgressWindow, private MidiKeyboardStat
{
}

virtual ~RecordProgress() {
virtual ~RecordProgress() override {
state_.removeListener(this);
}

Expand Down
2 changes: 1 addition & 1 deletion The-Orm/KeyboardMacroView.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class KeyboardMacroView : public Component, private ChangeListener, private Value::Listener {
public:
KeyboardMacroView(std::function<void(KeyboardMacroEvent)> callback);
virtual ~KeyboardMacroView();
virtual ~KeyboardMacroView() override;

virtual void resized() override;

Expand Down
2 changes: 1 addition & 1 deletion The-Orm/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class TheOrmApplication : public JUCEApplication, private ChangeListener
tooltipGlobalWindow_ = std::make_unique<TooltipWindow>();
}

virtual ~MainWindow() {
virtual ~MainWindow() override {
setLookAndFeel(nullptr);
}

Expand Down
2 changes: 1 addition & 1 deletion The-Orm/MainComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ MainComponent::MainComponent(bool makeYourOwnSize) :
std::stringstream buffer;
buffer << "\"sysex\" : ["; // This is the very specific CF Sysex format
bool first = true;
auto messages = patch.synth()->patchToSysex(patch.patch(), nullptr);
auto messages = patch.synth()->dataFileToSysex(patch.patch(), nullptr);
for (const auto& m : messages) {
for (int i = 0; i < m.getRawDataSize(); i++) {
if (!first) {
Expand Down
4 changes: 2 additions & 2 deletions The-Orm/MainComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class MainComponent : public Component, private ChangeListener
{
public:
MainComponent(bool makeYourOwnSize);
~MainComponent();
virtual ~MainComponent() override;

virtual void resized() override;

Expand All @@ -66,7 +66,7 @@ class MainComponent : public Component, private ChangeListener
static void crashTheSoftware();

void setZoomFactor(float newZoomInPercentage) const;
static float calcAcceptableGlobalScaleFactor();
float calcAcceptableGlobalScaleFactor();
Colour getUIColour(LookAndFeel_V4::ColourScheme::UIColour colourToGet);
void refreshSynthList();
static void aboutBox();
Expand Down
8 changes: 4 additions & 4 deletions The-Orm/PatchButtonPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void PatchButtonPanel::setupPageButtons() {
}
// Any more buttons unused?
for (int i = 0; i < maxPageButtons_; i++) {
if (i >= pageButtonMap_.size()) {
if (static_cast<size_t>(i) >= pageButtonMap_.size()) {
pageNumbers_[i]->setVisible(false);
}
}
Expand Down Expand Up @@ -276,9 +276,9 @@ void PatchButtonPanel::refresh(bool async, int autoSelectTarget /* = -1 */) {

// Now set the button text and colors
int active = indexOfActive();
for (int i = 0; i < (int) std::max(patchButtons_->size(), patches_.size()); i++) {
for (size_t i = 0; i < std::max(patchButtons_->size(), patches_.size()); i++) {
if (i < patchButtons_->size()) {
auto button = patchButtons_->buttonWithIndex(i);
auto button = patchButtons_->buttonWithIndex((int) i);
if (i < patches_.size() && patches_[i].patch() && patches_[i].synth()) {
auto displayMode = PatchHolderButton::getCurrentInfoForSynth(patches_[i].synth()->getName());
if (multiSynthMode) {
Expand All @@ -287,7 +287,7 @@ void PatchButtonPanel::refresh(bool async, int autoSelectTarget /* = -1 */) {
);
}
button->setPatchHolder(&patches_[i], i == active, displayMode);
refreshThumbnail(i);
refreshThumbnail((int)i);
}
else {
button->setPatchHolder(nullptr, false, PatchButtonInfo::CenterName);
Expand Down
2 changes: 1 addition & 1 deletion The-Orm/PatchButtonPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PatchButtonPanel : public Component,
typedef std::function<void(int, int, std::function<void(std::vector<midikraft::PatchHolder>)>)> TPageLoader;

PatchButtonPanel(std::function<void(midikraft::PatchHolder &)> handler);
virtual ~PatchButtonPanel();
virtual ~PatchButtonPanel() override;

void setPatchLoader(TPageLoader pageGetter);
void setTotalCount(int totalCount);
Expand Down
8 changes: 8 additions & 0 deletions The-Orm/PatchDiff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@

#include <algorithm>
#include <boost/format.hpp>
// Turn off warning on unknown pragmas for VC++
#pragma warning(push)
#pragma warning(disable: 4068)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#include "dtl/dtl.hpp"
#pragma GCC diagnostic pop
#pragma warning(pop)


class DiffTokenizer : public CodeTokeniser {
public:
Expand Down
2 changes: 1 addition & 1 deletion The-Orm/PatchDiff.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CoupledScrollCodeEditor;
class PatchDiff : public Component, private Button::Listener {
public:
PatchDiff(midikraft::Synth *activeSynth, midikraft::PatchHolder const &patch1, midikraft::PatchHolder const &patch2);
~PatchDiff();
virtual ~PatchDiff() override;

void resized() override;
void buttonClicked(Button*) override;
Expand Down
22 changes: 11 additions & 11 deletions The-Orm/PatchListTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ImportNameListener : public Value::Listener {
SimpleLogger::instance()->postMessage("Changed name of import to " + value.getValue().toString());
String newValue = value.getValue();
db_.renameImport(importID_, newValue.toStdString());
};
}

private:
midikraft::PatchDatabase& db_;
Expand Down Expand Up @@ -294,7 +294,7 @@ TreeViewItem* PatchListTree::newTreeViewItemForPatchList(midikraft::ListInfo lis
if (onUserListSelected)
onUserListSelected(list.id);
};
node->acceptsItem = [this, list](juce::var dropItem) {
node->acceptsItem = [list](juce::var dropItem) {
String dropItemString = dropItem;
auto infos = midikraft::PatchHolder::dragInfoFromString(dropItemString.toStdString());
return infos.contains("drag_type") && (infos["drag_type"] == "PATCH" || infos["drag_type"] == "PATCH_IN_LIST");
Expand Down Expand Up @@ -346,17 +346,17 @@ TreeViewItem* PatchListTree::newTreeViewItemForPatchList(midikraft::ListInfo lis
std::string oldname = node->text().toStdString();
CreateListDialog::showCreateListDialog(std::make_shared<midikraft::PatchList>(node->id().toStdString(), node->text().toStdString()),
TopLevelWindow::getActiveTopLevelWindow(),
[this, oldname](std::shared_ptr<midikraft::PatchList> list) {
jassert(list);
if (list) {
db_.putPatchList(*list);
SimpleLogger::instance()->postMessage((boost::format("Renamed list from %s to %s") % oldname % list->name()).str());
[this, oldname](std::shared_ptr<midikraft::PatchList> new_list) {
jassert(new_list);
if (new_list) {
db_.putPatchList(*new_list);
SimpleLogger::instance()->postMessage((boost::format("Renamed list from %s to %s") % oldname % new_list->name()).str());
regenerateUserLists();
}
}, [this](std::shared_ptr<midikraft::PatchList> list) {
if (list) {
db_.deletePatchlist(midikraft::ListInfo({ list->id(), list->name() }));
SimpleLogger::instance()->postMessage("Deleted list " + list->name());
}, [this](std::shared_ptr<midikraft::PatchList> new_list) {
if (new_list) {
db_.deletePatchlist(midikraft::ListInfo({ new_list->id(), new_list->name() }));
SimpleLogger::instance()->postMessage("Deleted list " + new_list->name());
regenerateUserLists();
}
});
Expand Down
4 changes: 2 additions & 2 deletions The-Orm/PatchListTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ class PatchListTree : public Component, private ChangeListener {
typedef std::function<void(midikraft::PatchHolder)> TPatchSelectionHandler;

PatchListTree(midikraft::PatchDatabase &db, std::vector<midikraft::SynthHolder> const& synths);
virtual ~PatchListTree();
virtual ~PatchListTree() override;

TSelectionHandler onImportListSelected;
TSelectionHandler onUserListSelected;
TSelectionHandler onUserListChanged;

TPatchSelectionHandler onPatchSelected;

virtual void resized();
virtual void resized() override;

void refreshAllUserLists();
void refreshUserList(std::string list_id);
Expand Down
2 changes: 1 addition & 1 deletion The-Orm/PatchPerSynthList.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class PatchPerSynthList : public Component, private ChangeListener {
public:
PatchPerSynthList();
virtual ~PatchPerSynthList();
virtual ~PatchPerSynthList() override;

virtual void resized() override;

Expand Down
12 changes: 6 additions & 6 deletions The-Orm/PatchSearchComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace {

const char* kAllDataTypesFilter = "All types";
//const char* kAllDataTypesFilter = "All types";

std::vector<std::pair<String, int>> kDisplayChoices = {
{ "Name and #", static_cast<int>(PatchButtonInfo::NameDisplay)},
Expand All @@ -23,9 +23,9 @@ namespace {
};

// A little helper
CategoryButtons::Category synthCategory(midikraft::NamedDeviceCapability* name) {
/*CategoryButtons::Category synthCategory(midikraft::NamedDeviceCapability* name) {
return CategoryButtons::Category(name->getName(), Colours::black);
}
}*/

std::map<std::string, std::weak_ptr<midikraft::Synth>> allSynthsMap() {
std::map<std::string, std::weak_ptr<midikraft::Synth>> synthMap;
Expand Down Expand Up @@ -158,7 +158,7 @@ void PatchSearchComponent::resized()
Rectangle<int> area(getLocalBounds());

// The left part with the search box gets 25% of the screen
int leftPart = area.getWidth() / 4;
int leftPart = 0; //area.getWidth() / 4;

// Determine the reserved place for the filter
auto sortAndDisplayTypeWidth = LAYOUT_BUTTON_WIDTH + LAYOUT_INSET_NORMAL;
Expand Down Expand Up @@ -187,8 +187,8 @@ void PatchSearchComponent::resized()

int normalFilterHeight = (int) flexBoxSize.getHeight() + categoryFilters_.getHeight();

auto sourceRow = leftHalf.removeFromTop(normalFilterHeight);
textSearch_.setBounds(sourceRow.withSizeKeepingCentre(leftPart, LAYOUT_LARGE_LINE_HEIGHT));
//auto sourceRow = leftHalf.removeFromTop(normalFilterHeight);
//textSearch_.setBounds(sourceRow.withSizeKeepingCentre(leftPart, LAYOUT_LARGE_LINE_HEIGHT));

buttonDisplayType_.setBounds(sortAndDisplayTypeArea.removeFromTop(normalFilterHeight).withSizeKeepingCentre(LAYOUT_BUTTON_WIDTH, LAYOUT_BUTTON_HEIGHT));

Expand Down
2 changes: 1 addition & 1 deletion The-Orm/PatchSearchComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PatchSearchComponent : public Component, private ChangeListener
public:
PatchSearchComponent(PatchView* patchView, PatchButtonPanel* patchButtons, midikraft::PatchDatabase& database);

virtual ~PatchSearchComponent();
virtual ~PatchSearchComponent() override;

virtual void resized() override;

Expand Down
2 changes: 1 addition & 1 deletion The-Orm/PatchView.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class PatchView : public Component,
{
public:
PatchView(midikraft::PatchDatabase &database, std::vector<midikraft::SynthHolder> const &synths);
virtual ~PatchView();
virtual ~PatchView() override;

void resized() override;

Expand Down
Loading

0 comments on commit 497aeb4

Please sign in to comment.