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)
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,
&day, &hour, &minute, &second, &zone, &daylight);
(void)sizeof(count);
radix_line("utc_to_time elements: " << count);
struct std::tm res;
res.tm_year = year;
......
......@@ -71,9 +71,10 @@ std::string computer_name()
char *hostname;
#ifndef _WIN32
hostname = new char[256];
hostname[255] = '\0';
if (gethostname(hostname, 256) != 0)
{
strcpy(hostname, "Unknown");
strncpy(hostname, "Unknown", 255);
}
std::string result(hostname);
delete[] hostname;
......@@ -485,6 +486,7 @@ long get_process_memory()
char buffer[128];
strncpy(buffer, line.substr(6).c_str(),
std::min(sizeof(buffer), line.size() - 6));
buffer[127] = '\0';
caddr_t context = nullptr, token = strtok_r(buffer, " \t", &context);
if (token != nullptr) result = long(atoi(token)) * 1024L;
......
......@@ -19,10 +19,13 @@ class NavigationActionManager::PImpl
NavigationActionManager::PImpl::~PImpl() {}
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,
std::function<void()> functor)
{
......
......@@ -25,6 +25,7 @@ class RADIX_PUBLIC NavigationActionManager : public QObject
private:
class PImpl;
std::unique_ptr<PImpl, void (*)(PImpl *)> p;
static void deleter(PImpl *impl);
};
} // namespace radix
......
......@@ -19,25 +19,27 @@ class NavigationItem::PImpl
NavigationItem::PImpl::~PImpl() { qDeleteAll(children); }
NavigationItem::NavigationItem(QVariant data, NavigationItem *parentItem)
: p(new PImpl(), [](PImpl *impl) { delete impl; })
: p(new PImpl(), deleter)
{
p->parent = parentItem;
p->data.append(data);
}
NavigationItem::NavigationItem(QList<QVariant> data, NavigationItem *parentItem)
: p(new PImpl(), [](PImpl *impl) { delete impl; })
: p(new PImpl(), deleter)
{
p->parent = parentItem;
p->data = data;
}
NavigationItem::NavigationItem(NavigationItem *parentItem)
: p(new PImpl(), [](PImpl *impl) { delete impl; })
: p(new PImpl(), deleter)
{
p->parent = parentItem;
}
void NavigationItem::deleter(PImpl *impl) { delete impl; }
int NavigationItem::type() const { return p->type; }
void NavigationItem::setType(int type) { p->type = type; }
......
......@@ -30,6 +30,7 @@ class RADIX_PUBLIC NavigationItem
private:
class PImpl;
std::unique_ptr<PImpl, void (*)(PImpl *)> p;
static void deleter(PImpl *impl);
};
} // namespace radix
......
......@@ -21,11 +21,13 @@ NavigationModel::PImpl::~PImpl()
}
NavigationModel::NavigationModel(QObject* parent)
: QAbstractItemModel(parent)
, p(new PImpl(), [](PImpl* impl) { delete impl; })
, p(new PImpl(), deleter)
{
p->root = new NavigationItem();
}
void NavigationModel::deleter(PImpl* impl) { delete impl; }
QVariant NavigationModel::data(const QModelIndex& index, int role) const
{
if (!index.isValid()) return QVariant();
......
......@@ -38,6 +38,7 @@ class RADIX_PUBLIC NavigationModel : public QAbstractItemModel
private:
class PImpl;
std::unique_ptr<PImpl, void (*)(PImpl *)> p;
static void deleter(PImpl *impl);
};
} // namespace radix
......
......@@ -34,10 +34,12 @@ class RADIX_PUBLIC NavigationItemSortFilterProxyModel::PImpl
NavigationItemSortFilterProxyModel::NavigationItemSortFilterProxyModel(
QObject* 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
{
const QString& text = index.data().toString();
......@@ -85,12 +87,14 @@ class RADIX_PUBLIC NavigationWidget::PImpl
NavigationWidget::NavigationWidget(QWidget* parent)
: QWidget(parent)
, p(new PImpl(), [](PImpl* impl) { delete impl; })
, p(new PImpl(), deleter)
{
initMembers();
initLayout();
}
void NavigationWidget::deleter(PImpl* impl) { delete impl; }
NavigationModel* NavigationWidget::navigationModel() { return p->model; }
NavigationActionManager* NavigationWidget::navigationActionManager()
......
......@@ -22,7 +22,8 @@ class NavigationItem;
class NavigationModel;
class NavigationActionManager;
class RADIX_PUBLIC NavigationItemSortFilterProxyModel : public QSortFilterProxyModel
class RADIX_PUBLIC NavigationItemSortFilterProxyModel
: public QSortFilterProxyModel
{
Q_OBJECT
......@@ -39,6 +40,7 @@ class RADIX_PUBLIC NavigationItemSortFilterProxyModel : public QSortFilterProxyM
bool accepts(const QModelIndex& index) const;
class PImpl;
std::unique_ptr<PImpl, void (*)(PImpl*)> p;
static void deleter(PImpl* impl);
};
class RADIX_PUBLIC NavigationWidget : public QWidget
......@@ -73,6 +75,7 @@ class RADIX_PUBLIC NavigationWidget : public QWidget
class PImpl;
std::unique_ptr<PImpl, void (*)(PImpl*)> p;
static void deleter(PImpl* impl);
};
} // namespace radix
......
......@@ -29,10 +29,12 @@ TableView::PImpl::PImpl()
TableView::TableView(QWidget *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; }
void TableView::setSeparator(char value) { p->separator = value; }
......
......@@ -21,9 +21,10 @@ class RADIX_PUBLIC TableView : public QTableView
class PImpl;
std::unique_ptr<PImpl, void (*)(PImpl *)> p;
static void deleter(PImpl *impl);
public:
TableView(QWidget *parent = 0);
TableView(QWidget *parent = nullptr);
char separator() const;
void setSeparator(char value);
......
......@@ -3,7 +3,6 @@
#include <iostream>
#include <QLabel>
#include <QPushButton>
#include <QTabBar>
#include <QToolButton>
......@@ -16,15 +15,15 @@ TabWidget::TabWidget(QWidget *parent)
setTabsClosable(true);
//
// create a 'new tab' button
QPushButton *newButton = new QPushButton("+", this);
newButton->setObjectName("tabs_new_tab_button");
newButton->setToolTip("Add new tab");
newButton->setMaximumWidth(25);
mNewButton = new QPushButton("+", this);
mNewButton->setObjectName("tabs_new_tab_button");
mNewButton->setToolTip("Add new tab");
mNewButton->setMaximumWidth(25);
addTab(new QLabel(""), QString(""));
QWidget *newTabWidget = widget(0);
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
QWidget *temp = tabBar()->tabButton(0, QTabBar::LeftSide);
if (temp) temp->hide();
......@@ -34,7 +33,7 @@ TabWidget::TabWidget(QWidget *parent)
setCurrentIndex(-1);
// forward pushbutton signal
connect(newButton, SIGNAL(clicked(bool)), this, SIGNAL(addTabRequested()));
connect(mNewButton, SIGNAL(clicked(bool)), this, SIGNAL(addTabRequested()));
}
} // namespace radix
#ifndef RADIX_RADIXWIDGETS_TABWIDGET_HH_
#define RADIX_RADIXWIDGETS_TABWIDGET_HH_
#include <QPushButton>
#include <QTabWidget>
#include "radixcore/visibility.hh"
......@@ -15,7 +16,10 @@ class RADIX_PUBLIC TabWidget : public QTabWidget
Q_OBJECT
public:
TabWidget(QWidget *parent = 0);
TabWidget(QWidget *parent = nullptr);
private:
QPushButton *mNewButton;
signals:
void addTabRequested();
......
......@@ -832,6 +832,7 @@ bool vtkPlotPointsErrorBars::UpdateTableCache(vtkTable *table)
}
vtkDataArray *x = array[0];
vtkDataArray *y = array[1];
if (x == nullptr || y == nullptr) return false;
// Now copy the components into their new columns
if (this->UseIndexForXSeries)
......
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