From d733de358eaf06ede78808f3b1a9a5b200d167c6 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Wed, 29 Feb 2012 23:06:21 -0800 Subject: [PATCH] Enforce restriction on total number of patterns and phrases. --- src/gui/input.C | 9 +++++++-- src/pattern.C | 7 ++++++- src/phrase.C | 7 ++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/gui/input.C b/src/gui/input.C index 307348c..e4fb8e0 100644 --- a/src/gui/input.C +++ b/src/gui/input.C @@ -195,9 +195,14 @@ canvas_input_callback ( O_Canvas *widget, Canvas *c, int m ) break; case 'c': { - c->grid( c->grid()->create() ); + Grid *g = c->grid()->create(); - ui->update_sequence_widgets(); + if ( g ) + { + c->grid( g ); + + ui->update_sequence_widgets(); + } break; } diff --git a/src/pattern.C b/src/pattern.C index a4e88ce..e25c041 100644 --- a/src/pattern.C +++ b/src/pattern.C @@ -261,7 +261,12 @@ pattern::recording ( void ) pattern * pattern::create ( void ) { - return new pattern; + if ( pattern::patterns() < 128 ) + { + return new pattern; + } + else + return NULL; } pattern * diff --git a/src/phrase.C b/src/phrase.C index a38811a..964828f 100644 --- a/src/phrase.C +++ b/src/phrase.C @@ -109,7 +109,12 @@ phrase::reset ( void ) phrase * phrase::create ( void ) { - return new phrase; + if ( phrase::phrases() < 128 ) + { + return new phrase; + } + else + return NULL; } phrase *