Problem: A crash when no color is selected and the "alter" button is pressed.

Solution: Disable the alter button if no item is selected and add an additional test for a valid index.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18247 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Bernhard Roider 2007-05-09 20:09:03 +00:00
parent 1038ed69e6
commit 4a2ffc83f8
2 changed files with 14 additions and 1 deletions

View File

@ -545,6 +545,8 @@ PrefColors::PrefColors(QPrefs * form, QWidget * parent)
connect(colorChangePB, SIGNAL(clicked()),
this, SLOT(change_color()));
connect(lyxObjectsLW, SIGNAL(itemSelectionChanged()),
this, SLOT(change_lyxObjects_selection()));
connect(lyxObjectsLW, SIGNAL(itemActivated(QListWidgetItem*)),
this, SLOT(change_color()));
}
@ -570,12 +572,17 @@ void PrefColors::apply(LyXRC & /*rc*/) const
// problem here.
void PrefColors::update(LyXRC const & /*rc*/)
{
change_lyxObjects_selection();
}
void PrefColors::change_color()
{
int const row = lyxObjectsLW->currentRow();
QString color = newcolors_[row];
// just to be sure
if (row < 0) return;
QString const color = newcolors_[row];
QColor c(QColorDialog::getColor(QColor(color), qApp->focusWidget()));
if (c.isValid() && c.name() != color) {
@ -588,6 +595,11 @@ void PrefColors::change_color()
}
}
void PrefColors::change_lyxObjects_selection()
{
colorChangePB->setDisabled(lyxObjectsLW->currentRow() < 0);
}
/////////////////////////////////////////////////////////////////////
//

View File

@ -156,6 +156,7 @@ public:
private Q_SLOTS:
void change_color();
void change_lyxObjects_selection();
private:
std::vector<Color_color> lcolors_;