Browse Source

Remove window reopen test. Add mutexes to logger init/destroy.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
8eb58fde2b
2 changed files with 11 additions and 9 deletions
  1. +5
    -4
      src/logger.cpp
  2. +6
    -5
      standalone/main.cpp

+ 5
- 4
src/logger.cpp View File

@@ -2,9 +2,8 @@


#include <common.hpp> #include <common.hpp>
#include <asset.hpp> #include <asset.hpp>
#include <settings.hpp>
#include <system.hpp> #include <system.hpp>
#include <unistd.h> // for dup2
// #include <unistd.h> // for dup2




namespace rack { namespace rack {
@@ -17,9 +16,10 @@ static std::mutex logMutex;




void init() { void init() {
std::lock_guard<std::mutex> lock(logMutex);
startTime = system::getTime(); startTime = system::getTime();
// Don't open a file in development mode. // Don't open a file in development mode.
if (settings::devMode) {
if (asset::logPath.empty()) {
outputFile = stderr; outputFile = stderr;
return; return;
} }
@@ -37,6 +37,7 @@ void init() {
} }


void destroy() { void destroy() {
std::lock_guard<std::mutex> lock(logMutex);
if (outputFile && outputFile != stderr) { if (outputFile && outputFile != stderr) {
// Print end token so we know if the logger exited cleanly. // Print end token so we know if the logger exited cleanly.
std::fprintf(outputFile, "END"); std::fprintf(outputFile, "END");
@@ -96,7 +97,7 @@ static bool fileEndsWith(FILE* file, std::string str) {
} }


bool isTruncated() { bool isTruncated() {
if (settings::devMode)
if (asset::logPath.empty())
return false; return false;


// Open existing log file // Open existing log file


+ 6
- 5
standalone/main.cpp View File

@@ -223,12 +223,13 @@ int main(int argc, char* argv[]) {
INFO("Running window"); INFO("Running window");
APP->window->run(); APP->window->run();
INFO("Stopped window"); INFO("Stopped window");
delete APP->window;
APP->window = NULL;


INFO("Re-creating window");
APP->window = new Window;
APP->window->run();
// INFO("Destroying window");
// delete APP->window;
// APP->window = NULL;
// INFO("Re-creating window");
// APP->window = new Window;
// APP->window->run();
} }


// Destroy context // Destroy context


Loading…
Cancel
Save