]> git.lyx.org Git - features.git/commitdiff
fix memory access bugs in flimage use.
authorAngus Leeming <leeming@lyx.org>
Thu, 7 Mar 2002 09:59:17 +0000 (09:59 +0000)
committerAngus Leeming <leeming@lyx.org>
Thu, 7 Mar 2002 09:59:17 +0000 (09:59 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3682 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/xforms/ChangeLog
src/frontends/xforms/xformsGImage.C

index 604dbed832ab2e39461096ccba661c4b5529e51d..3bc05cbad1a0fd9c0bce7a9c1293cfb461410f9c 100644 (file)
@@ -1,3 +1,10 @@
+2002-03-07  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * 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  <a.leeming@ic.ac.uk>
 
        * xformsGImage.[Ch]: new files. An image loader based on xforms library
index 0a7590768c35f4265f088cb6270ca854b50df569..bcaa69f48852df2092a0990069e7ce5296ac6ac3 100644 (file)
@@ -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);