diff --git a/src/Fl_File_Chooser.cxx b/src/Fl_File_Chooser.cxx index 66f3efc11..657318618 100644 --- a/src/Fl_File_Chooser.cxx +++ b/src/Fl_File_Chooser.cxx @@ -27,12 +27,13 @@ #include "../FL/Fl_File_Chooser.H" #include +#include void Fl_File_Chooser::cb_window_i(Fl_Double_Window*, void*) { fileName->value(""); fileList->deselect(); Fl::remove_timeout((Fl_Timeout_Handler)previewCB, this); -window->hide(); +hide(); } void Fl_File_Chooser::cb_window(Fl_Double_Window* o, void* v) { ((Fl_File_Chooser*)(o->user_data()))->cb_window_i(o,v); @@ -104,7 +105,7 @@ void Fl_File_Chooser::cb_fileName(Fl_File_Input* o, void* v) { } void Fl_File_Chooser::cb_okButton_i(Fl_Return_Button*, void*) { - window->hide(); + hide(); // Do any callback that is registered... if (callback_) @@ -118,7 +119,7 @@ void Fl_File_Chooser::cb_cancelButton_i(Fl_Button*, void*) { fileName->value(""); fileList->deselect(); Fl::remove_timeout((Fl_Timeout_Handler)previewCB, this); -window->hide(); +hide(); } void Fl_File_Chooser::cb_cancelButton(Fl_Button* o, void* v) { ((Fl_File_Chooser*)(o->parent()->parent()->parent()->user_data()))->cb_cancelButton_i(o,v); @@ -356,6 +357,9 @@ void Fl_File_Chooser::filter_value(int f) { void Fl_File_Chooser::hide() { window->hide(); + Fl_Shared_Image *oldimage = (Fl_Shared_Image *)previewBox->image(); + if (oldimage) oldimage->release(); + previewBox->image(NULL); } void Fl_File_Chooser::iconsize(uchar s) { diff --git a/src/Fl_File_Chooser.fl b/src/Fl_File_Chooser.fl index ea542c240..72438c773 100644 --- a/src/Fl_File_Chooser.fl +++ b/src/Fl_File_Chooser.fl @@ -32,6 +32,9 @@ comment {// decl {\#include } {private local } +decl {\#include } {selected private local +} + class FL_EXPORT Fl_File_Chooser {open } { decl {enum { SINGLE = 0, MULTI = 1, CREATE = 2, DIRECTORY = 4 };} {public local @@ -68,7 +71,8 @@ class FL_EXPORT Fl_File_Chooser {open } decl {void update_preview();} {private local } - Function {Fl_File_Chooser(const char *d, const char *p, int t, const char *title)} {} { + Function {Fl_File_Chooser(const char *d, const char *p, int t, const char *title)} {open + } { code {if (!prefs_) { prefs_ = new Fl_Preferences(Fl_Preferences::USER, "fltk.org", "filechooser"); }} {} @@ -78,12 +82,12 @@ class FL_EXPORT Fl_File_Chooser {open callback {fileName->value(""); fileList->deselect(); Fl::remove_timeout((Fl_Timeout_Handler)previewCB, this); -window->hide();} open - private xywh {507 327 490 380} type Double hide resizable +hide();} open + private xywh {412 246 490 380} type Double resizable code0 {if (title) window->label(title);} code1 {\#include } code2 {\#include } - code3 {\#include } modal + code3 {\#include } modal visible } { Fl_Group {} {open private xywh {10 10 470 25} @@ -158,7 +162,7 @@ window->hide();} open } { Fl_Return_Button okButton { label OK - callback {window->hide(); + callback {hide(); // Do any callback that is registered... if (callback_) @@ -172,7 +176,7 @@ if (callback_) callback {fileName->value(""); fileList->deselect(); Fl::remove_timeout((Fl_Timeout_Handler)previewCB, this); -window->hide();} +hide();} private xywh {408 345 72 25} code0 {o->label(fl_cancel);} } @@ -288,9 +292,12 @@ data_ = d;} {} code {showChoice->value(f); showChoiceCB();} {} } - Function {hide()} {return_type void + Function {hide()} {open return_type void } { - code {window->hide();} {} + code {window->hide(); +Fl_Shared_Image *oldimage = (Fl_Shared_Image *)previewBox->image(); +if (oldimage) oldimage->release(); +previewBox->image(NULL);} {} } Function {iconsize(uchar s)} {return_type void } { @@ -351,7 +358,7 @@ okButton->parent()->init_sizes();} {} } { code {fileList->textfont(f);} {} } - Function {textfont()} {selected return_type Fl_Font + Function {textfont()} {return_type Fl_Font } { code {return (fileList->textfont());} {} } diff --git a/src/Fl_File_Chooser2.cxx b/src/Fl_File_Chooser2.cxx index 06ca17eca..e68285a4c 100644 --- a/src/Fl_File_Chooser2.cxx +++ b/src/Fl_File_Chooser2.cxx @@ -1350,7 +1350,7 @@ Fl_File_Chooser::update_preview() oldimage = (Fl_Shared_Image *)previewBox->image(); - if (oldimage) oldimage->release(); + if (oldimage) ((Fl_Shared_Image *)oldimage)->release(); previewBox->image(0); @@ -1444,14 +1444,14 @@ Fl_File_Chooser::update_preview() h = w * image->h() / image->w(); if (h > pbh) { - h = pbh; - w = h * image->w() / image->h(); + h = pbh; + w = h * image->w() / image->h(); } - oldimage = (Fl_Shared_Image *)image->copy(w, h); + oldimage = Fl_Shared_Image::get(filename, w, h); previewBox->image((Fl_Image *)oldimage); - image->release(); + ((Fl_Shared_Image *)image)->release(); } else { previewBox->image((Fl_Image *)image); } diff --git a/src/Fl_Shared_Image.cxx b/src/Fl_Shared_Image.cxx index 5f9706aa1..29447f857 100644 --- a/src/Fl_Shared_Image.cxx +++ b/src/Fl_Shared_Image.cxx @@ -239,18 +239,19 @@ void Fl_Shared_Image::release() { } } - for (i = 0; i < num_images_; i ++) + for (i = 0; i < num_images_; i ++) { if (images_[i] == this) { num_images_ --; if (i < num_images_) { memmove(images_ + i, images_ + i + 1, - (num_images_ - i) * sizeof(Fl_Shared_Image *)); + (num_images_ - i) * sizeof(Fl_Shared_Image *)); } break; } - + } + delete this; if (num_images_ == 0 && images_) {