zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 5928138823f08952180297b7dc4613e0882e8a03
parent 96902a8bebc0011f7f105fb4603e4433fa3f9703
Author: fundamental <mark.d.mccurry@gmail.com>
Date:   Sat, 21 Nov 2015 10:14:00 -0500

MiddleWare: Remove Fallback On std::bad_alloc

If memory cannot be allocated from the heap consistently, the program
is no longer in a state which is handled well throughout the codebase.
Trying to recover from this point is going to mask any issue.

Diffstat:
Msrc/Misc/MiddleWare.cpp | 51++++++++++++++++++---------------------------------
1 file changed, 18 insertions(+), 33 deletions(-)

diff --git a/src/Misc/MiddleWare.cpp b/src/Misc/MiddleWare.cpp @@ -495,23 +495,12 @@ public: } } - Part *p; - try { - p = alloc.get(); - } catch (std::bad_alloc &ba) { - std::cerr << "failed to load part: " << ba.what() << std::endl; - return; - } + Part *p = alloc.get(); #else - try { - Part *p = new Part(*master->memory, synth, master->time, - config->cfg.GzipCompression, - config->cfg.Interpolation, - &master->microtonal, master->fft); - } catch (std::bad_alloc &ba) { - std::cerr << "failed to load part: " << ba.what() << std::endl; - return; - } + Part *p = new Part(*master->memory, synth, master->time, + config->cfg.GzipCompression, + config->cfg.Interpolation, + &master->microtonal, master->fft); if(p->loadXMLinstrument(filename)) fprintf(stderr, "Warning: failed to load part<%s>!\n", filename); @@ -538,23 +527,19 @@ public: if(npart == -1) return; - try { - Part *p = new Part(*master->memory, synth, - master->time, - config->cfg.GzipCompression, - config->cfg.Interpolation, - &master->microtonal, master->fft); - p->applyparameters(); - obj_store.extractPart(p, npart); - kits.extractPart(p, npart); - - //Give it to the backend and wait for the old part to return for - //deallocation - parent->transmitMsg("/load-part", "ib", npart, sizeof(Part *), &p); - GUI::raiseUi(ui, "/damage", "s", ("/part" + to_s(npart) + "/").c_str()); - } catch (std::bad_alloc &ba) { - std::cerr << "failed to load part: " << ba.what() << std::endl; - } + Part *p = new Part(*master->memory, synth, + master->time, + config->cfg.GzipCompression, + config->cfg.Interpolation, + &master->microtonal, master->fft); + p->applyparameters(); + obj_store.extractPart(p, npart); + kits.extractPart(p, npart); + + //Give it to the backend and wait for the old part to return for + //deallocation + parent->transmitMsg("/load-part", "ib", npart, sizeof(Part *), &p); + GUI::raiseUi(ui, "/damage", "s", ("/part" + to_s(npart) + "/").c_str()); } //Well, you don't get much crazier than changing out all of your RT