]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/XFormsView.C
fix crash with "save as"
[lyx.git] / src / frontends / xforms / XFormsView.C
index eeb2776c8be932fc429522acd93d34e27914e2b5..59e25ac9bceed52c8dc762abadde45f62a07b145 100644 (file)
@@ -1,12 +1,12 @@
-/* This file is part of
- * ======================================================
+/**
+ * \file XFormsView.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- *           LyX, The Document Processor
+ * \author unknown
  *
- *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-2001 The LyX Team.
- *
- * ====================================================== */
+ * Full author contact details are available in file CREDITS
+ */
 
 #include <config.h>
 
@@ -57,7 +57,8 @@ int C_XFormsView_atCloseMainFormCB(FL_FORM * form, void * p)
 
 
 XFormsView::XFormsView(int width, int height)
-       : LyXView()
+       : LyXView(),
+         icon_pixmap_(0), icon_mask_(0)
 {
        create_form_form_main(width, height);
        fl_set_form_atclose(getForm(), C_XFormsView_atCloseMainFormCB, 0);
@@ -67,12 +68,15 @@ XFormsView::XFormsView(int width, int height)
 
        // Make sure the buttons are disabled if needed.
        updateToolbar();
-       redraw_con = getDialogs()->redrawGUI.connect(boost::bind(&XFormsView::redraw, this));
+       redraw_con = getDialogs().redrawGUI().connect(boost::bind(&XFormsView::redraw, this));
 }
 
 
 XFormsView::~XFormsView()
 {
+       if (icon_pixmap_)
+               XFreePixmap(fl_get_display(), icon_pixmap_);
+
        minibuffer_->freeze();
        fl_hide_form(form_);
        fl_free_form(form_);
@@ -159,19 +163,18 @@ void XFormsView::create_form_form_main(int width, int height)
                air, height - (25 + air), width - (2 * air), 25));
 
        //  assign an icon to main form
-       string iconname = LibFileSearch("images", "lyx", "xpm");
+       string const iconname = LibFileSearch("images", "lyx", "xpm");
        if (!iconname.empty()) {
                unsigned int w, h;
-               Pixmap lyx_p, lyx_mask;
-               lyx_p = fl_read_pixmapfile(fl_root,
+               icon_pixmap_ = fl_read_pixmapfile(fl_root,
                                           iconname.c_str(),
                                           &w,
                                           &h,
-                                          &lyx_mask,
+                                          &icon_mask_,
                                           0,
                                           0,
-                                          0); // this leaks
-               fl_set_form_icon(getForm(), lyx_p, lyx_mask);
+                                          0);
+               fl_set_form_icon(getForm(), icon_pixmap_, icon_mask_);
        }
 
        // set min size
@@ -198,7 +201,7 @@ void XFormsView::message(string const & str)
 
 void XFormsView::show_view_state()
 {
-       message(getLyXFunc()->view_status_message());
+       message(getLyXFunc().view_status_message());
 }