[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdeedu/parley/src/practice
From: Frederik Gladhorn <frederik.gladhorn () gmx ! de>
Date: 2007-09-30 19:56:51
Message-ID: 1191182211.035857.7228.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 719279 by gladhorn:
Fix nasty crash when suggestions is turned on. Crashed because of an unchecked cast \
which fails since KComboBox uses QLineEdit instead of KLineEdit for KDE4.
M +24 -13 writtenpracticedialog.cpp
--- trunk/KDE/kdeedu/parley/src/practice/writtenpracticedialog.cpp #719278:719279
@@ -73,10 +73,13 @@
bool split = Prefs::split();
fields = Prefs::fields();
- if (! split || fields < 1)
+ if (! split || fields < 1) {
fields = 1;
- else if (fields > 10)
- fields = 10;
+ } else {
+ if (fields > 10) {
+ fields = 10;
+ }
+ }
QVBoxLayout * vb = new QVBoxLayout(mw->TranslationFrame);
vb->setMargin(0);
@@ -97,8 +100,8 @@
combo->setInsertPolicy(QComboBox::NoInsert);
combo->setDuplicatesEnabled(false);
vb->addWidget(combo);
- connect(combo, SIGNAL(textChanged(const QString&)), \
SLOT(slotTransChanged(const QString&)));
- connect(combo->lineEdit(), SIGNAL(lostFocus()), \
SLOT(slotTransLostFocus())); + connect(combo, SIGNAL(editTextChanged(const \
QString&)), SLOT(slotTransChanged(const QString&))); + \
connect(combo->lineEdit(), SIGNAL(editingFinished()), SLOT(slotTransLostFocus())); }
} else {
for (i = 0; i < fields; i ++) {
@@ -121,7 +124,6 @@
int m_queryOriginalColumn = Prefs::fromIdentifier();
int m_queryTranslationColumn = Prefs::toIdentifier();
-
if (suggestions) {
for (i = 0; i < m_doc->entryCount(); i ++) {
KEduVocExpression* expr = m_doc->entry(i);
@@ -142,6 +144,8 @@
vocabulary.removeAt(k --);
}
+kDebug() << " added " << vocabulary.count() << " suggestions";
+
mw->imageGraphicsView->setVisible(false);
KConfigGroup cg(KGlobal::config(), "RandomQueryDialog");
@@ -380,7 +384,6 @@
kDebug() << " length " << length << "text " << field->text();
length++;
}
-
if (length >= translations[i].length()) {
field->setText(translations[i]);
verifyField(field, translations[i]);
@@ -423,19 +426,27 @@
{
mw->verify->setDefault(true);
bool suggestions = Prefs::suggestions();
- KComboBox* combo = sender() ? qobject_cast<KComboBox*>(sender()) : 0;
- KLineEdit* senderedit = sender() ? qobject_cast<KLineEdit*>(sender()) : 0;
+ KComboBox* combo = qobject_cast<KComboBox*>(sender());
+ KLineEdit* senderedit = qobject_cast<KLineEdit*>(sender());
+
if (suggestions && combo) {
- KLineEdit* edit = qobject_cast<KLineEdit*>(combo->lineEdit());
+ QLineEdit* edit = qobject_cast<QLineEdit*>(combo->lineEdit());
+ if ( !edit ) {
+ return; // cast failed
+ }
resetQueryWidget(edit);
suggestion_hint = ! edit->text().isEmpty() && edit->text().length() <= 10;
if (suggestion_hint)
mw->status->setText(i18n("Press F5 for a list of translations starting \
with '%1'\n"
"Press F6 for a list of translations \
containing '%1'", edit->text()));
- else
+ else {
mw->status->clear();
- } else if (! suggestions && senderedit)
- resetQueryWidget(senderedit);
+ }
+ } else {
+ if ( (!suggestions) && senderedit) {
+ resetQueryWidget(senderedit);
+ }
+ }
}
void WrittenPracticeDialog::slotTransLostFocus()
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic