fix tapetool crash (#2352)
This commit is contained in:
parent
6985407a96
commit
102e065515
3 changed files with 12 additions and 7 deletions
|
@ -25,6 +25,8 @@ class TPaletteHandle;
|
|||
namespace DVGui {
|
||||
|
||||
class DVAPI StyleIndexLineEdit : public LineEdit {
|
||||
Q_OBJECT
|
||||
|
||||
TPaletteHandle *m_pltHandle;
|
||||
|
||||
public:
|
||||
|
|
|
@ -868,15 +868,16 @@ void StyleIndexFieldAndChip::onValueChanged(const QString &changedText) {
|
|||
// Aware of both "current" and translated string
|
||||
if (!QString("current").contains(changedText) &&
|
||||
!StyleIndexLineEdit::tr("current").contains(changedText)) {
|
||||
int index = changedText.toInt();
|
||||
TPalette *plt = m_pltHandle->getPalette();
|
||||
int indexCount = plt->getStyleCount();
|
||||
if (index > indexCount)
|
||||
style = QString::number(indexCount - 1);
|
||||
int index = changedText.toInt();
|
||||
TPalette *plt = m_pltHandle->getPalette();
|
||||
if (plt && index > plt->getStyleCount())
|
||||
style = QString::number(plt->getStyleCount() - 1);
|
||||
else
|
||||
style = text();
|
||||
}
|
||||
m_property->setValue(style.toStdWString());
|
||||
m_property->setValue(style.toStdWString());
|
||||
} else
|
||||
m_property->setValue(changedText.toStdWString());
|
||||
|
||||
repaint();
|
||||
// synchronize the state with the same widgets in other tool option bars
|
||||
if (m_toolHandle) m_toolHandle->notifyToolChanged();
|
||||
|
|
|
@ -30,6 +30,8 @@ StyleIndexLineEdit::~StyleIndexLineEdit() {}
|
|||
void StyleIndexLineEdit::paintEvent(QPaintEvent *pe) {
|
||||
QLineEdit::paintEvent(pe);
|
||||
|
||||
if (!m_pltHandle->getPalette()) return;
|
||||
|
||||
TColorStyle *style;
|
||||
// Aware of both "current" and translated string
|
||||
if (QString("current").contains(text()) || tr("current").contains(text()))
|
||||
|
|
Loading…
Reference in a new issue