mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-24 17:09:41 +00:00
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:
parent
1038ed69e6
commit
4a2ffc83f8
@ -545,6 +545,8 @@ PrefColors::PrefColors(QPrefs * form, QWidget * parent)
|
|||||||
|
|
||||||
connect(colorChangePB, SIGNAL(clicked()),
|
connect(colorChangePB, SIGNAL(clicked()),
|
||||||
this, SLOT(change_color()));
|
this, SLOT(change_color()));
|
||||||
|
connect(lyxObjectsLW, SIGNAL(itemSelectionChanged()),
|
||||||
|
this, SLOT(change_lyxObjects_selection()));
|
||||||
connect(lyxObjectsLW, SIGNAL(itemActivated(QListWidgetItem*)),
|
connect(lyxObjectsLW, SIGNAL(itemActivated(QListWidgetItem*)),
|
||||||
this, SLOT(change_color()));
|
this, SLOT(change_color()));
|
||||||
}
|
}
|
||||||
@ -570,12 +572,17 @@ void PrefColors::apply(LyXRC & /*rc*/) const
|
|||||||
// problem here.
|
// problem here.
|
||||||
void PrefColors::update(LyXRC const & /*rc*/)
|
void PrefColors::update(LyXRC const & /*rc*/)
|
||||||
{
|
{
|
||||||
|
change_lyxObjects_selection();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrefColors::change_color()
|
void PrefColors::change_color()
|
||||||
{
|
{
|
||||||
int const row = lyxObjectsLW->currentRow();
|
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()));
|
QColor c(QColorDialog::getColor(QColor(color), qApp->focusWidget()));
|
||||||
|
|
||||||
if (c.isValid() && c.name() != color) {
|
if (c.isValid() && c.name() != color) {
|
||||||
@ -588,6 +595,11 @@ void PrefColors::change_color()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrefColors::change_lyxObjects_selection()
|
||||||
|
{
|
||||||
|
colorChangePB->setDisabled(lyxObjectsLW->currentRow() < 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -156,6 +156,7 @@ public:
|
|||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void change_color();
|
void change_color();
|
||||||
|
void change_lyxObjects_selection();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Color_color> lcolors_;
|
std::vector<Color_color> lcolors_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user