aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorImran Zaman <imran.zaman@tieto.com>2010-03-05 12:32:44 +0200
committerImran Zaman <imran.zaman@tieto.com>2010-03-05 12:45:39 +0200
commitf03de84bfec0e6e54213a97a3111eed15be99bca (patch)
tree376a77cb2e8d1829052b6ae74f721ba6e703eb2f
parentc315f5309059e05c1e31d0efa525e9d12b0c2185 (diff)
Fixes: Fixes number of potential issues reported through coverity
RevBy: Danial, Dominik Details: This patch fixes some potential issues reported through coverity.
-rw-r--r--plainqt/style/qtmaemo6teststyle.cpp30
-rw-r--r--src/events/duiorientationtracker.cpp4
-rw-r--r--src/mashup/mashup/duiappletinventory.cpp7
-rw-r--r--src/mashup/mashup/duifiledatastore.cpp5
-rw-r--r--src/scene/duiscenemanager.cpp5
-rw-r--r--src/widgets/duiapplicationpage.cpp1
6 files changed, 29 insertions, 23 deletions
diff --git a/plainqt/style/qtmaemo6teststyle.cpp b/plainqt/style/qtmaemo6teststyle.cpp
index b50a334d..26519afb 100644
--- a/plainqt/style/qtmaemo6teststyle.cpp
+++ b/plainqt/style/qtmaemo6teststyle.cpp
@@ -36,24 +36,26 @@ QtMaemo6TestStyleEventFilter::QtMaemo6TestStyleEventFilter(QtMaemo6TestStyle *pa
bool QtMaemo6TestStyleEventFilter::eventFilter(QObject *obj, QEvent *event)
{
QWidget *widget = qobject_cast<QWidget *>(obj);
- QWidget *parent = qobject_cast<QWidget *>(widget->parent());
-
- switch (event->type()) {
- case QEvent::Show: {
- if (NULL != widget && (qobject_cast<QMainWindow *>(widget) || qobject_cast<QDialog *>(widget))) {
- //QMainWindow* main_window(qobject_cast<QMainWindow*>(widget));
- //if (NULL != main_window) {
- if (widget->windowFlags() & Qt::Window) {
- if (!parent || !qobject_cast<QtMaemo6WindowDecoration *>(parent)) {
- parent = m_style->m_windowDecoration = new QtMaemo6WindowDecoration(widget);
+ if (widget) {
+ QWidget *parent = qobject_cast<QWidget *>(widget->parent());
+
+ switch (event->type()) {
+ case QEvent::Show: {
+ if (NULL != widget && (qobject_cast<QMainWindow *>(widget) || qobject_cast<QDialog *>(widget))) {
+ //QMainWindow* main_window(qobject_cast<QMainWindow*>(widget));
+ //if (NULL != main_window) {
+ if (widget->windowFlags() & Qt::Window) {
+ if (!parent || !qobject_cast<QtMaemo6WindowDecoration *>(parent)) {
+ parent = m_style->m_windowDecoration = new QtMaemo6WindowDecoration(widget);
+ }
+ parent->showMaximized();
}
- parent->showMaximized();
}
}
- }
- break;
- default:
break;
+ default:
+ break;
+ }
}
// standard event processing
return QObject::eventFilter(obj, event);
diff --git a/src/events/duiorientationtracker.cpp b/src/events/duiorientationtracker.cpp
index 3870a5d7..808290c2 100644
--- a/src/events/duiorientationtracker.cpp
+++ b/src/events/duiorientationtracker.cpp
@@ -65,12 +65,11 @@ void DuiOrientationTrackerPrivate::topEdgeChanged()
{
#ifdef HAVE_CONTEXTSUBSCRIBER
Dui::OrientationAngle angle;
- Dui::Orientation orientation;
+ Dui::Orientation orientation = Dui::Landscape;
QString edge = topEdgeProperty.value().toString();
if (edge == "top") {
angle = Dui::Angle0;
- orientation = Dui::Landscape;
} else if (edge == "left") {
angle = Dui::Angle270;
orientation = Dui::Portrait;
@@ -79,7 +78,6 @@ void DuiOrientationTrackerPrivate::topEdgeChanged()
orientation = Dui::Portrait;
} else if (edge == "bottom") {
angle = Dui::Angle180;
- orientation = Dui::Landscape;
} else {
angle = currentAngle;
}
diff --git a/src/mashup/mashup/duiappletinventory.cpp b/src/mashup/mashup/duiappletinventory.cpp
index b0b9f6e4..84b00266 100644
--- a/src/mashup/mashup/duiappletinventory.cpp
+++ b/src/mashup/mashup/duiappletinventory.cpp
@@ -105,10 +105,13 @@ QStringList DuiAppletInventory::categories() const
void DuiAppletInventory::appletButtonClicked()
{
DuiAppletButton *button = dynamic_cast<DuiAppletButton *>(sender());
+
Q_ASSERT(button != NULL);
- mashupCanvas->appletInstanceManager()->instantiateApplet(button->metadataFilename());
- emit hideAppletInventory();
+ if (button) {
+ mashupCanvas->appletInstanceManager()->instantiateApplet(button->metadataFilename());
+ emit hideAppletInventory();
+ }
}
void DuiAppletInventory::appletPathChanged(const QString &path)
diff --git a/src/mashup/mashup/duifiledatastore.cpp b/src/mashup/mashup/duifiledatastore.cpp
index c1e3db92..7e78625d 100644
--- a/src/mashup/mashup/duifiledatastore.cpp
+++ b/src/mashup/mashup/duifiledatastore.cpp
@@ -169,7 +169,6 @@ bool DuiFileDataStore::setValue(const QString &key, const QVariant &value)
// QSettings has some kind of a cache so we'll prevent any temporary writes
// by checking if the data can be actually stored before doing anything
if (isWritable() && settings.contains(key)) {
- bool originalValueSet = settings.contains(key);
QVariant originalValue = settings.value(key);
settings.setValue(key, value);
bool syncOk = doSync(settings, watcher);
@@ -180,11 +179,9 @@ bool DuiFileDataStore::setValue(const QString &key, const QVariant &value)
settingsSnapshot[key] = value;
emit valueChanged(key, value);
}
- } else if (originalValueSet) {
+ } else {
// if sync fails, make sure the value in memory is the original
settings.setValue(key, originalValue);
- } else {
- settings.remove(key);
}
}
return returnValue;
diff --git a/src/scene/duiscenemanager.cpp b/src/scene/duiscenemanager.cpp
index b2e1949f..d469d54c 100644
--- a/src/scene/duiscenemanager.cpp
+++ b/src/scene/duiscenemanager.cpp
@@ -1005,6 +1005,11 @@ void DuiSceneManager::showWindowNow(DuiSceneWindow *window, DuiSceneWindow::Dele
int DuiSceneManager::execDialog(DuiDialog *dialog)
{
+ if (dialog == 0) {
+ duiWarning("DuiSceneManager") << "Invalid dialog instance";
+ return DuiDialog::Rejected;
+ }
+
QEventLoop eventLoop;
QPointer<DuiDialog> dialog_ptr = dialog;
connect(dialog, SIGNAL(finished(int)), &eventLoop, SLOT(quit()));
diff --git a/src/widgets/duiapplicationpage.cpp b/src/widgets/duiapplicationpage.cpp
index 757f160c..a1bdb658 100644
--- a/src/widgets/duiapplicationpage.cpp
+++ b/src/widgets/duiapplicationpage.cpp
@@ -336,6 +336,7 @@ void DuiApplicationPage::actionEvent(QActionEvent *e)
case QEvent::ActionRemoved: {
if (action)
action->disconnect(this);
+ //fall through is intentional.
}
case QEvent::ActionAdded: {
emit actionUpdated(e);