* frontends/{qt2,qt4}/QPrefsDialog.C (remove_format):

Prevent deletion of file formats if they are used by a converter 
	and warn the user accordingly.
	Fixes crash (bug 2431).

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13514 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2006-03-28 12:01:31 +00:00
parent eedb4c6821
commit 7b81bf1108
2 changed files with 19 additions and 2 deletions

View File

@ -19,6 +19,8 @@
#include "qcoloritem.h" #include "qcoloritem.h"
#include "qfontexample.h" #include "qfontexample.h"
#include "frontends/Alert.h"
#include "ui/QPrefAsciiModule.h" #include "ui/QPrefAsciiModule.h"
#include "ui/QPrefDateModule.h" #include "ui/QPrefDateModule.h"
#include "ui/QPrefKeyboardModule.h" #include "ui/QPrefKeyboardModule.h"
@ -845,7 +847,14 @@ void QPrefsDialog::remove_format()
int const nr(fileformatsModule->formatsLB->currentItem()); int const nr(fileformatsModule->formatsLB->currentItem());
if (nr < 0) if (nr < 0)
return; return;
form_->formats().erase(form_->formats().get(nr).name()); string const current_text = form_->formats().get(nr).name();
if (form_->converters().formatIsUsed(current_text)) {
Alert::error(_("Format in use"),
_("Cannot remove a Format used by a Converter. "
"Remove the converter first."));
return;
}
form_->formats().erase(current_text);
updateFormats(); updateFormats();
form_->converters().update(form_->formats()); form_->converters().update(form_->formats());

View File

@ -29,6 +29,7 @@
#include "controllers/frnt_lang.h" #include "controllers/frnt_lang.h"
#include "controllers/helper_funcs.h" #include "controllers/helper_funcs.h"
#include "frontends/Alert.h"
#include "frontends/lyx_gui.h" #include "frontends/lyx_gui.h"
#include "QPrefsDialog.h" #include "QPrefsDialog.h"
@ -969,7 +970,14 @@ void QPrefsDialog::remove_format()
int const nr(fileformatsModule->formatsLB->currentItem()); int const nr(fileformatsModule->formatsLB->currentItem());
if (nr < 0) if (nr < 0)
return; return;
form_->formats().erase(form_->formats().get(nr).name()); string const current_text = form_->formats().get(nr).name();
if (form_->converters().formatIsUsed(current_text)) {
Alert::error(_("Format in use"),
_("Cannot remove a Format used by a Converter. "
"Remove the converter first."));
return;
}
form_->formats().erase(current_text);
updateFormats(); updateFormats();
form_->converters().update(form_->formats()); form_->converters().update(form_->formats());