Browse Source

Make all subsystems able to initialize and destroy multiple times.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
54cc95ae46
6 changed files with 16 additions and 11 deletions
  1. +2
    -0
      adapters/standalone.cpp
  2. +1
    -0
      include/app/Browser.hpp
  3. +8
    -8
      src/app/Browser.cpp
  4. +2
    -2
      src/app/TipWindow.cpp
  5. +1
    -0
      src/logger.cpp
  6. +2
    -1
      src/network.cpp

+ 2
- 0
adapters/standalone.cpp View File

@@ -11,6 +11,7 @@
#include <engine/Engine.hpp>
#include <app/common.hpp>
#include <app/Scene.hpp>
#include <app/Browser.hpp>
#include <plugin.hpp>
#include <context.hpp>
#include <window/Window.hpp>
@@ -175,6 +176,7 @@ int main(int argc, char* argv[]) {
keyboard::init();
gamepad::init();
plugin::init();
app::browserInit();
library::init();
discord::init();
if (!settings::headless) {


+ 1
- 0
include/app/Browser.hpp View File

@@ -7,6 +7,7 @@ namespace rack {
namespace app {


PRIVATE void browserInit();
PRIVATE widget::Widget* browserCreate();




+ 8
- 8
src/app/Browser.cpp View File

@@ -41,12 +41,10 @@ namespace browser {


static fuzzysearch::Database<plugin::Model*> modelDb;
static bool modelDbInitialized = false;


static void fuzzySearchInit() {
if (modelDbInitialized)
return;
static void modelDbInit() {
modelDb = fuzzysearch::Database<plugin::Model*>();
modelDb.setWeights({1.f, 1.f, 0.1f, 1.f, 0.5f, 0.5f});
modelDb.setThreshold(0.25f);

@@ -75,8 +73,6 @@ static void fuzzySearchInit() {
modelDb.addEntry(model, fields);
}
}

modelDbInitialized = true;
}


@@ -731,8 +727,6 @@ struct Browser : widget::OpaqueWidget {
}
}
else {
// Lazily initialize search database
fuzzySearchInit();
// Score results against search query
auto results = modelDb.search(search);
// DEBUG("=============");
@@ -1013,6 +1007,12 @@ inline void ZoomButton::onAction(const ActionEvent& e) {
} // namespace browser



void browserInit() {
browser::modelDbInit();
}


widget::Widget* browserCreate() {
browser::BrowserOverlay* overlay = new browser::BrowserOverlay;
overlay->bgColor = nvgRGBAf(0, 0, 0, 0.33);


+ 2
- 2
src/app/TipWindow.cpp View File

@@ -32,7 +32,7 @@ struct TipInfo {


// Remember to use “smart quotes.”
static std::vector<TipInfo> tipInfos = {
static const std::vector<TipInfo> tipInfos = {
{"To add a module to your patch, right-click an empty rack space or press Enter. Click and drag a module from the Module Browser into the desired rack space.\n\nYou can force-move modules by holding " RACK_MOD_CTRL_NAME " while dragging them.\n\nClick and drag on empty rack space to select multiple modules.", "", ""},
{"Pan around the rack by using the scroll bars, dragging while holding the middle mouse button, " RACK_MOD_ALT_NAME "+clicking and dragging, or pressing the arrow keys. Arrow key panning speed can be modified by holding " RACK_MOD_CTRL_NAME ", " RACK_MOD_SHIFT_NAME ", or " RACK_MOD_CTRL_NAME "+" RACK_MOD_SHIFT_NAME ".\n\nZoom in and out using the View menu, " RACK_MOD_CTRL_NAME "+scroll, or " RACK_MOD_CTRL_NAME "+= and " RACK_MOD_CTRL_NAME "+minus.", "", ""},
// {"Want to use VCV Rack as a plugin in your DAW? VCV Rack Studio Edition is available now as a 64-bit VST 2 plugin for Ableton Live, FL Studio, Reason, REAPER, Bitwig, and more.", "Learn more", "https://vcvrack.com/Rack"},
@@ -158,7 +158,7 @@ struct TipWindow : widget::OpaqueWidget {
// Increment tip index
settings::tipIndex = math::eucMod(settings::tipIndex + delta, (int) tipInfos.size());

TipInfo& tipInfo = tipInfos[settings::tipIndex];
const TipInfo& tipInfo = tipInfos[settings::tipIndex];
label->text = tipInfo.text;
linkButton->setVisible(tipInfo.linkText != "");
linkButton->text = tipInfo.linkText;


+ 1
- 0
src/logger.cpp View File

@@ -49,6 +49,7 @@ static bool isTruncated() {
void init() {
assert(!outputFile);
std::lock_guard<std::mutex> lock(mutex);
truncated = false;

// Don't open a file in development mode.
if (logPath.empty()) {


+ 2
- 1
src/network.cpp View File

@@ -70,7 +70,8 @@ void init() {

void destroy() {
curl_global_cleanup();
OPENSSL_cleanup();
// Don't destroy OpenSSL because it's not designed to be reinitialized.
// OPENSSL_cleanup();
}




Loading…
Cancel
Save