]> git.lyx.org Git - features.git/commitdiff
Fix memory leaks in the Qt math panel.
authorAngus Leeming <leeming@lyx.org>
Tue, 17 Jun 2003 00:30:47 +0000 (00:30 +0000)
committerAngus Leeming <leeming@lyx.org>
Tue, 17 Jun 2003 00:30:47 +0000 (00:30 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7176 a592a061-630c-0410-9148-cb99ea01b6c8

17 files changed:
src/ChangeLog
src/LyXAction.C
src/frontends/Dialogs.C
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlMath2.C
src/frontends/controllers/ControlMath2.h
src/frontends/qt2/ChangeLog
src/frontends/qt2/Dialogs.C
src/frontends/qt2/QDelimiterDialog.C
src/frontends/qt2/QDelimiterDialog.h
src/frontends/qt2/QMath.C
src/frontends/qt2/QMath.h
src/frontends/qt2/QMathDialog.C
src/frontends/qt2/QMathMatrixDialog.C
src/frontends/qt2/QMathMatrixDialog.h
src/lfuns.h
src/lyxfunc.C

index 7dc0eb2d0dfefff2552cd7beabcdc026ed9401e7..486e403a02058972074460cfa3d21bc2e8a1ab62 100644 (file)
@@ -1,3 +1,10 @@
+2003-06-17  Angus Leeming  <leeming@lyx.org>
+
+       * lfuns.h:
+       * LyXAction.C (init): new LFUN_DIALOG_SHOW.
+
+       * lyxfunc.C (dispatch): invoke it.
+
 2003-06-16  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
 
        * iterators.C (operator++, ParPosition): reintroduce some
index bf89d50509bef6f138d3d4e1553eb649456fa831..1522ffea0fb01602612a57864051bd3e67075178 100644 (file)
@@ -313,6 +313,7 @@ void LyXAction::init()
                { LFUN_REJECT_CHANGE, "reject-change", Noop },
                { LFUN_ACCEPT_ALL_CHANGES, "accept-all-changes", Noop },
                { LFUN_REJECT_ALL_CHANGES, "reject-all-changes", Noop },
+               { LFUN_DIALOG_SHOW, "dialog-show", Noop },
                { LFUN_DIALOG_SHOW_NEW_INSET, "dialog-show-new-inset", Noop },
                { LFUN_DIALOG_SHOW_NEXT_INSET, "dialog-show-next-inset", Noop },
                { LFUN_DIALOG_UPDATE, "dialog-update", Noop },
index 82cac2cb640a12b04ae042691fe7b550ac513b8b..08dfde0335a54b90edad5baf569e63178bdb50ef 100644 (file)
@@ -95,6 +95,7 @@ void Dialogs::show(string const & name, string const & data)
        if (!dialog)
                return;
 
+       // FIXME! Should check that the dialog is NOT an inset dialog.
        dialog->show(data);
 }
 
@@ -105,6 +106,7 @@ void Dialogs::show(string const & name, string const & data, InsetBase * inset)
        if (!dialog)
                return;
 
+       // FIXME! Should check that the dialog IS an inset dialog.
        dialog->show(data);
        open_insets_[name] = inset;
 }
index c29b44a7c7f5092d74abf34925ce0a033889920a..25c821bf04c6c58dba3984a379a10d7c84c0ad14 100644 (file)
@@ -1,3 +1,7 @@
+2003-06-17  Angus Leeming  <leeming@lyx.org>
+
+       * ControlMath2.[Ch] (showDialog): new member function.
+
 2003-06-12  Angus Leeming  <leeming@lyx.org>
 
        * ControlMath2.[Ch]: new files. A work in progress towards a clean
index a51b5d23bf7f75d2181f37b5d1c75ffa1ee6ae59..4552d7851a6aafb9a09d66f6d249d0f9845b0d19 100644 (file)
@@ -63,3 +63,9 @@ void ControlMath2::dispatchToggleDisplay() const
        kernel().dispatch(FuncRequest(LFUN_MATH_DISPLAY));
 }
 
+
+void ControlMath2::showDialog(string const & name) const
+{
+       kernel().dispatch(FuncRequest(LFUN_DIALOG_SHOW, name));
+}
+
index 93455cd71a2b655d94e6ba05eba0a2de4d260701..d493d0b5b472edf4567f2fcf7cedd668fa00f035 100644 (file)
@@ -41,6 +41,8 @@ public:
        void dispatchDelim(string const & str) const;
        /// switch between display and inline
        void dispatchToggleDisplay() const;
+       /// a request to launch dialog \param name.
+       void showDialog(string const & name) const;
 };
 
 
index 01f7ea0243a0579b8efe74d4ff58334e0fb74cc5..a27a0947f7c94c4c0bf442c0498bf35e55b7a37a 100644 (file)
@@ -1,3 +1,14 @@
+2003-06-17  Angus Leeming  <leeming@lyx.org>
+
+       * Dialogs.C (build): create "mathdelimiter" and "mathmatrix" dialogs.
+
+       * QMath.[Ch]: add QMathMatrix and QMathDelimiter classes.
+
+       * QDelimiterDialog.[Ch]: store a QMathDelimiter*, not a QMath*.
+       * QMathMatrixDialog.[Ch]: store a QMathMatrix*, not a QMath*.
+
+       * QMathDialog.C (delimiterClicked, matrixClicked): fix memory leaks.
+       
 2003-06-14  John Levon  <levon@movementarian.org>
 
        * ui/QPrintDialogBase.ui: make "OK" default
index dfe4cd6ca95233e5933e0be56c799a351cd3e6dc..4c75aff7f4f02329cc763a8f773c41822a747649 100644 (file)
@@ -82,8 +82,9 @@ namespace {
 
 char const * const dialognames[] = { "about", "bibitem", "bibtex", "changes",
 "character", "citation", "error", "errorlist", "ert", "external", "file",
-"float", "graphics", "include", "index", "label", "log", "math", "minipage",
-"paragraph", "ref", "tabular", "tabularcreate",
+"float", "graphics", "include", "index", "label", "log",
+"math", "mathdelimiter", "mathmatrix",
+"minipage", "paragraph", "ref", "tabular", "tabularcreate",
 
 #ifdef HAVE_LIBAIKSAURUS
 "thesaurus",
@@ -198,6 +199,14 @@ Dialog * Dialogs::build(string const & name)
                dialog->setController(new ControlMath2(*dialog));
                dialog->setView(new QMath(*dialog));
                dialog->bc().bp(new IgnorantPolicy);
+       } else if (name == "mathdelimiter") {
+               dialog->setController(new ControlMath2(*dialog));
+               dialog->setView(new QMathDelimiter(*dialog));
+               dialog->bc().bp(new IgnorantPolicy);
+       } else if (name == "mathmatrix") {
+               dialog->setController(new ControlMath2(*dialog));
+               dialog->setView(new QMathMatrix(*dialog));
+               dialog->bc().bp(new IgnorantPolicy);
        } else if (name == "minipage") {
                dialog->setController(new ControlMinipage(*dialog));
                dialog->setView(new QMinipage(*dialog));
index a328eccf4d073970c0aa711da817db2c2dfd893d..c2a50029fdb6c6b84dd4553bdd4fe2a1351ce468 100644 (file)
@@ -71,7 +71,7 @@ string fix_name(string const & str)
 } // namespace anon
 
 
-QDelimiterDialog::QDelimiterDialog(QMath * form)
+QDelimiterDialog::QDelimiterDialog(QMathDelimiter * form)
        : QDelimiterDialogBase(0, 0, false, 0),
        form_(form)
 {
index b881635d4be3c6f1d56f99fff02896e6b66d815b..1953c0539ccb95ce082b051e189bb3554fa4336a 100644 (file)
 #include "ui/QDelimiterDialogBase.h"
 #include "LString.h"
 
-class QMath;
+class QMathDelimiter;
 class IconPalette;
 class QLabel;
 
 class QDelimiterDialog : public QDelimiterDialogBase {
        Q_OBJECT
 public:
-       QDelimiterDialog(QMath * form);
+       QDelimiterDialog(QMathDelimiter * form);
 public slots:
        void ldelim_clicked(const string & str);
        void rdelim_clicked(const string & str);
@@ -40,7 +40,7 @@ private:
        string right_;
 
        /// owning form
-       QMath * form_;
+       QMathDelimiter * form_;
 };
 
 #endif // QDELIMITERDIALOG_H
index f716081ced7affcf595a3553f0800cc2ece4d471..28d55c980bd89695db032c42b3ee0e5ea61f55b6 100644 (file)
 #include "gettext.h"
 #include "ControlMath2.h"
 #include "QMathDialog.h"
+#include "QMathMatrixDialog.h"
+#include "QDelimiterDialog.h"
 #include "QMath.h"
 
 
-typedef QController<ControlMath2, QView<QMathDialog> > base_class;
+typedef QController<ControlMath2, QView<QMathDialog> > math_base;
 
 
 QMath::QMath(Dialog & parent)
-       : base_class(parent, _("LyX: Math Panel"))
+       : math_base(parent, _("LyX: Math Panel"))
 {}
 
 
@@ -29,3 +31,31 @@ void QMath::build_dialog()
 {
        dialog_.reset(new QMathDialog(this));
 }
+
+
+typedef QController<ControlMath2, QView<QMathMatrixDialog> > matrix_base;
+
+
+QMathMatrix::QMathMatrix(Dialog & parent)
+       : matrix_base(parent, _("LyX: Insert Matrix"))
+{}
+
+
+void QMathMatrix::build_dialog()
+{
+       dialog_.reset(new QMathMatrixDialog(this));
+}
+
+
+typedef QController<ControlMath2, QView<QDelimiterDialog> > delimiter_base;
+
+
+QMathDelimiter::QMathDelimiter(Dialog & parent)
+       : delimiter_base(parent, _("LyX: Insert Delimiter"))
+{}
+
+
+void QMathDelimiter::build_dialog()
+{
+       dialog_.reset(new QDelimiterDialog(this));
+}
index 6b2a3dcf86ed8dbee6958e8a265729d0c6cf288a..f6a467cddf80b34f7c0f48ac092d9cb2b9e3fd74 100644 (file)
@@ -17,6 +17,8 @@
 
 class ControlMath2;
 class QMathDialog;
+class QMathMatrixDialog;
+class QDelimiterDialog;
 
 class QMath : public QController<ControlMath2, QView<QMathDialog> > {
 public:
@@ -31,4 +33,32 @@ private:
        virtual void build_dialog();
 };
 
+
+class QMathMatrix : public QController<ControlMath2, QView<QMathMatrixDialog> > {
+public:
+       friend class QMathMatrixDialog;
+
+       QMathMatrix(Dialog &);
+
+private:
+       virtual void apply() {}
+       virtual void update_contents() {}
+       /// Build the dialog.
+       virtual void build_dialog();
+};
+
+
+class QMathDelimiter : public QController<ControlMath2, QView<QDelimiterDialog> > {
+public:
+       friend class QDelimiterDialog;
+
+       QMathDelimiter(Dialog &);
+
+private:
+       virtual void apply() {}
+       virtual void update_contents() {}
+       /// Build the dialog.
+       virtual void build_dialog();
+};
+
 #endif // QMATH_H
index e8df28acacefd7aed2ff7c1ba5b443db18cc8be5..fd25ec4b3b58cbb8a5905a3b1979062aebfa344b 100644 (file)
@@ -21,8 +21,6 @@
 #include "QMath.h"
 
 #include "iconpalette.h"
-#include "QDelimiterDialog.h"
-#include "QMathMatrixDialog.h"
 
 #include <qapplication.h>
 #include <qwidgetstack.h>
@@ -208,9 +206,7 @@ void QMathDialog::fracClicked()
 
 void QMathDialog::delimiterClicked()
 {
-       // FIXME: leak
-       QDelimiterDialog * d = new QDelimiterDialog(form_);
-       d->show();
+       form_->controller().showDialog("mathdelimiter");
 }
 
 
@@ -235,9 +231,7 @@ void QMathDialog::functionSelected(const QString & str)
 
 void QMathDialog::matrixClicked()
 {
-       // FIXME: leak?
-       QMathMatrixDialog * d = new QMathMatrixDialog(form_);
-       d->show();
+       form_->controller().showDialog("mathmatrix");
 }
 
 
index 75488a5650eb3f1549030b0c13876db9d9c3388a..8a2c54658d5af4e763275eac99b0114f988fa862 100644 (file)
@@ -31,7 +31,7 @@ static char h_align_str[80] = "c";
 static char v_align_c[] = "tcb";
 
 
-QMathMatrixDialog::QMathMatrixDialog(QMath * form)
+QMathMatrixDialog::QMathMatrixDialog(QMathMatrix * form)
        : QMathMatrixDialogBase(0, 0, false, 0),
        form_(form)
 {
index e5a9cb3179d3aa90fdac5c9b82a8a021c50759c6..262a6fe708429b54722c3b5c5784eca3265dd755 100644 (file)
 
 #include "ui/QMathMatrixDialogBase.h"
 
-class QMath;
+class QMathMatrix;
 
 class QMathMatrixDialog : public QMathMatrixDialogBase {
        Q_OBJECT
 public:
-       QMathMatrixDialog(QMath * form);
+       QMathMatrixDialog(QMathMatrix * form);
 public slots:
        void slotOK();
        void slotClose();
@@ -31,7 +31,7 @@ protected slots:
        virtual void rowsChanged(int);
        virtual void change_adaptor();
 private:
-       QMath * form_;
+       QMathMatrix * form_;
 };
 
 #endif // QMATHMATRIXDIALOG_H
index 14dcb4be1a3c7b4efdc036febf302894355b5be1..a0f1cc124102b000a4268726dcc56581f8b85264 100644 (file)
@@ -321,18 +321,19 @@ enum kb_action {
        LFUN_REJECT_ALL_CHANGES,        // Levon 20021016
        LFUN_INSERT_BIBITEM,            // AndrĂ© 14 Feb 2003
        // 245
+       LFUN_DIALOG_SHOW,
        LFUN_DIALOG_SHOW_NEW_INSET,
        LFUN_DIALOG_SHOW_NEXT_INSET,
        LFUN_DIALOG_UPDATE,
        LFUN_DIALOG_HIDE,
-       LFUN_DIALOG_DISCONNECT_INSET,
        // 250
+       LFUN_DIALOG_DISCONNECT_INSET,
        LFUN_INSET_APPLY,
        LFUN_INSET_INSERT,
        LFUN_INSET_MODIFY,
        LFUN_INSET_DIALOG_UPDATE,
-       LFUN_INSET_SETTINGS,
        // 255
+       LFUN_INSET_SETTINGS,
        LFUN_PARAGRAPH_APPLY,
        LFUN_PARAGRAPH_UPDATE,
        LFUN_EXTERNAL_EDIT,
index bf551cd8b55ba52548abb52d28b459770eb39c6b..c97fa8bc82911e17ebf420c7b5a502ef4c86089e 100644 (file)
@@ -1408,6 +1408,10 @@ void LyXFunc::dispatch(FuncRequest const & ev, bool verbose)
                owner->getDialogs().showMathPanel();
                break;
 
+       case LFUN_DIALOG_SHOW:
+               owner->getDialogs().show(argument);
+               break;
+
        case LFUN_DIALOG_SHOW_NEW_INSET: {
                string const & name = argument;
                string data;