]> git.lyx.org Git - lyx.git/commitdiff
Problem: A crash when no color is selected and the "alter" button is pressed.
authorBernhard Roider <bernhard.roider@sonnenkinder.org>
Wed, 9 May 2007 20:09:03 +0000 (20:09 +0000)
committerBernhard Roider <bernhard.roider@sonnenkinder.org>
Wed, 9 May 2007 20:09:03 +0000 (20:09 +0000)
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

src/frontends/qt4/QPrefs.cpp
src/frontends/qt4/QPrefs.h

index cbc9a373c0a794bb79b8c64c0bfb3d1774822320..8566d7868b1a4bda32b1395d46c49158d36f7f37 100644 (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);
+}
+
 
 /////////////////////////////////////////////////////////////////////
 //
index 6efdcadbdc8c9ae1982b225ac6a89224d58fd95a..0757813e9e2b97af6c6de3503035047fbb7b948f 100644 (file)
@@ -156,6 +156,7 @@ public:
 
 private Q_SLOTS:
        void change_color();
+       void change_lyxObjects_selection();
 
 private:
        std::vector<Color_color> lcolors_;