Commit d347f7d4 authored by LEFEBVREJP email's avatar LEFEBVREJP email
Browse files

Merge branch 'fortify' into 'master'

Fortify changes

See merge request !80
parents 1ef4f9ff ad788bbc
Pipeline #67178 passed with stages
in 18 minutes and 21 seconds
...@@ -134,6 +134,7 @@ struct std::tm utc_to_time(const std::string &time, int &zone, int &daylight) ...@@ -134,6 +134,7 @@ struct std::tm utc_to_time(const std::string &time, int &zone, int &daylight)
int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0; int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
int count = sscanf(time.c_str(), "%d-%d-%dT%d:%d:%d-%d:%d", &year, &month, int count = sscanf(time.c_str(), "%d-%d-%dT%d:%d:%d-%d:%d", &year, &month,
&day, &hour, &minute, &second, &zone, &daylight); &day, &hour, &minute, &second, &zone, &daylight);
(void)sizeof(count);
radix_line("utc_to_time elements: " << count); radix_line("utc_to_time elements: " << count);
struct std::tm res; struct std::tm res;
res.tm_year = year; res.tm_year = year;
......
...@@ -71,9 +71,10 @@ std::string computer_name() ...@@ -71,9 +71,10 @@ std::string computer_name()
char *hostname; char *hostname;
#ifndef _WIN32 #ifndef _WIN32
hostname = new char[256]; hostname = new char[256];
hostname[255] = '\0';
if (gethostname(hostname, 256) != 0) if (gethostname(hostname, 256) != 0)
{ {
strcpy(hostname, "Unknown"); strncpy(hostname, "Unknown", 255);
} }
std::string result(hostname); std::string result(hostname);
delete[] hostname; delete[] hostname;
...@@ -485,6 +486,7 @@ long get_process_memory() ...@@ -485,6 +486,7 @@ long get_process_memory()
char buffer[128]; char buffer[128];
strncpy(buffer, line.substr(6).c_str(), strncpy(buffer, line.substr(6).c_str(),
std::min(sizeof(buffer), line.size() - 6)); std::min(sizeof(buffer), line.size() - 6));
buffer[127] = '\0';
caddr_t context = nullptr, token = strtok_r(buffer, " \t", &context); caddr_t context = nullptr, token = strtok_r(buffer, " \t", &context);
if (token != nullptr) result = long(atoi(token)) * 1024L; if (token != nullptr) result = long(atoi(token)) * 1024L;
......
...@@ -19,10 +19,13 @@ class NavigationActionManager::PImpl ...@@ -19,10 +19,13 @@ class NavigationActionManager::PImpl
NavigationActionManager::PImpl::~PImpl() {} NavigationActionManager::PImpl::~PImpl() {}
NavigationActionManager::NavigationActionManager(QObject *parent) NavigationActionManager::NavigationActionManager(QObject *parent)
: p(new PImpl(), [](PImpl *impl) { delete impl; }) : QObject(parent)
, p(new PImpl(), [](PImpl *impl) { delete impl; })
{ {
} }
void NavigationActionManager::deleter(PImpl *impl) { delete impl; }
void NavigationActionManager::registerAction(NavigationItem *item, QString text, void NavigationActionManager::registerAction(NavigationItem *item, QString text,
std::function<void()> functor) std::function<void()> functor)
{ {
......
...@@ -25,6 +25,7 @@ class RADIX_PUBLIC NavigationActionManager : public QObject ...@@ -25,6 +25,7 @@ class RADIX_PUBLIC NavigationActionManager : public QObject
private: private:
class PImpl; class PImpl;
std::unique_ptr<PImpl, void (*)(PImpl *)> p; std::unique_ptr<PImpl, void (*)(PImpl *)> p;
static void deleter(PImpl *impl);
}; };
} // namespace radix } // namespace radix
......
...@@ -19,25 +19,27 @@ class NavigationItem::PImpl ...@@ -19,25 +19,27 @@ class NavigationItem::PImpl
NavigationItem::PImpl::~PImpl() { qDeleteAll(children); } NavigationItem::PImpl::~PImpl() { qDeleteAll(children); }
NavigationItem::NavigationItem(QVariant data, NavigationItem *parentItem) NavigationItem::NavigationItem(QVariant data, NavigationItem *parentItem)
: p(new PImpl(), [](PImpl *impl) { delete impl; }) : p(new PImpl(), deleter)
{ {
p->parent = parentItem; p->parent = parentItem;
p->data.append(data); p->data.append(data);
} }
NavigationItem::NavigationItem(QList<QVariant> data, NavigationItem *parentItem) NavigationItem::NavigationItem(QList<QVariant> data, NavigationItem *parentItem)
: p(new PImpl(), [](PImpl *impl) { delete impl; }) : p(new PImpl(), deleter)
{ {
p->parent = parentItem; p->parent = parentItem;
p->data = data; p->data = data;
} }
NavigationItem::NavigationItem(NavigationItem *parentItem) NavigationItem::NavigationItem(NavigationItem *parentItem)
: p(new PImpl(), [](PImpl *impl) { delete impl; }) : p(new PImpl(), deleter)
{ {
p->parent = parentItem; p->parent = parentItem;
} }
void NavigationItem::deleter(PImpl *impl) { delete impl; }
int NavigationItem::type() const { return p->type; } int NavigationItem::type() const { return p->type; }
void NavigationItem::setType(int type) { p->type = type; } void NavigationItem::setType(int type) { p->type = type; }
......
...@@ -30,6 +30,7 @@ class RADIX_PUBLIC NavigationItem ...@@ -30,6 +30,7 @@ class RADIX_PUBLIC NavigationItem
private: private:
class PImpl; class PImpl;
std::unique_ptr<PImpl, void (*)(PImpl *)> p; std::unique_ptr<PImpl, void (*)(PImpl *)> p;
static void deleter(PImpl *impl);
}; };
} // namespace radix } // namespace radix
......
...@@ -21,11 +21,13 @@ NavigationModel::PImpl::~PImpl() ...@@ -21,11 +21,13 @@ NavigationModel::PImpl::~PImpl()
} }
NavigationModel::NavigationModel(QObject* parent) NavigationModel::NavigationModel(QObject* parent)
: QAbstractItemModel(parent) : QAbstractItemModel(parent)
, p(new PImpl(), [](PImpl* impl) { delete impl; }) , p(new PImpl(), deleter)
{ {
p->root = new NavigationItem(); p->root = new NavigationItem();
} }
void NavigationModel::deleter(PImpl* impl) { delete impl; }
QVariant NavigationModel::data(const QModelIndex& index, int role) const QVariant NavigationModel::data(const QModelIndex& index, int role) const
{ {
if (!index.isValid()) return QVariant(); if (!index.isValid()) return QVariant();
......
...@@ -38,6 +38,7 @@ class RADIX_PUBLIC NavigationModel : public QAbstractItemModel ...@@ -38,6 +38,7 @@ class RADIX_PUBLIC NavigationModel : public QAbstractItemModel
private: private:
class PImpl; class PImpl;
std::unique_ptr<PImpl, void (*)(PImpl *)> p; std::unique_ptr<PImpl, void (*)(PImpl *)> p;
static void deleter(PImpl *impl);
}; };
} // namespace radix } // namespace radix
......
...@@ -34,10 +34,12 @@ class RADIX_PUBLIC NavigationItemSortFilterProxyModel::PImpl ...@@ -34,10 +34,12 @@ class RADIX_PUBLIC NavigationItemSortFilterProxyModel::PImpl
NavigationItemSortFilterProxyModel::NavigationItemSortFilterProxyModel( NavigationItemSortFilterProxyModel::NavigationItemSortFilterProxyModel(
QObject* parent) QObject* parent)
: QSortFilterProxyModel(parent) : QSortFilterProxyModel(parent)
, p(new PImpl(), [](PImpl* impl) { delete impl; }) , p(new PImpl(), deleter)
{ {
} }
void NavigationItemSortFilterProxyModel::deleter(PImpl* impl) { delete impl; }
bool NavigationItemSortFilterProxyModel::accepts(const QModelIndex& index) const bool NavigationItemSortFilterProxyModel::accepts(const QModelIndex& index) const
{ {
const QString& text = index.data().toString(); const QString& text = index.data().toString();
...@@ -85,12 +87,14 @@ class RADIX_PUBLIC NavigationWidget::PImpl ...@@ -85,12 +87,14 @@ class RADIX_PUBLIC NavigationWidget::PImpl
NavigationWidget::NavigationWidget(QWidget* parent) NavigationWidget::NavigationWidget(QWidget* parent)
: QWidget(parent) : QWidget(parent)
, p(new PImpl(), [](PImpl* impl) { delete impl; }) , p(new PImpl(), deleter)
{ {
initMembers(); initMembers();
initLayout(); initLayout();
} }
void NavigationWidget::deleter(PImpl* impl) { delete impl; }
NavigationModel* NavigationWidget::navigationModel() { return p->model; } NavigationModel* NavigationWidget::navigationModel() { return p->model; }
NavigationActionManager* NavigationWidget::navigationActionManager() NavigationActionManager* NavigationWidget::navigationActionManager()
......
...@@ -22,7 +22,8 @@ class NavigationItem; ...@@ -22,7 +22,8 @@ class NavigationItem;
class NavigationModel; class NavigationModel;
class NavigationActionManager; class NavigationActionManager;
class RADIX_PUBLIC NavigationItemSortFilterProxyModel : public QSortFilterProxyModel class RADIX_PUBLIC NavigationItemSortFilterProxyModel
: public QSortFilterProxyModel
{ {
Q_OBJECT Q_OBJECT
...@@ -39,6 +40,7 @@ class RADIX_PUBLIC NavigationItemSortFilterProxyModel : public QSortFilterProxyM ...@@ -39,6 +40,7 @@ class RADIX_PUBLIC NavigationItemSortFilterProxyModel : public QSortFilterProxyM
bool accepts(const QModelIndex& index) const; bool accepts(const QModelIndex& index) const;
class PImpl; class PImpl;
std::unique_ptr<PImpl, void (*)(PImpl*)> p; std::unique_ptr<PImpl, void (*)(PImpl*)> p;
static void deleter(PImpl* impl);
}; };
class RADIX_PUBLIC NavigationWidget : public QWidget class RADIX_PUBLIC NavigationWidget : public QWidget
...@@ -73,6 +75,7 @@ class RADIX_PUBLIC NavigationWidget : public QWidget ...@@ -73,6 +75,7 @@ class RADIX_PUBLIC NavigationWidget : public QWidget
class PImpl; class PImpl;
std::unique_ptr<PImpl, void (*)(PImpl*)> p; std::unique_ptr<PImpl, void (*)(PImpl*)> p;
static void deleter(PImpl* impl);
}; };
} // namespace radix } // namespace radix
......
...@@ -21,18 +21,20 @@ class RADIX_PUBLIC TableView::PImpl ...@@ -21,18 +21,20 @@ class RADIX_PUBLIC TableView::PImpl
TableView::PImpl::PImpl() TableView::PImpl::PImpl()
{ {
allow_paste = false; allow_paste = false;
copy_vert_header = false; copy_vert_header = false;
copy_horiz_header = false; copy_horiz_header = false;
separator = '\t'; separator = '\t';
} }
TableView::TableView(QWidget *parent) TableView::TableView(QWidget *parent)
: QTableView(parent) : QTableView(parent)
, p(new PImpl(), [](PImpl *impl) { delete impl; }) , p(new PImpl(), deleter)
{ {
} }
void TableView::deleter(PImpl *impl) { delete impl; }
char TableView::separator() const { return p->separator; } char TableView::separator() const { return p->separator; }
void TableView::setSeparator(char value) { p->separator = value; } void TableView::setSeparator(char value) { p->separator = value; }
...@@ -98,11 +100,11 @@ void TableView::copy() ...@@ -98,11 +100,11 @@ void TableView::copy()
} }
if (p->copy_horiz_header) if (p->copy_horiz_header)
{ {
for (int i = 0; i < cols.size(); i++) for (int i = 0; i < cols.size(); i++)
{ {
if (i > 0) data.append(p->separator); if (i > 0) data.append(p->separator);
data.append(chmodel->headerData(cols[i], Qt::Horizontal).toString()); data.append(chmodel->headerData(cols[i], Qt::Horizontal).toString());
} }
} }
data.append('\n'); data.append('\n');
} }
......
...@@ -21,9 +21,10 @@ class RADIX_PUBLIC TableView : public QTableView ...@@ -21,9 +21,10 @@ class RADIX_PUBLIC TableView : public QTableView
class PImpl; class PImpl;
std::unique_ptr<PImpl, void (*)(PImpl *)> p; std::unique_ptr<PImpl, void (*)(PImpl *)> p;
static void deleter(PImpl *impl);
public: public:
TableView(QWidget *parent = 0); TableView(QWidget *parent = nullptr);
char separator() const; char separator() const;
void setSeparator(char value); void setSeparator(char value);
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include <iostream> #include <iostream>
#include <QLabel> #include <QLabel>
#include <QPushButton>
#include <QTabBar> #include <QTabBar>
#include <QToolButton> #include <QToolButton>
...@@ -16,15 +15,15 @@ TabWidget::TabWidget(QWidget *parent) ...@@ -16,15 +15,15 @@ TabWidget::TabWidget(QWidget *parent)
setTabsClosable(true); setTabsClosable(true);
// //
// create a 'new tab' button // create a 'new tab' button
QPushButton *newButton = new QPushButton("+", this); mNewButton = new QPushButton("+", this);
newButton->setObjectName("tabs_new_tab_button"); mNewButton->setObjectName("tabs_new_tab_button");
newButton->setToolTip("Add new tab"); mNewButton->setToolTip("Add new tab");
newButton->setMaximumWidth(25); mNewButton->setMaximumWidth(25);
addTab(new QLabel(""), QString("")); addTab(new QLabel(""), QString(""));
QWidget *newTabWidget = widget(0); QWidget *newTabWidget = widget(0);
newTabWidget->setObjectName("tabwidget_new_tab"); newTabWidget->setObjectName("tabwidget_new_tab");
tabBar()->setTabButton(0, QTabBar::RightSide, newButton); tabBar()->setTabButton(0, QTabBar::RightSide, mNewButton);
// this is require on mac to hide the close button on the first tab // this is require on mac to hide the close button on the first tab
QWidget *temp = tabBar()->tabButton(0, QTabBar::LeftSide); QWidget *temp = tabBar()->tabButton(0, QTabBar::LeftSide);
if (temp) temp->hide(); if (temp) temp->hide();
...@@ -34,7 +33,7 @@ TabWidget::TabWidget(QWidget *parent) ...@@ -34,7 +33,7 @@ TabWidget::TabWidget(QWidget *parent)
setCurrentIndex(-1); setCurrentIndex(-1);
// forward pushbutton signal // forward pushbutton signal
connect(newButton, SIGNAL(clicked(bool)), this, SIGNAL(addTabRequested())); connect(mNewButton, SIGNAL(clicked(bool)), this, SIGNAL(addTabRequested()));
} }
} // namespace radix } // namespace radix
#ifndef RADIX_RADIXWIDGETS_TABWIDGET_HH_ #ifndef RADIX_RADIXWIDGETS_TABWIDGET_HH_
#define RADIX_RADIXWIDGETS_TABWIDGET_HH_ #define RADIX_RADIXWIDGETS_TABWIDGET_HH_
#include <QPushButton>
#include <QTabWidget> #include <QTabWidget>
#include "radixcore/visibility.hh" #include "radixcore/visibility.hh"
...@@ -15,7 +16,10 @@ class RADIX_PUBLIC TabWidget : public QTabWidget ...@@ -15,7 +16,10 @@ class RADIX_PUBLIC TabWidget : public QTabWidget
Q_OBJECT Q_OBJECT
public: public:
TabWidget(QWidget *parent = 0); TabWidget(QWidget *parent = nullptr);
private:
QPushButton *mNewButton;
signals: signals:
void addTabRequested(); void addTabRequested();
......
...@@ -832,6 +832,7 @@ bool vtkPlotPointsErrorBars::UpdateTableCache(vtkTable *table) ...@@ -832,6 +832,7 @@ bool vtkPlotPointsErrorBars::UpdateTableCache(vtkTable *table)
} }
vtkDataArray *x = array[0]; vtkDataArray *x = array[0];
vtkDataArray *y = array[1]; vtkDataArray *y = array[1];
if (x == nullptr || y == nullptr) return false;
// Now copy the components into their new columns // Now copy the components into their new columns
if (this->UseIndexForXSeries) if (this->UseIndexForXSeries)
...@@ -868,7 +869,7 @@ bool vtkPlotPointsErrorBars::UpdateTableCache(vtkTable *table) ...@@ -868,7 +869,7 @@ bool vtkPlotPointsErrorBars::UpdateTableCache(vtkTable *table)
if (xErr) if (xErr)
{ {
switch (xErr->GetDataType()) switch (xErr->GetDataType())
{ {
vtkTemplateMacro(CopyToXErrors( vtkTemplateMacro(CopyToXErrors(
this->XErrors, static_cast<VTK_TT *>(xErr->GetVoidPointer(0)), this->XErrors, static_cast<VTK_TT *>(xErr->GetVoidPointer(0)),
int(xErr->GetNumberOfTuples()), this->ShiftScale)); int(xErr->GetNumberOfTuples()), this->ShiftScale));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment