[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kexi] src: Fix control flow issues, invalid expressions, type issues
From:       Jaroslaw Staniek <staniek () kde ! org>
Date:       2016-02-29 23:12:16
Message-ID: E1aaWzA-0000sv-02 () scm ! kde ! org
[Download RAW message or body]

Git commit 1f34bd144ab1cb970aa3293d607d78d8a2d7dd56 by Jaroslaw Staniek.
Committed on 29/02/2016 at 23:07.
Pushed by staniek into branch 'master'.

Fix control flow issues, invalid expressions, type issues

(from Coverity reports)

M  +2    -1    src/formeditor/form.cpp
M  +10   -10   src/formeditor/richtextdialog.cpp
M  +17   -12   src/main/KexiMenuWidget.cpp
M  +1    -1    src/main/KexiSearchLineEdit.cpp
M  +3    -7    src/plugins/tables/kexitabledesignerview.cpp
M  +2    -1    src/widget/KexiConnectionSelectorWidget.cpp
M  +3    -2    src/widget/dataviewcommon/kexidataprovider.cpp
M  +3    -3    src/widget/kexislider.cpp
M  +2    -2    src/widget/navigator/KexiProjectNavigator.cpp

http://commits.kde.org/kexi/1f34bd144ab1cb970aa3293d607d78d8a2d7dd56

diff --git a/src/formeditor/form.cpp b/src/formeditor/form.cpp
index 5e46ec3..4088eaa 100644
--- a/src/formeditor/form.cpp
+++ b/src/formeditor/form.cpp
@@ -476,6 +476,7 @@ void Form::selectWidgets(const QList<QWidget*>& widgets, \
WidgetSelectionFlags fl  flags = LastSelection;
         }
         selectWidget(widget, flags);
+        ++i;
     }
 }
 
@@ -1562,7 +1563,7 @@ void Form::createPropertiesForWidget(QWidget *w)
             else {
                 int realType = subwinfo->customTypeForProperty(propertyName);
                 if (realType == KProperty::Invalid || realType == KProperty::Auto) {
-                    realType = meta.type();
+                    realType = int(meta.type());
                 }
                 newProp = new KProperty(
                     propertyName,
diff --git a/src/formeditor/richtextdialog.cpp b/src/formeditor/richtextdialog.cpp
index a2c40be..7cf2489 100644
--- a/src/formeditor/richtextdialog.cpp
+++ b/src/formeditor/richtextdialog.cpp
@@ -179,19 +179,19 @@ RichTextDialog::slotActionTriggered(QAction* action)
     else if (action == d->superscriptTextAction) {
         if (isChecked && d->subscriptTextAction->isChecked()) {
             d->subscriptTextAction->setChecked(false);
-            QTextCharFormat currentCharFormat = d->edit->currentCharFormat();
-            currentCharFormat.setVerticalAlignment(
-                isChecked ? QTextCharFormat::AlignSuperScript : \
                QTextCharFormat::AlignNormal);
-            d->edit->setCurrentCharFormat(currentCharFormat);
         }
+        QTextCharFormat currentCharFormat = d->edit->currentCharFormat();
+        currentCharFormat.setVerticalAlignment(
+            isChecked ? QTextCharFormat::AlignSuperScript : \
QTextCharFormat::AlignNormal); +        \
d->edit->setCurrentCharFormat(currentCharFormat);  } else if (action == \
                d->subscriptTextAction) {
-        if (isChecked && d->subscriptTextAction->isChecked()) {
-            d->subscriptTextAction->setChecked(false);
-            QTextCharFormat currentCharFormat = d->edit->currentCharFormat();
-            currentCharFormat.setVerticalAlignment(
-                isChecked ? QTextCharFormat::AlignSubScript : \
                QTextCharFormat::AlignNormal);
-            d->edit->setCurrentCharFormat(currentCharFormat);
+        if (isChecked && d->superscriptTextAction->isChecked()) {
+            d->superscriptTextAction->setChecked(false);
         }
+        QTextCharFormat currentCharFormat = d->edit->currentCharFormat();
+        currentCharFormat.setVerticalAlignment(
+            isChecked ? QTextCharFormat::AlignSubScript : \
QTextCharFormat::AlignNormal); +        \
d->edit->setCurrentCharFormat(currentCharFormat);  } else if (action == \
d->alignLeftAction) {  if (isChecked)
             d->edit->setAlignment(Qt::AlignLeft);
diff --git a/src/main/KexiMenuWidget.cpp b/src/main/KexiMenuWidget.cpp
index 2e9ab83..27795f0 100644
--- a/src/main/KexiMenuWidget.cpp
+++ b/src/main/KexiMenuWidget.cpp
@@ -928,7 +928,10 @@ void KexiMenuWidget::setIcon(const QIcon &icon)
 //actually performs the scrolling
 void KexiMenuWidgetPrivate::scrollMenu(QAction *action, \
QMenuScroller::ScrollLocation location, bool active)  {
-    return;
+    Q_UNUSED(action)
+    Q_UNUSED(location)
+    Q_UNUSED(active)
+#if 0
     if (!scroll || !scroll->scrollFlags)
         return;
     updateActionRects();
@@ -1037,11 +1040,14 @@ void KexiMenuWidgetPrivate::scrollMenu(QAction *action, \
QMenuScroller::ScrollLoc  setCurrentAction(action);
 
     q->update();     //issue an update so we see all the new state..
+#endif
 }
 
 void KexiMenuWidgetPrivate::scrollMenu(QMenuScroller::ScrollLocation location, bool \
active)  {
-    return;
+    Q_UNUSED(location)
+    Q_UNUSED(active)
+#if 0
     updateActionRects();
     QList<QAction*> actionsList = q->actions();
     if(location == QMenuScroller::ScrollBottom) {
@@ -1075,12 +1081,16 @@ void \
KexiMenuWidgetPrivate::scrollMenu(QMenuScroller::ScrollLocation location, b  }
         }
     }
+#endif
 }
 
 //only directional
 void KexiMenuWidgetPrivate::scrollMenu(QMenuScroller::ScrollDirection direction, \
bool page, bool active)  {
-    return;
+    Q_UNUSED(direction)
+    Q_UNUSED(page)
+    Q_UNUSED(active)
+#if 0
     if (!scroll || !(scroll->scrollFlags & direction)) //not really possible...
         return;
     updateActionRects();
@@ -1122,6 +1132,7 @@ void \
KexiMenuWidgetPrivate::scrollMenu(QMenuScroller::ScrollDirection direction,  \
q->update();  }
     }
+#endif
 }
 
 /* This is poor-mans eventfilters. This avoids the use of
@@ -2752,15 +2763,9 @@ void KexiMenuWidget::keyPressEvent(QKeyEvent *e)
     case Qt::Key_Left: {
         if (d->currentAction && !d->scroll) {
             QAction *nextAction = 0;
-            if (key == Qt::Key_Left) {
-                QRect actionR = d->actionRect(d->currentAction);
-                for(int x = actionR.left()-1; !nextAction && x >= 0; x--)
-                    nextAction = d->actionAt(QPoint(x, actionR.center().y()));
-            } else {
-                QRect actionR = d->actionRect(d->currentAction);
-                for(int x = actionR.right()+1; !nextAction && x < width(); x++)
-                    nextAction = d->actionAt(QPoint(x, actionR.center().y()));
-            }
+            QRect actionR = d->actionRect(d->currentAction);
+            for(int x = actionR.left()-1; !nextAction && x >= 0; x--)
+                nextAction = d->actionAt(QPoint(x, actionR.center().y()));
             if (nextAction) {
                 d->setCurrentAction(nextAction, /*popup*/-1, \
KexiMenuWidget::SelectedFromKeyboard);  key_consumed = true;
diff --git a/src/main/KexiSearchLineEdit.cpp b/src/main/KexiSearchLineEdit.cpp
index f09d87f..dc446b8 100644
--- a/src/main/KexiSearchLineEdit.cpp
+++ b/src/main/KexiSearchLineEdit.cpp
@@ -554,8 +554,8 @@ void KexiSearchLineEdit::keyPressEvent(QKeyEvent *event)
         case Qt::Key_Select:
             if (!QApplication::keypadNavigationEnabled())
                 break;
-#endif
             d->completer->popup()->hide(); // just hide. will end up propagating to \
parent +#endif
         default:
             break; // normal key processing
         }
diff --git a/src/plugins/tables/kexitabledesignerview.cpp \
b/src/plugins/tables/kexitabledesignerview.cpp index 721e124..7670fcc 100644
--- a/src/plugins/tables/kexitabledesignerview.cpp
+++ b/src/plugins/tables/kexitabledesignerview.cpp
@@ -847,13 +847,9 @@ void KexiTableDesignerView::slotRecordUpdated(KDbRecordData \
*data)  //refresh property editor:
         propertySetSwitched();
 
-        if (record >= 0) {
-            if (d->addHistoryCommand_in_slotRecordUpdated_enabled) {
-                addHistoryCommand(new InsertFieldCommand(0, this, record, *newSet \
                /*propertySet()*/),    //, field /*will be copied*/
-                                  false /* !execute */);
-            }
-        } else {
-            qWarning() << "record # not found  !";
+        if (d->addHistoryCommand_in_slotRecordUpdated_enabled) {
+            addHistoryCommand(new InsertFieldCommand(0, this, record, *newSet \
/*propertySet()*/),    //, field /*will be copied*/ +                              \
false /* !execute */);  }
     }
 }
diff --git a/src/widget/KexiConnectionSelectorWidget.cpp \
b/src/widget/KexiConnectionSelectorWidget.cpp index 2b7e50f..786c3a7 100644
--- a/src/widget/KexiConnectionSelectorWidget.cpp
+++ b/src/widget/KexiConnectionSelectorWidget.cpp
@@ -303,9 +303,10 @@ QString KexiConnectionSelectorWidget::selectedFileName()
         const QString firstUrl(fileWidget->locationEdit()->lineEdit()->text());
         if (QDir::isAbsolutePath(firstUrl))
             path = QUrl::fromLocalFile(firstUrl);
-        else
+        else {
             path = path.adjusted(QUrl::StripTrailingSlash);
             path.setPath(path.path() + '/' + (firstUrl));
+        }
         return path.toLocalFile();
     }
 
diff --git a/src/widget/dataviewcommon/kexidataprovider.cpp \
b/src/widget/dataviewcommon/kexidataprovider.cpp index 6d1d3c9..18945a4 100644
--- a/src/widget/dataviewcommon/kexidataprovider.cpp
+++ b/src/widget/dataviewcommon/kexidataprovider.cpp
@@ -94,9 +94,10 @@ void KexiFormDataProvider::fillDataItems(KDbRecordData *data, bool \
cursorAtNewRe  indexForVisibleLookupValue = -1; //no
         const QVariant value(data->at(it.value()));
         QVariant visibleLookupValue;
-        if (indexForVisibleLookupValue != -1 && (int)data->count() > \
indexForVisibleLookupValue) +        if (indexForVisibleLookupValue != -1 && \
(int)data->count() > indexForVisibleLookupValue) {  visibleLookupValue = \
                data->at(indexForVisibleLookupValue);
-            qDebug() << "fill data of '" << itemIface->dataSource() <<  "' at idx=" \
<< it.value() +        }
+        qDebug() << "fill data of '" << itemIface->dataSource() <<  "' at idx=" << \
it.value()  << " data=" << value
             << (indexForVisibleLookupValue != -1
                  ? QString(" SPECIAL: indexForVisibleLookupValue=%1 \
                visibleValue=%2")
diff --git a/src/widget/kexislider.cpp b/src/widget/kexislider.cpp
index 7335173..0121a51 100644
--- a/src/widget/kexislider.cpp
+++ b/src/widget/kexislider.cpp
@@ -91,15 +91,15 @@ protected:
         int current(option.minimum);
         int nextLabel = current;
 
-        QFontMetrics fm(font());
+        const QFontMetrics fm(fontMetrics());
         int h = fm.height() + 3;
         int w = fm.width(QString::number(option.maximum)) + 3;
 
         if(available<w)
             nextLabel = -1;
 
-        float i = available/(orientation() == Qt::Horizontal ? w : h);
-        float t = option.maximum/interval;
+        qreal i = qreal(available) / qreal(orientation() == Qt::Horizontal ? w : h);
+        qreal t = qreal(option.maximum)/qreal(interval);
         int valStep = t/ i + 1;
 
         // Since there is no subrect for tickmarks do a translation here.
diff --git a/src/widget/navigator/KexiProjectNavigator.cpp \
b/src/widget/navigator/KexiProjectNavigator.cpp index f3501d5..b0469e7 100644
--- a/src/widget/navigator/KexiProjectNavigator.cpp
+++ b/src/widget/navigator/KexiProjectNavigator.cpp
@@ -345,7 +345,7 @@ void KexiProjectNavigator::slotSelectionChanged(const \
QModelIndex& i)  return;
     }
 
-    const bool gotitem = it && it->partItem();
+    const bool gotitem = it->partItem();
 //! @todo also check if the item is not read only
     if (d->deleteAction) {
         d->deleteAction->setEnabled(gotitem && !d->readOnly);
@@ -379,7 +379,7 @@ void KexiProjectNavigator::slotSelectionChanged(const \
QModelIndex& i)  #endif
         }
     }
-    emit selectionChanged(it ? it->partItem() : 0);
+    emit selectionChanged(it->partItem());
 }
 
 void KexiProjectNavigator::slotRemove()


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic