zynaddsubfx

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

commit 4f1d4f4c182aebb5bccefdb403011185cfaf5d62
parent 731b067a27f13142d5d43d461fbd4a8f3542d802
Author: fundamental <mark.d.mccurry@gmail.com>
Date:   Tue, 22 Sep 2009 18:43:55 -0400

UI: Fixed memory leaks (James Morris)

Fixed several memory leaks in the FLTK GUI as indicated by James Morris's patch

Diffstat:
MAUTHORS.txt | 1+
MChangeLog | 1+
Msrc/UI/MasterUI.fl | 52++++++++++++++++++++++++++++------------------------
Msrc/UI/PartUI.fl | 8++++----
Msrc/UI/VirKeyboard.fl | 11+++++++----
Msrc/UI/WidgetPDial.fl | 12+++++++-----
6 files changed, 48 insertions(+), 37 deletions(-)

diff --git a/AUTHORS.txt b/AUTHORS.txt @@ -14,4 +14,5 @@ Contributors: Jérémie Andréi (AZERTY keyboard layout, Array index fix) Alexis Ballier (const char* <-> string mismatch, NULLMidi prototype fix) Tobias Doerffel (static vs instance variables alteration) + James Morris (Memory leaks in FLTK GUI) diff --git a/ChangeLog b/ChangeLog @@ -902,3 +902,4 @@ 22 Sep 2009 (Mark McCurry) - Changed temporary data for Oscilgen from static to instance recommended by Tobias Doerffel + - Fixed Memory leaks in UI based upon James Morris' patch diff --git a/src/UI/MasterUI.fl b/src/UI/MasterUI.fl @@ -1,9 +1,8 @@ # data file for the Fltk User Interface Designer (fluid) -version 1.0109 +version 1.0107 header_name {.h} code_name {.cc} -decl {//Copyright (c) 2002-2009 Nasca Octavian Paul} {selected -} +decl {//Copyright (c) 2002-2009 Nasca Octavian Paul} {} decl {//License: GNU GPL version 2 or later} {} @@ -275,7 +274,8 @@ labelsize(10); align(FL_ALIGN_TOP); value(master->Psysefxsend[neff1][neff2]); -char tmp[20];snprintf(tmp,20,"%d->%d",neff1+1,neff2+1);this->label(strdup(tmp));} {} +char tmp[20];snprintf(tmp,20,"%d->%d",neff1+1,neff2+1); +this->copy_label(tmp);} {} } Function {~SysEffSend()} {} { code {hide();} {} @@ -344,7 +344,7 @@ bankui->show();} xywh {15 235 40 20} box PLASTIC_UP_BOX labelsize 10 } Fl_Choice partrcv { - callback {master->part[npart]->Prcvchn=(int) o->value();} open + callback {master->part[npart]->Prcvchn=(int) o->value();} tooltip {receive from Midi channel} xywh {10 213 50 15} down_box BORDER_BOX labelsize 10 align 5 textfont 1 textsize 10 code0 {char nrstr[10]; for(int i=0;i<NUM_MIDI_CHANNELS;i++){sprintf(nrstr,"Ch%d",i+1);if (i!=9) o->add(nrstr); else o->add("Dr10");};} code1 {o->value(master->part[npart]->Prcvchn);} @@ -367,7 +367,7 @@ if ((int) o->value()==0) panellistitemgroup->deactivate(); o->redraw();} private xywh {5 0 45 20} down_box DOWN_BOX labeltype EMBOSSED_LABEL labelfont 1 labelsize 13 align 24 - code0 {char tmp[10];snprintf(tmp,10,"%d",npart+1);o->label(strdup(tmp));} + code0 {char tmp[10];snprintf(tmp,10,"%d",npart+1);o->copy_label(tmp);} code1 {o->value(master->part[npart]->Penabled);} } } @@ -386,8 +386,7 @@ make_window(); panellistitem->show(); end();} {} } - Function {refresh()} {open - } { + Function {refresh()} {} { code {partenabled->value(master->part[npart]->Penabled); if (master->part[npart]->Penabled!=0) panellistitemgroup->activate(); else panellistitemgroup->deactivate(); @@ -415,7 +414,8 @@ panellistitemgroup->redraw();} {} } class MasterUI {} { - Function {make_window()} {} { + Function {make_window()} {selected + } { Fl_Window masterwindow { label zynaddsubfx callback {\#ifdef VSTAUDIOOUT @@ -426,7 +426,7 @@ if (fl_choice("Exit and leave the unsaved data?","No","Yes",NULL)) { *exitprogram=1; }; \#endif} - xywh {31 206 390 465} type Double xclass zynaddsubfx visible + xywh {31 206 390 465} type Double hide xclass zynaddsubfx } { Fl_Menu_Bar mastermenu { xywh {-5 0 690 25} @@ -1043,18 +1043,18 @@ GNU General Public License for details.} label {ZynAddSubFX Panel} xywh {89 59 630 635} type Double hide } { - Fl_Scroll {} {open + Fl_Scroll {} { xywh {0 5 570 310} type HORIZONTAL box THIN_UP_BOX } { - Fl_Pack {} {open + Fl_Pack {} { xywh {5 10 560 285} type HORIZONTAL code0 {for (int i=0;i<NUM_MIDI_PARTS/2;i++){panellistitem[i]=new Panellistitem(0,0,70,260,"");panellistitem[i]->init(master,i,bankui);}} } {} } - Fl_Scroll {} {open + Fl_Scroll {} { xywh {0 320 570 310} type HORIZONTAL box THIN_UP_BOX } { - Fl_Pack {} {open + Fl_Pack {} { xywh {5 325 560 285} type HORIZONTAL code0 {for (int i=NUM_MIDI_PARTS/2;i<NUM_MIDI_PARTS;i++){panellistitem[i]=new Panellistitem(0,0,70,260,"");panellistitem[i]->init(master,i,bankui);}} } {} @@ -1288,7 +1288,7 @@ if ((int) o->value()==0) simplelistitemgroup->deactivate(); o->redraw();} private xywh {250 40 85 20} down_box DOWN_BOX labeltype EMBOSSED_LABEL labelfont 1 labelsize 13 align 24 - code0 {//char tmp[10];snprintf(tmp,10,"%d",npart+1);o->label(strdup(tmp));} + code0 {//char tmp[10];snprintf(tmp,10,"%d",npart+1);o->copy_label(tmp);} code1 {o->value(master->part[npart]->Penabled);} } Fl_Box virkeys { @@ -1643,19 +1643,23 @@ simplerefresh();} {} } Function {~MasterUI()} {} { code {masterwindow->hide(); -delete (masterwindow); +delete masterwindow; +simplemasterwindow->hide(); +delete simplemasterwindow; aboutwindow->hide(); -delete (aboutwindow); +delete aboutwindow; syseffsendwindow->hide(); -delete(syseffsendwindow); +delete syseffsendwindow; -delete (virkeyboard); -delete (microtonalui); -delete (bankui); -delete (configui); -delete (sequi); +delete virkeyboard; +delete microtonalui; +delete bankui; +delete configui; +delete sequi; -delete(presetsui);} {} +delete presetsui; +delete panelwindow; +delete selectuiwindow;} {} } Function {showUI()} {} { code {switch (config.cfg.UserInterfaceMode){ diff --git a/src/UI/PartUI.fl b/src/UI/PartUI.fl @@ -56,7 +56,7 @@ class PartSysEffSend {: {public Fl_Group} xywh {0 0 25 25} box ROUND_UP_BOX labelfont 1 labelsize 10 align 130 maximum 127 step 1 code0 {o->size(25,25);} code1 {o->value(master->Psysefxvol[neff][npart]);} - code2 {char tmp[10];snprintf(tmp,10,"%d",neff+1);o->label(strdup(tmp));} + code2 {char tmp[10];snprintf(tmp,10,"%d",neff+1);o->copy_label(tmp);} class WidgetPDial } } @@ -212,7 +212,7 @@ o->redraw(); partui->showparameters(n,-1);//use to delete the ui, if it is not to item 0 } else o->value(1);} private xywh {30 0 20 15} down_box DOWN_BOX labeltype EMBOSSED_LABEL labelfont 1 labelsize 13 align 4 - code0 {snprintf(label,10,"%d",n+1);o->label(strdup(label));} + code0 {snprintf(label,10,"%d",n+1);o->label(label);} code1 {o->value(part->kit[n].Penabled);} code2 {if (n==0) o->deactivate();} } @@ -590,7 +590,7 @@ part->ctl.portamento.updowntimestretch=x;} } Fl_Dial proptb { label {Prp.Dpth} - callback {part->ctl.portamento.propDepth=(int) o->value();} selected + callback {part->ctl.portamento.propDepth=(int) o->value();} tooltip {The difference from nonproportinal portamento} xywh {405 60 25 25} labelsize 9 maximum 127 step 1 code0 {o->value(part->ctl.portamento.propDepth);} class WidgetPDial @@ -841,7 +841,7 @@ if (part->Pkitmode==0) { } } Fl_Window instrumenteditwindow { - label {Instrument Edit} + label {Instrument Edit} selected xywh {182 214 395 360} type Double hide } { Fl_Group {} { diff --git a/src/UI/VirKeyboard.fl b/src/UI/VirKeyboard.fl @@ -41,9 +41,9 @@ decl {const int keysoct1qwertz[]={'q','2','w','3','e','r','5','t','6','z','7','u decl {const int keysoct2qwertz[]={'y','s','x','d','c','v','g','b','h','n','j','m',',','l','.',246,'-',0};} {} -decl {const int keysoct1az[]={'a',233,'z','\\"','e','r','(','t','-','y',232,'u','i',231,'o',224,'p',65106,'=','$',0};} {} +decl {const int keysoct1az[]={'a',233,'z','\\"','e','r','(','t','-','y',232,'u','i',231,'o',224,'p',65106,'=','$',0};} {} -decl {const int keysoct2az[]={'w','s','x','d','c','v','g','b','h','n','j',',',';','l',':','m','!',0};} {} +decl {const int keysoct2az[]={'w','s','x','d','c','v','g','b','h','n','j',',',';','l',':','m','!',0};} {} class VirKeys {: {public Fl_Box} } { @@ -184,8 +184,7 @@ if ((event==FL_KEYDOWN)||(event==FL_KEYUP)){ return(1);} {} } - Function {presskey(int nk,int exclusive,int type)} {selected - } { + Function {presskey(int nk,int exclusive,int type)} {} { code {//Exclusive means that multiple keys can be pressed at once //when the user uses the shift key if (nk>=N_OCT*12) return; @@ -410,6 +409,10 @@ virkeys->take_focus();} open midictl=75; make_window();} {} } + Function {~VirKeyboard()} {} { + code {delete virkeyboardwindow;} {selected + } + } Function {show()} {} { code {virkeyboardwindow->show();} {} } diff --git a/src/UI/WidgetPDial.fl b/src/UI/WidgetPDial.fl @@ -1,5 +1,5 @@ # data file for the Fltk User Interface Designer (fluid) -version 1.0109 +version 1.0107 header_name {.h} code_name {.cc} decl {//Copyright (c) 2003-2005 Nasca Octavian Paul} {} @@ -61,7 +61,8 @@ textmode=false; } Function {setText(const char * c)} {return_type void } { - code {strcpy(text,c); + code {strncpy(text, c, max_tooltip_len-1); +text[max_tooltip_len-1] = 0; textmode=true; // Recalc size of window fl_font(labelfont(), labelsize()); @@ -84,7 +85,9 @@ textmode=true; } decl {char tip[40];} {} decl {bool textmode;} {} - decl {char text[400];//bad stuff will happen if too much is put in this (perhaps dynamically allocate?)} {} + decl {enum { max_tooltip_len = 400 };} {selected + } + decl {char text[max_tooltip_len];} {} } class WidgetPDial {: {public Fl_Dial} @@ -153,8 +156,7 @@ case FL_RELEASE: return(1); break; }; -return(0);} {selected - } +return(0);} {} } Function {drawgradient(int cx,int cy,int sx,double m1,double m2)} {return_type void } {