Abdelrazak Younes wrote:
Jürgen Spitzmüller wrote:
Abdelrazak Younes wrote:
Here is a radical solution. I should have thought about this earlier!
The dialog will be updated in any case by the LyXFunc::dispatch() method
so the updating done in InsetTabular::dispatch() is superfluous.

This patch
- doesn't compile (is_deleted_ is still used in the destructor)

Yes, I was about to send an updated patch when I noticed this:

- breaks the tabular dialog (try to check something in the dialog, e.g. "multicolumn"; it's not possible).

This is because the controller/dialog/dispatch is so brain damaged that I wonder how it worked up until now.

So we need to investigate further.

I am going to try to put the updateDialog() method in the Controller instead and see how it goes.

I got a much better solution attached.

Abdel.
Index: frontends/controllers/ControlTabular.cpp
===================================================================
--- frontends/controllers/ControlTabular.cpp    (revision 19100)
+++ frontends/controllers/ControlTabular.cpp    (working copy)
@@ -32,16 +32,24 @@
 {
        // try to get the current cell
        BufferView const * const bv = kernel().bufferview();
+       InsetTabular const * current_inset = 0;
        if (bv) {
                Cursor const & cur = bv->cursor();
                // get the innermost tabular inset;
                // assume that it is "ours"
                for (int i = cur.depth() - 1; i >= 0; --i)
                        if (cur[i].inset().lyxCode() == Inset::TABULAR_CODE) {
+                               current_inset = static_cast<InsetTabular 
*>(&cur[i].inset());
                                active_cell_ = cur[i].idx();
                                break;
                        }
        }
+
+       if (current_inset && data.empty()) {
+               params_.reset(new Tabular(current_inset->tabular));
+               return true;
+       }
+
        InsetTabular tmp(kernel().buffer());
        InsetTabularMailer::string2params(data, tmp);
        params_.reset(new Tabular(tmp.tabular));
Index: frontends/qt4/QTabular.cpp
===================================================================
--- frontends/qt4/QTabular.cpp  (revision 19100)
+++ frontends/qt4/QTabular.cpp  (working copy)
@@ -633,6 +633,8 @@
 
 void QTabular::update_contents()
 {
+       controller().initialiseParams(string());
+
        Tabular const & tabular(controller().tabular());
        Tabular::idx_type const cell = controller().getActiveCell();
 
Index: insets/InsetTabular.cpp
===================================================================
--- insets/InsetTabular.cpp     (revision 19102)
+++ insets/InsetTabular.cpp     (working copy)
@@ -2877,20 +2877,19 @@
 InsetTabular::InsetTabular(Buffer const & buf, row_type rows,
                           col_type columns)
        : tabular(buf.params(), max(rows, row_type(1)),
-         max(columns, col_type(1))), buffer_(&buf), scx_(0), is_deleted_(false)
+         max(columns, col_type(1))), buffer_(&buf), scx_(0)
 {}
 
 
 InsetTabular::InsetTabular(InsetTabular const & tab)
        : Inset(tab), tabular(tab.tabular),
-               buffer_(tab.buffer_), scx_(0), is_deleted_(false)
+               buffer_(tab.buffer_), scx_(0)
 {}
 
 
 InsetTabular::~InsetTabular()
 {
        InsetTabularMailer(*this).hideDialog();
-       is_deleted_ = true;
 }
 
 
@@ -3491,11 +3490,6 @@
                cell(cur.idx())->dispatch(cur, cmd);
                break;
        }
-
-       // FIXME: this accesses the position cache before it is initialized
-       //resetPos(cur);
-       if (!is_deleted_)
-               InsetTabularMailer(*this).updateDialog(&cur.bv());
 }
 
 
Index: insets/InsetTabular.h
===================================================================
--- insets/InsetTabular.h       (revision 19100)
+++ insets/InsetTabular.h       (working copy)
@@ -824,9 +824,6 @@
        mutable idx_type first_visible_cell;
        ///
        mutable int scx_;
-       /// Ugly boolean used when this inset is dissolved and
-       /// InsetTabularMailer should not be used.
-       bool is_deleted_;
 };
 
 

Reply via email to