(d->iface)->metaObject()->className());
+ thisWidget->metaObject()->className());
}
KexiContextMenuUtils::updateTitle(
menu, d->iface->columnInfo()->captionOrAliasOrName(),
diff --git a/src/plugins/importexport/csv/kexicsvimportdialog.cpp b/src/plugins/importexport/csv/kexicsvimportdialog.cpp
--- a/src/plugins/importexport/csv/kexicsvimportdialog.cpp
+++ b/src/plugins/importexport/csv/kexicsvimportdialog.cpp
@@ -432,18 +432,22 @@
KexiPart::Part *part = Kexi::partManager().partForPluginId("org.kexi-project.table");
KDbObject tmp;
- tristate res = m_conn->loadObjectData(
+ tristate res = (part && part->info()) ? m_conn->loadObjectData(
project->typeIdForPluginId(part->info()->pluginId()),
m_newTableWidget->nameText(),
- &tmp);
+ &tmp)
+ : false;
if (res == true) {
KMessageBox::information(this,
""
+ part->i18nMessage("Object %1 already exists.", 0)
.subs(m_newTableWidget->nameText()).toString()
+ "
" + xi18n("Please choose other name.") + "
"
);
return;
+ } else if (res == false) {
+ qFatal("Plugin org.kexi-project.table not found");
+ return;
}
} else {
m_partItemForSavedTable = m_tablesList->selectedPartItem();
diff --git a/src/plugins/importexport/csv/kexicsvwidgets.cpp b/src/plugins/importexport/csv/kexicsvwidgets.cpp
--- a/src/plugins/importexport/csv/kexicsvwidgets.cpp
+++ b/src/plugins/importexport/csv/kexicsvwidgets.cpp
@@ -71,7 +71,6 @@
QString commentSymbol;
QVector availablecommentSymbols;
KComboBox* combo;
- QLineEdit* commentSymbolEdit;
};
KexiCSVDelimiterWidget::KexiCSVDelimiterWidget(bool lineEditOnBottom, QWidget * parent)
diff --git a/src/plugins/queries/kexiquerydesignerguieditor.cpp b/src/plugins/queries/kexiquerydesignerguieditor.cpp
--- a/src/plugins/queries/kexiquerydesignerguieditor.cpp
+++ b/src/plugins/queries/kexiquerydesignerguieditor.cpp
@@ -396,9 +396,9 @@
//build query schema
KexiQueryPart::TempData * temp = tempData();
if (temp->query()) {
- KexiView *queryDataView = window()->viewForMode(Kexi::DataViewMode);
+ KexiQueryView *queryDataView = dynamic_cast(window()->viewForMode(Kexi::DataViewMode));
if (queryDataView) {
- dynamic_cast(queryDataView)->setData(0);
+ queryDataView->setData(0);
}
temp->clearQuery();
} else {
diff --git a/src/plugins/queries/kexiqueryview.cpp b/src/plugins/queries/kexiqueryview.cpp
--- a/src/plugins/queries/kexiqueryview.cpp
+++ b/src/plugins/queries/kexiqueryview.cpp
@@ -122,7 +122,7 @@
const tristate result = executeQuery(querySchema);
if (true != result)
return result;
- } else if (mode == Kexi::DesignViewMode || Kexi::TextViewMode) {
+ } else if (mode == Kexi::DesignViewMode || mode == Kexi::TextViewMode) {
KexiQueryPart::TempData * temp = static_cast(window()->data());
const tristate result = executeQuery(temp->query());
if (true != result)
@@ -136,20 +136,28 @@
bool *cancel)
{
KexiView * view = window()->viewThatRecentlySetDirtyFlag();
- if (dynamic_cast(view))
- return dynamic_cast(view)->storeNewData(object, options, cancel);
- if (dynamic_cast(view))
- return dynamic_cast(view)->storeNewData(object, options, cancel);
+ KexiQueryDesignerGuiEditor *guiView = dynamic_cast(view);
+ if (guiView) {
+ return guiView->storeNewData(object, options, cancel);
+ }
+ KexiQueryDesignerSQLView *sqlView = dynamic_cast(view);
+ if (sqlView) {
+ return sqlView->storeNewData(object, options, cancel);
+ }
return 0;
}
tristate KexiQueryView::storeData(bool dontAsk)
{
KexiView * view = window()->viewThatRecentlySetDirtyFlag();
- if (dynamic_cast(view))
- return dynamic_cast(view)->storeData(dontAsk);
- if (dynamic_cast(view))
- return dynamic_cast(view)->storeData(dontAsk);
+ KexiQueryDesignerGuiEditor *guiView = dynamic_cast(view);
+ if (guiView) {
+ return guiView->storeData(dontAsk);
+ }
+ KexiQueryDesignerSQLView *sqlView = dynamic_cast(view);
+ if (sqlView) {
+ return sqlView->storeData(dontAsk);
+ }
return false;
}
diff --git a/src/plugins/reports/kexidbreportdata.cpp b/src/plugins/reports/kexidbreportdata.cpp
--- a/src/plugins/reports/kexidbreportdata.cpp
+++ b/src/plugins/reports/kexidbreportdata.cpp
@@ -72,11 +72,16 @@
return;
KDbOrderByColumnList order;
for (int i = 0; i < sorting.count(); i++) {
- order.appendField(d->copySchema, sorting[i].field, sorting[i].order == Qt::AscendingOrder);
+ if (!order.appendField(d->copySchema, sorting[i].field,
+ sorting[i].order == Qt::AscendingOrder))
+ {
+ qWarning() << "Cannot set sort field" << i << sorting[i].field;
+ return;
+ }
}
d->copySchema->setOrderByColumnList(order);
} else {
- qDebug() << "Unable to sort null schema";
+ qWarning() << "Unable to sort null schema";
}
}
diff --git a/src/plugins/reports/kexireportdesignview.h b/src/plugins/reports/kexireportdesignview.h
--- a/src/plugins/reports/kexireportdesignview.h
+++ b/src/plugins/reports/kexireportdesignview.h
@@ -51,7 +51,6 @@
private:
KReportDesigner *m_reportDesigner;
- KPropertySet *m_propertySet;
KexiReportPart::TempData* tempData() const;
QScrollArea * m_scrollArea;
@@ -61,7 +60,6 @@
QAction *m_editPasteAction;
QAction *m_editDeleteAction;
QAction *m_editSectionAction;
- QAction *m_parameterEdit;
QAction *m_itemRaiseAction;
QAction *m_itemLowerAction;
diff --git a/src/plugins/reports/kexireportdesignview.cpp b/src/plugins/reports/kexireportdesignview.cpp
--- a/src/plugins/reports/kexireportdesignview.cpp
+++ b/src/plugins/reports/kexireportdesignview.cpp
@@ -88,12 +88,12 @@
bool *cancel)
{
KDbObject *s = KexiView::storeNewData(object, options, cancel);
- qDebug() << "new id:" << s->id();
-
if (!s || *cancel) {
delete s;
return 0;
}
+ qDebug() << "new id:" << s->id();
+
if (!storeData()) {
//failure: remove object's object data to avoid garbage
KDbConnection *conn = KexiMainWindowIface::global()->project()->dbConnection();
diff --git a/src/plugins/reports/kexireportview.cpp b/src/plugins/reports/kexireportview.cpp
--- a/src/plugins/reports/kexireportview.cpp
+++ b/src/plugins/reports/kexireportview.cpp
@@ -54,7 +54,7 @@
#include
KexiReportView::KexiReportView(QWidget *parent)
- : KexiView(parent), m_preRenderer(0), m_reportDocument(0) //! @todo KEXI3, m_kexi(0), m_functions(0)
+ : KexiView(parent), m_preRenderer(0), m_reportDocument(0), m_functions(0) //! @todo KEXI3, m_kexi(0)
{
setObjectName("KexiReportDesigner_DataView");
@@ -171,21 +171,20 @@
void KexiReportView::slotPrintReport()
{
+ QScopedPointer renderer(m_factory.createInstance("print"));
+ if (!renderer) {
+ return;
+ }
QPrinter printer(QPrinter::HighResolution);
- QPainter painter;
- KReportRendererBase *renderer;
-
- renderer = m_factory.createInstance("print");
- QPointer dialog = new QPrintDialog(&printer, this);
- if (dialog->exec() == QDialog::Accepted) {
+ QPrintDialog dialog(&printer, this);
+ if (dialog.exec() == QDialog::Accepted) {
KReportRendererContext cxt;
+ QPainter painter;
cxt.printer = &printer;
cxt.painter = &painter;
renderer->render(cxt, m_reportDocument);
}
- delete dialog;
- delete renderer;
}
void KexiReportView::slotExportAsPdf()
@@ -254,12 +253,9 @@
void KexiReportView::slotExportAsSpreadsheet()
{
- KReportRendererBase *renderer;
- KReportRendererContext cxt;
-
- renderer = m_factory.createInstance("ods");
-
+ QScopedPointer renderer(m_factory.createInstance("ods"));
if (renderer) {
+ KReportRendererContext cxt;
cxt.destinationUrl = getExportUrl(QLatin1String("application/vnd.oasis.opendocument.spreadsheet"),
xi18n("Export Report as Spreadsheet"),
"kfiledialog:///LastVisitedODSExportPath/",
@@ -280,12 +276,11 @@
void KexiReportView::slotExportAsTextDocument()
{
- KReportRendererBase *renderer;
- KReportRendererContext cxt;
-
- renderer = m_factory.createInstance("odt");
-
+ QScopedPointer renderer(m_factory.createInstance("odt"));
+ //! @todo Show error or don't show the commands to the user if the plugin isn't available.
+ //! The same for other createInstance() calls.
if (renderer) {
+ KReportRendererContext cxt;
cxt.destinationUrl = getExportUrl(QLatin1String("application/vnd.oasis.opendocument.text"),
xi18n("Export Report as Text Document"),
"kfiledialog:///LastVisitedODTExportPath/",
@@ -306,10 +301,8 @@
void KexiReportView::slotExportAsWebPage()
{
- KReportRendererContext cxt;
- KReportRendererBase *renderer;
-
const QString dialogTitle = xi18n("Export Report as Web Page");
+ KReportRendererContext cxt;
cxt.destinationUrl = getExportUrl(QLatin1String("text/html"),
dialogTitle,
"kfiledialog:///LastVisitedHTMLExportPath/",
@@ -329,11 +322,10 @@
KGuiItem(xi18nc("@action:button", "Use CSS")),
KGuiItem(xi18nc("@action:button", "Use Table")));
- if (answer == KMessageBox::Yes) {
- renderer = m_factory.createInstance("htmlcss");
- }
- else {
- renderer = m_factory.createInstance("htmltable");
+ QScopedPointer renderer(
+ m_factory.createInstance(answer == KMessageBox::Yes ? "htmlcss" : "htmltable"));
+ if (!renderer) {
+ return;
}
if (!renderer->render(cxt, m_reportDocument)) {
@@ -380,7 +372,7 @@
// }
// m_preRenderer->registerScriptObject(m_kexi, "Kexi");
//If using a kexidb source, add a functions scripting object
- if (tempData()->connectionDefinition.attribute("type") == "internal") {
+ if (!m_functions && tempData()->connectionDefinition.attribute("type") == "internal") {
m_functions = new KRScriptFunctions(reportData, KexiMainWindowIface::global()->project()->dbConnection());
m_preRenderer->registerScriptObject(m_functions, "field");
connect(m_preRenderer, SIGNAL(groupChanged(QMap)),
diff --git a/src/plugins/tables/kexitabledesignerview.cpp b/src/plugins/tables/kexitabledesignerview.cpp
--- a/src/plugins/tables/kexitabledesignerview.cpp
+++ b/src/plugins/tables/kexitabledesignerview.cpp
@@ -847,13 +847,9 @@
//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 */);
}
}
}
@@ -1562,9 +1558,11 @@
if (!execute) {
command->setRedoEnabled(false);
}
- d->history->push(command);
+ const bool pushed = d->history->push(command);
if (!execute) {
- command->setRedoEnabled(true);
+ if (pushed) { // only if not merged, it merged it's deleted already (COVERITY CID #1354238)
+ command->setRedoEnabled(true);
+ }
}
updateUndoRedoActions();
#endif
diff --git a/src/plugins/tables/kexitabledesignerview_p.cpp b/src/plugins/tables/kexitabledesignerview_p.cpp
--- a/src/plugins/tables/kexitabledesignerview_p.cpp
+++ b/src/plugins/tables/kexitabledesignerview_p.cpp
@@ -94,8 +94,8 @@
KProperty& property = set[propertyName];
//remember because we'll change list data soon
- KPropertyListData *oldListData = property.listData() ?
- new KPropertyListData(*property.listData()) : 0;
+ const QScopedPointeroldListData(property.listData() ?
+ new KPropertyListData(*property.listData()) : 0);
if (slist && nlist) {
if (slist->isEmpty() || nlist->isEmpty()) {
property.setListData(0);
@@ -116,9 +116,8 @@
property.setValue(newValue, rememberOldValue);
if (commandGroup) {
new ChangeFieldPropertyCommand(commandGroup, designerView, set, propertyName, oldValue, newValue,
- oldListData, property.listData());
+ oldListData.data(), property.listData());
}
- delete oldListData;
addHistoryCommand_in_slotPropertyChanged_enabled
= prev_addHistoryCommand_in_slotPropertyChanged_enabled; //restore
}
diff --git a/src/widget/KexiConnectionSelectorWidget.cpp b/src/widget/KexiConnectionSelectorWidget.cpp
--- a/src/widget/KexiConnectionSelectorWidget.cpp
+++ b/src/widget/KexiConnectionSelectorWidget.cpp
@@ -303,9 +303,10 @@
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();
}
@@ -463,6 +464,7 @@
if (!d->conn_set->removeConnectionData(item->data()))
return;
+ delete item->data();
delete item;
if (nextItem)
diff --git a/src/widget/dataviewcommon/kexidataawareobjectiface.cpp b/src/widget/dataviewcommon/kexidataawareobjectiface.cpp
--- a/src/widget/dataviewcommon/kexidataawareobjectiface.cpp
+++ b/src/widget/dataviewcommon/kexidataawareobjectiface.cpp
@@ -1227,7 +1227,8 @@
}
clearVariables();
- if (dynamic_cast(this) && dynamic_cast(this)->isVisible())
+ const QWidget* thisWidget = dynamic_cast(this);
+ if (thisWidget && thisWidget->isVisible())
initDataContents();
else
m_initDataContentsOnShow = true;
@@ -1577,7 +1578,7 @@
if (m_scrollbarToolTipsEnabled && verticalScrollBar()->isSliderDown()) {
QWidget* thisWidget = dynamic_cast(this);
const int record = lastVisibleRecord() + 1;
- if (record > 0) {
+ if (thisWidget && record > 0) {
const QString toolTipText( xi18n("Record: %1", record) );
QToolTip::showText(
QPoint(
diff --git a/src/widget/dataviewcommon/kexidataprovider.cpp b/src/widget/dataviewcommon/kexidataprovider.cpp
--- a/src/widget/dataviewcommon/kexidataprovider.cpp
+++ b/src/widget/dataviewcommon/kexidataprovider.cpp
@@ -94,9 +94,10 @@
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/dataviewcommon/kexiformdataiteminterface.cpp b/src/widget/dataviewcommon/kexiformdataiteminterface.cpp
--- a/src/widget/dataviewcommon/kexiformdataiteminterface.cpp
+++ b/src/widget/dataviewcommon/kexiformdataiteminterface.cpp
@@ -72,7 +72,11 @@
void KexiFormDataItemInterface::cancelEditor()
{
- QWidget *parentWidget = dynamic_cast(this)->parentWidget();
+ QWidget *thisWidget = dynamic_cast(this);
+ if (!thisWidget) {
+ return;
+ }
+ QWidget *parentWidget = thisWidget->parentWidget();
KexiDataAwareObjectInterface *dataAwareObject = KexiUtils::findParentByType(parentWidget);
if (dataAwareObject)
dataAwareObject->cancelEditor();
diff --git a/src/widget/kexiqueryparameters.cpp b/src/widget/kexiqueryparameters.cpp
--- a/src/widget/kexiqueryparameters.cpp
+++ b/src/widget/kexiqueryparameters.cpp
@@ -136,6 +136,7 @@
case KDbField::BLOB: {
//! @todo BLOB input unsupported
values.append(QByteArray());
+ break;
}
default:
qWarning() << "unsupported type " << KDbField::typeName(parameter.type)
diff --git a/src/widget/kexislider.cpp b/src/widget/kexislider.cpp
--- a/src/widget/kexislider.cpp
+++ b/src/widget/kexislider.cpp
@@ -79,27 +79,27 @@
QStyleOptionSlider option;
initStyleOption(&option);
- const int& ticks( option.tickPosition );
+ const QSlider::TickPosition ticks( option.tickPosition );
const int available(style()->proxy()->pixelMetric(QStyle::PM_SliderSpaceAvailable, &option, this));
int interval = option.tickInterval;
if( interval < 1 ) interval = option.pageStep;
if( interval < 1 ) return;
- const QRect& r(option.rect);
+ const QRect r(option.rect);
const QPalette palette(option.palette);
const int fudge(style()->proxy()->pixelMetric(QStyle::PM_SliderLength, &option, this) / 2);
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(availablepartItem()) {
pm = d->itemMenu;
KexiProjectModelItem *par_it = static_cast(bit->parent());
- d->itemMenu->update(par_it->partInfo(), bit->partItem());
+ if (par_it->partInfo() && bit->partItem()) {
+ d->itemMenu->update(*par_it->partInfo(), *bit->partItem());
+ }
}
if (pm) {
pm->exec(event->globalPos());
@@ -343,7 +345,7 @@
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);
@@ -377,7 +379,7 @@
#endif
}
}
- emit selectionChanged(it ? it->partItem() : 0);
+ emit selectionChanged(it->partItem());
}
void KexiProjectNavigator::slotRemove()
@@ -697,26 +699,26 @@
{
}
-void KexiItemMenu::update(KexiPart::Info* partInfo, KexiPart::Item* partItem)
+void KexiItemMenu::update(const KexiPart::Info& partInfo, const KexiPart::Item& partItem)
{
clear();
addSection(QString());
- KexiContextMenuUtils::updateTitle(this, partItem->name(), partInfo->name(),
- KexiIconName(partInfo->iconName()));
+ KexiContextMenuUtils::updateTitle(this, partItem.name(), partInfo.name(),
+ KexiIconName(partInfo.iconName()));
if (m_actionCollection->action("open_object")
&& m_actionCollection->action("open_object")->isEnabled()
- && partItem && (partInfo->supportedViewModes() & Kexi::DataViewMode)) {
+ && (partInfo.supportedViewModes() & Kexi::DataViewMode)) {
addAction("open_object");
}
if (m_actionCollection->action("design_object")
&& m_actionCollection->action("design_object")->isEnabled()
- && partItem && (partInfo->supportedViewModes() & Kexi::DesignViewMode)) {
+ && (partInfo.supportedViewModes() & Kexi::DesignViewMode)) {
addAction("design_object");
}
if (m_actionCollection->action("editText_object")
&& m_actionCollection->action("editText_object")->isEnabled()
- && partItem && (partInfo->supportedViewModes() & Kexi::TextViewMode)) {
+ && (partInfo.supportedViewModes() & Kexi::TextViewMode)) {
addAction("editText_object");
}
addSeparator();
@@ -727,21 +729,21 @@
//! @todo addSeparator();
#endif
bool addSep = false;
- if (partItem && partInfo->isExecuteSupported()) {
+ if (partInfo.isExecuteSupported()) {
addAction("data_execute");
addSep = true;
}
- if (partItem && partInfo->isDataExportSupported()) {
+ if (partInfo.isDataExportSupported()) {
addAction("export_object");
addSep = true;
}
if (addSep)
addSeparator();
#ifdef KEXI_QUICK_PRINTING_SUPPORT
- if (partItem && partInfo->isPrintingSupported())
+ if (partInfo.isPrintingSupported())
addAction("print_object");
- if (partItem && partInfo->isPrintingSupported())
+ if (partInfo.isPrintingSupported())
addAction("pageSetupForObject");
if (m_actionCollection->action("edit_rename") || m_actionCollection->action("edit_delete"))
addSeparator();
diff --git a/src/widget/tableview/KexiDataTableView.cpp b/src/widget/tableview/KexiDataTableView.cpp
--- a/src/widget/tableview/KexiDataTableView.cpp
+++ b/src/widget/tableview/KexiDataTableView.cpp
@@ -110,9 +110,10 @@
void
KexiDataTableView::setData(KDbCursor *c)
{
- if (!dynamic_cast(mainWidget()))
+ KexiDataTableScrollArea* area = dynamic_cast(mainWidget());
+ if (!area)
return;
- dynamic_cast(mainWidget())->setData(c);
+ area->setData(c);
}
void KexiDataTableView::filter()
diff --git a/src/widget/tableview/KexiTableScrollArea.cpp b/src/widget/tableview/KexiTableScrollArea.cpp
--- a/src/widget/tableview/KexiTableScrollArea.cpp
+++ b/src/widget/tableview/KexiTableScrollArea.cpp
@@ -733,7 +733,7 @@
if (!d->appearance.horizontalGridEnabled)
y_offset++; //correction because we're not drawing cell borders
- if (d->appearance.fullRecordSelection && d->appearance.fullRecordSelection) {
+ if (d->appearance.fullRecordSelection) {
}
if (m_currentRecord == data && (column == m_curColumn || d->appearance.fullRecordSelection)) {
if (edit && ( (d->appearance.recordHighlightingEnabled && !d->appearance.fullRecordSelection)
diff --git a/src/widget/tableview/KexiTableScrollAreaHeader.cpp b/src/widget/tableview/KexiTableScrollAreaHeader.cpp
--- a/src/widget/tableview/KexiTableScrollAreaHeader.cpp
+++ b/src/widget/tableview/KexiTableScrollAreaHeader.cpp
@@ -51,42 +51,44 @@
const KexiTableScrollAreaHeader *headerWidget
= qobject_cast(parent());
if (ce == CE_Header && option) {
- QStyleOptionHeader newOption(*qstyleoption_cast(option));
+ const QStyleOptionHeader *existingOption = qstyleoption_cast(option);
+ QScopedPointer newOption(
+ existingOption ? new QStyleOptionHeader(*existingOption) : new QStyleOptionHeader);
const int currentSection = headerWidget->orientation() == Qt::Horizontal
? headerWidget->currentIndex().column()
: headerWidget->currentIndex().row();
// qDebug() << headerWidget->orientation() << currentSection <<
// headerWidget->currentIndex().row() << headerWidget->currentIndex().column();
- if (newOption.section >= 0) {
+ if (newOption->section >= 0) {
int f1 = 0, f2 = 0;
- if (newOption.section == currentSection) {
+ if (newOption->section == currentSection) {
f1 = 34;
f2 = 66;
}
else if (headerWidget->scrollArea()->appearance().recordMouseOverHighlightingEnabled
&& headerWidget->orientation() == Qt::Vertical
- && newOption.section == headerWidget->scrollArea()->highlightedRecordNumber())
+ && newOption->section == headerWidget->scrollArea()->highlightedRecordNumber())
{
f1 = 10;
f2 = 90;
}
if (f1 > 0) {
- newOption.palette.setColor(QPalette::Button,
+ newOption->palette.setColor(QPalette::Button,
KexiUtils::blendedColors(
headerWidget->selectionBackgroundColor(),
headerWidget->palette().color(headerWidget->backgroundRole()), f1, f2));
//set background color as well (e.g. for thinkeramik)
- newOption.palette.setColor(QPalette::Window, newOption.palette.color(QPalette::Button));
+ newOption->palette.setColor(QPalette::Window, newOption->palette.color(QPalette::Button));
}
if (headerWidget->orientation() == Qt::Vertical) {
// For mouse-over styles such as Breeze fill color and animate,
// what's in conflict with what we do: disable this.
- newOption.state &= (0xffffffff ^ QStyle::State_MouseOver);
- //qDebug() << newOption.rect;
+ newOption->state &= (0xffffffff ^ QStyle::State_MouseOver);
+ //qDebug() << newOption->rect;
}
- QProxyStyle::drawControl(ce, &newOption, painter, widget);
+ QProxyStyle::drawControl(ce, newOption.data(), painter, widget);
return;
}
}
diff --git a/src/widget/tableview/KexiTableScrollArea_p.h b/src/widget/tableview/KexiTableScrollArea_p.h
--- a/src/widget/tableview/KexiTableScrollArea_p.h
+++ b/src/widget/tableview/KexiTableScrollArea_p.h
@@ -142,9 +142,6 @@
/*! Helper for "highlighted record" effect. */
int highlightedRecord;
- /*! Id of context menu key (cached). */
- int contextMenuKey;
-
/*! Specifies currently displayed cell tooltip.
Value of QPoint(-1,-1) means "no tooltip". */
QPoint recentCellWithToolTip;
diff --git a/src/widget/tableview/kexiblobtableedit.cpp b/src/widget/tableview/kexiblobtableedit.cpp
--- a/src/widget/tableview/kexiblobtableedit.cpp
+++ b/src/widget/tableview/kexiblobtableedit.cpp
@@ -151,7 +151,6 @@
bool KexiBlobTableEdit::valueIsNull()
{
//! @todo
- d->value.size();
return d->value.isEmpty();
}
@@ -209,6 +208,7 @@
// the key is unique for this tuple: (checksum, w, h)
qulonglong sum((((qulonglong(qChecksum(array.constData(), array.length())) << 32) + w) << 16) + h);
pp = d->cachedPixmaps.object(sum);
+ bool insertToCache = false;
if (!pp) {
QPixmap pixmap;
if (val.canConvert(QVariant::ByteArray) && pixmap.loadFromData(val.toByteArray())) {
@@ -224,13 +224,18 @@
pp = new PixmapAndPos;
pp->pixmap = pixmap;
pp->pos = pos;
- d->cachedPixmaps.insert(sum, pp);
+ insertToCache = true;
}
}
}
if (pp) {
p->drawPixmap(pp->pos, pp->pixmap);
}
+ if (insertToCache) {
+ // Do that afterwards because in theory QCache can delete pp immediately (COVERITY CID #1354236)
+ //! @todo use cost other than 1
+ d->cachedPixmaps.insert(sum, pp);
+ }
}
}
@@ -423,7 +428,7 @@
QMouseEvent me(QEvent::MouseButtonPress, QPoint(2, 2), Qt::LeftButton, Qt::NoButton,
Qt::NoModifier);
QApplication::sendEvent(d->button, &me);
- } else if (ke->modifiers() == Qt::NoButton
+ } else if (ke->modifiers() == Qt::NoModifier
&& (k == Qt::Key_F2 || k == Qt::Key_Space || k == Qt::Key_Enter || k == Qt::Key_Return)) {
d->menu->insertFromFile();
} else
@@ -459,9 +464,9 @@
{
if (o == d->menu && e->type() == QEvent::KeyPress) {
QKeyEvent* ke = static_cast(e);
- const int mods = ke->modifiers();
+ const Qt::KeyboardModifiers mods = ke->modifiers();
const int k = ke->key();
- if ((mods == Qt::NoButton && (k == Qt::Key_Tab || k == Qt::Key_Left || k == Qt::Key_Right))
+ if ((mods == Qt::NoModifier && (k == Qt::Key_Tab || k == Qt::Key_Left || k == Qt::Key_Right))
|| (mods == Qt::ShiftModifier && k == Qt::Key_Backtab)
) {
d->menu->hide();
diff --git a/src/widget/tableview/kexicomboboxbase.cpp b/src/widget/tableview/kexicomboboxbase.cpp
--- a/src/widget/tableview/kexicomboboxbase.cpp
+++ b/src/widget/tableview/kexicomboboxbase.cpp
@@ -28,6 +28,7 @@
#include
+#include
#include
KexiComboBoxBase::KexiComboBoxBase()
@@ -74,6 +75,9 @@
//! @todo for now we're assuming the id is INTEGER
KDbTableViewData *tvData = popup()->tableView()->data();
const int boundColumn = boundColumnIndex();
+ if (boundColumn < 0) {
+ return -1;
+ }
int record = -1;
for (KDbTableViewDataIterator it(tvData->begin()); it != tvData->end(); ++it) {
record++;
@@ -290,7 +294,8 @@
}
data = selectRecordForEnteredValueInLookupTable(m_userEnteredValue);
}
- return data ? data->at(boundColumnIndex()) : QVariant();
+ const int boundColumn = boundColumnIndex();
+ return (data && boundColumn >= 0) ? data->at(boundColumn) : QVariant();
} else if (popup()) {
//use 'enum hints' model
const int record = popup()->tableView()->currentRecord();
@@ -377,8 +382,11 @@
//qDebug() << show << field() << popup() << m_updatePopupSelectionOnShow;
if (!field())
return;
- m_insideCreatePopup = true;
QWidget* thisWidget = dynamic_cast(this);
+ if (!thisWidget) {
+ return;
+ }
+ QScopedValueRollback insideCreatePopuRollback(m_insideCreatePopup, true);
QWidget *widgetToFocus = internalEditor() ? internalEditor() : thisWidget;
//qDebug() << "widgetToFocus:" << widgetToFocus;
@@ -465,7 +473,6 @@
widgetToFocus->setFocus();
}
}
- m_insideCreatePopup = false;
}
void KexiComboBoxBase::hide()
@@ -524,7 +531,9 @@
if (valueToSet.toString().isEmpty() && !m_insideCreatePopup) {
clear();
QWidget* thisWidget = dynamic_cast(this);
- thisWidget->parentWidget()->setFocus();
+ if (thisWidget) {
+ thisWidget->parentWidget()->setFocus();
+ }
return;
}
}
diff --git a/src/widget/tableview/kexicomboboxpopup.cpp b/src/widget/tableview/kexicomboboxpopup.cpp
--- a/src/widget/tableview/kexicomboboxpopup.cpp
+++ b/src/widget/tableview/kexicomboboxpopup.cpp
@@ -182,7 +182,7 @@
delete d->privateQuery;
d->privateQuery = 0;
const QList visibleColumns(lookupFieldSchema ? lookupFieldSchema->visibleColumns() : QList());
- if (!visibleColumns.isEmpty() && lookupFieldSchema->boundColumn() >= 0) {
+ if (!visibleColumns.isEmpty() && lookupFieldSchema && lookupFieldSchema->boundColumn() >= 0) {
const bool multipleLookupColumnJoined = visibleColumns.count() > 1;
//! @todo support more RowSourceType's, not only table and query
KDbCursor *cursor = 0;
@@ -439,7 +439,7 @@
if (e->type() == QEvent::KeyPress) {
QKeyEvent *ke = static_cast(e);
const int k = ke->key();
- if ((ke->modifiers() == Qt::NoButton && (k == Qt::Key_Escape || k == Qt::Key_F4))
+ if ((ke->modifiers() == Qt::NoModifier && (k == Qt::Key_Escape || k == Qt::Key_F4))
|| (ke->modifiers() == Qt::AltModifier && k == Qt::Key_Up)) {
hide();
emit cancelled();
diff --git a/src/widget/tableview/kexicomboboxtableedit.cpp b/src/widget/tableview/kexicomboboxtableedit.cpp
--- a/src/widget/tableview/kexicomboboxtableedit.cpp
+++ b/src/widget/tableview/kexicomboboxtableedit.cpp
@@ -263,7 +263,7 @@
{
//qDebug() << ke;
const int k = ke->key();
- if ((ke->modifiers() == Qt::NoButton && k == Qt::Key_F4)
+ if ((ke->modifiers() == Qt::NoModifier && k == Qt::Key_F4)
|| (ke->modifiers() == Qt::AltModifier && k == Qt::Key_Down)) {
//show popup
slotButtonClicked();
diff --git a/src/widget/tableview/kexitableedit.cpp b/src/widget/tableview/kexitableedit.cpp
--- a/src/widget/tableview/kexitableedit.cpp
+++ b/src/widget/tableview/kexitableedit.cpp
@@ -268,8 +268,8 @@
void KexiTableEdit::repaintRelatedCell()
{
#ifndef KEXI_MOBILE
- if (dynamic_cast(parentWidget())) {
- dynamic_cast(parentWidget())->updateCurrentCell();
+ if (KexiDataAwareObjectInterface *iface = dynamic_cast(parentWidget())) {
+ iface->updateCurrentCell();
}
#endif
}
diff --git a/src/widget/undo/kundo2stack.h b/src/widget/undo/kundo2stack.h
--- a/src/widget/undo/kundo2stack.h
+++ b/src/widget/undo/kundo2stack.h
@@ -84,7 +84,6 @@
class KEXIUNDO_EXPORT KUndo2Command
{
KUndo2CommandPrivate *d;
- int timedID;
public:
explicit KUndo2Command(KUndo2Command *parent = 0);
@@ -161,7 +160,7 @@
virtual ~KUndo2QStack();
void clear();
- void push(KUndo2Command *cmd);
+ bool push(KUndo2Command *cmd);
bool canUndo() const;
bool canRedo() const;
diff --git a/src/widget/undo/kundo2stack.cpp b/src/widget/undo/kundo2stack.cpp
--- a/src/widget/undo/kundo2stack.cpp
+++ b/src/widget/undo/kundo2stack.cpp
@@ -693,9 +693,10 @@
If \a cmd's id is not -1, and if the id is the same as that of the
most recently executed command, KUndo2QStack will attempt to merge the two
commands by calling KUndo2Command::mergeWith() on the most recently executed
- command. If KUndo2Command::mergeWith() returns true, \a cmd is deleted.
+ command. If KUndo2Command::mergeWith() returns true, \a cmd is deleted and false
+ is returned.
- In all other cases \a cmd is simply pushed on the stack.
+ In all other cases \a cmd is simply pushed on the stack and true is returned.
If commands were undone before \a cmd was pushed, the current command and
all commands above it are deleted. Hence \a cmd always ends up being the
@@ -709,7 +710,7 @@
\sa KUndo2Command::id() KUndo2Command::mergeWith()
*/
-void KUndo2QStack::push(KUndo2Command *cmd)
+bool KUndo2QStack::push(KUndo2Command *cmd)
{
cmd->redoMergedCommands();
cmd->setEndTime();
@@ -808,6 +809,7 @@
}
if (try_merge && cur->mergeWith(cmd)) {
delete cmd;
+ cmd = 0;
if (!macro) {
emit indexChanged(m_index);
emit canUndoChanged(canUndo());
@@ -827,6 +829,7 @@
setIndex(m_index + 1, false);
}
}
+ return cmd;
}
/*!
diff --git a/src/widget/undo/kundo2view.cpp b/src/widget/undo/kundo2view.cpp
--- a/src/widget/undo/kundo2view.cpp
+++ b/src/widget/undo/kundo2view.cpp
@@ -90,45 +90,38 @@
class KUndo2ViewPrivate
{
public:
- KUndo2ViewPrivate() :
+ KUndo2ViewPrivate(KUndo2View *view) :
#ifndef QT_NO_UNDOGROUP
group(0),
#endif
- model(0) {}
+ q(view)
+ {
+ model = new KUndo2Model(q);
+ q->setModel(model);
+ q->setSelectionModel(model->selectionModel());
+ }
#ifndef QT_NO_UNDOGROUP
QPointer group;
#endif
KUndo2Model *model;
- KUndo2View* q;
-
- void init(KUndo2View* view);
+ KUndo2View* const q;
};
-void KUndo2ViewPrivate::init(KUndo2View* view)
-{
- q = view;
- model = new KUndo2Model(q);
- q->setModel(model);
- q->setSelectionModel(model->selectionModel());
-}
-
/*!
Constructs a new view with parent \a parent.
*/
-KUndo2View::KUndo2View(QWidget *parent) : QListView(parent), d(new KUndo2ViewPrivate)
+KUndo2View::KUndo2View(QWidget *parent) : QListView(parent), d(new KUndo2ViewPrivate(this))
{
- d->init(this);
}
/*!
Constructs a new view with parent \a parent and sets the observed stack to \a stack.
*/
-KUndo2View::KUndo2View(KUndo2QStack *stack, QWidget *parent) : QListView(parent), d(new KUndo2ViewPrivate)
+KUndo2View::KUndo2View(KUndo2QStack *stack, QWidget *parent) : QListView(parent), d(new KUndo2ViewPrivate(this))
{
- d->init(this);
setStack(stack);
}
@@ -140,9 +133,8 @@
The view will update itself autmiatically whenever the active stack of the group changes.
*/
-KUndo2View::KUndo2View(KUndo2Group *group, QWidget *parent) : QListView(parent), d(new KUndo2ViewPrivate)
+KUndo2View::KUndo2View(KUndo2Group *group, QWidget *parent) : QListView(parent), d(new KUndo2ViewPrivate(this))
{
- d->init(this);
setGroup(group);
}
diff --git a/src/widget/utils/kexidropdownbutton.cpp b/src/widget/utils/kexidropdownbutton.cpp
--- a/src/widget/utils/kexidropdownbutton.cpp
+++ b/src/widget/utils/kexidropdownbutton.cpp
@@ -110,7 +110,7 @@
{
const int k = e->key();
const bool dropDown =
- (e->modifiers() == Qt::NoButton
+ (e->modifiers() == Qt::NoModifier
&& (k == Qt::Key_Space || k == Qt::Key_Enter || k == Qt::Key_Return || k == Qt::Key_F2
|| k == Qt::Key_F4)
)