fix a nasty crash caused by the new controller for tabular storing and resetting a LyXTabular

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7088 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2003-06-03 01:20:22 +00:00
parent 0b8a489710
commit 96a07595c3
2 changed files with 28 additions and 19 deletions

View File

@ -1,3 +1,7 @@
2003-06-03 John Levon <levon@movementarian.org>
* QTabular.C: fix a crash
2003-06-01 John Levon <levon@movementarian.org> 2003-06-01 John Levon <levon@movementarian.org>
* QGraphicsDialog.C: use relative file browsing * QGraphicsDialog.C: use relative file browsing

View File

@ -319,40 +319,45 @@ void QTabular::closeGUI()
// ugly hack to auto-apply the stuff that hasn't been // ugly hack to auto-apply the stuff that hasn't been
// yet. don't let this continue to exist ... // yet. don't let this continue to exist ...
// Subtle here, we must /not/ apply any changes and
// then refer to tabular, as it will have been freed
// since the changes update the actual controller().tabular()
LyXTabular const & tabular(controller().tabular()); LyXTabular const & tabular(controller().tabular());
// apply the fixed width values // apply the fixed width values
int const cell = controller().getActiveCell(); int const cell = controller().getActiveCell();
bool const multicol(tabular.IsMultiColumn(cell)); bool const multicol(tabular.IsMultiColumn(cell));
string str1 = widgetsToLength(dialog_->widthED, dialog_->widthUnit); string width = widgetsToLength(dialog_->widthED, dialog_->widthUnit);
string str2; string width2;
LyXLength llen(tabular.GetColumnPWidth(cell)); LyXLength llen(tabular.GetColumnPWidth(cell));
LyXLength llenMulti(tabular.GetMColumnPWidth(cell)); LyXLength llenMulti(tabular.GetMColumnPWidth(cell));
if (multicol && !llenMulti.zero()) if (multicol && !llenMulti.zero())
str2 = llenMulti.asString(); width2 = llenMulti.asString();
else if (!multicol && !llen.zero()) else if (!multicol && !llen.zero())
str2 = llen.asString(); width2 = llen.asString();
if (str1 != str2) {
if (multicol)
controller().set(LyXTabular::SET_MPWIDTH, str1);
else
controller().set(LyXTabular::SET_PWIDTH, str1);
}
// apply the special alignment // apply the special alignment
str1 = fromqstr(dialog_->specialAlignmentED->text()); string const sa1 = fromqstr(dialog_->specialAlignmentED->text());
if (multicol) string sa2;
str2 = tabular.GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
else
str2 = tabular.GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
if (str1 != str2) { if (multicol)
sa2 = tabular.GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
else
sa2 = tabular.GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
if (sa1 != sa2) {
if (multicol) if (multicol)
controller().set(LyXTabular::SET_SPECIAL_MULTI, str1); controller().set(LyXTabular::SET_SPECIAL_MULTI, sa1);
else else
controller().set(LyXTabular::SET_SPECIAL_COLUMN, str1); controller().set(LyXTabular::SET_SPECIAL_COLUMN, sa1);
}
if (width != width2) {
if (multicol)
controller().set(LyXTabular::SET_MPWIDTH, width);
else
controller().set(LyXTabular::SET_PWIDTH, width);
} }
} }