diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 604dbed832..3bc05cbad1 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,10 @@ +2002-03-07 Angus Leeming + + * xformsGImage.C (statusCB, errorCB): close the file streams once the + image is loaded or if an error occurs. + (init_graphics): FLIMAGE_SETUP setup must be static as xforms stores + it permanently (and does not make a copy!). + 2002-03-05 Angus Leeming * xformsGImage.[Ch]: new files. An image loader based on xforms library diff --git a/src/frontends/xforms/xformsGImage.C b/src/frontends/xforms/xformsGImage.C index 0a7590768c..bcaa69f488 100644 --- a/src/frontends/xforms/xformsGImage.C +++ b/src/frontends/xforms/xformsGImage.C @@ -308,8 +308,14 @@ void xformsGImage::statusCB(string const & status_message) return; if (prefixIs(status_message, "Done Reading")) { - on_finish_->emit(true); - on_finish_.reset(); + if (image_) { + flimage_close(image_); + } + + if (on_finish_.get()) { + on_finish_->emit(true); + on_finish_.reset(); + } } } @@ -319,8 +325,14 @@ void xformsGImage::errorCB(string const & error_message) if (error_message.empty() || !on_finish_.get()) return; - on_finish_->emit(false); - on_finish_.reset(); + if (image_) { + flimage_close(image_); + } + + if (on_finish_.get()) { + on_finish_->emit(false); + on_finish_.reset(); + } } } // namespace grfx @@ -398,7 +410,9 @@ void init_graphics() flimage_enable_xwd(); flimage_enable_xpm(); - FLIMAGE_SETUP setup; + // xforms stores this permanently (does not make a copy) so + // this should never be destroyed. + static FLIMAGE_SETUP setup; setup.visual_cue = status_report; setup.error_message = error_report; flimage_setup(&setup);