Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions easy_profiler_converter/converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void JsonExporter::convertChildren(const profiler::reader::BlocksTreeNode& node,
convert(child, children.back());
}

json["children"] = children;
json["children"] = std::move(children);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's stopping the move assignment from happening already? children is an xvalue, yes?

}

void JsonExporter::convert(const ::std::string& inputFile, const ::std::string& outputFile) const
Expand Down Expand Up @@ -104,7 +104,7 @@ void JsonExporter::convert(const ::std::string& inputFile, const ::std::string&
desc["sourceLine"] = descriptor.lineNumber;
}

json["blockDescriptors"] = descriptors;
json["blockDescriptors"] = std::move(descriptors);
}

// convert threads and blocks
Expand All @@ -122,7 +122,7 @@ void JsonExporter::convert(const ::std::string& inputFile, const ::std::string&
convertChildren(kv.second, thread);
}

json["threads"] = threads;
json["threads"] = std::move(threads);
}

// convert bookmarks
Expand All @@ -142,7 +142,7 @@ void JsonExporter::convert(const ::std::string& inputFile, const ::std::string&
bookmark["text"] = mark.text;
}

json["bookmarks"] = bookmarks;
json["bookmarks"] = std::move(bookmarks);
}

try
Expand Down
8 changes: 4 additions & 4 deletions easy_profiler_core/include/easy/serialized_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ namespace profiler {
using value_type = typename StdType<dataType>::value_type;
const value_type* value() const { return reinterpret_cast<const value_type*>(data()); }
uint16_t size() const { return m_size / sizeof(value_type); }
value_type operator [] (int i) const { return value()[i]; }
value_type at(int i) const { return value()[i]; }
value_type operator [] (size_t i) const { return value()[i]; }
value_type at(size_t i) const { return value()[i]; }
~Value() = delete;
};

Expand All @@ -270,8 +270,8 @@ namespace profiler {
using value_type = char;
const char* value() const { return data(); }
uint16_t size() const { return m_size; }
char operator [] (int i) const { return data()[i]; }
char at(int i) const { return data()[i]; }
char operator [] (size_t i) const { return data()[i]; }
char at(size_t i) const { return data()[i]; }
const char* c_str() const { return data(); }
~Value() = delete;
};
Expand Down
3 changes: 3 additions & 0 deletions easy_profiler_core/nonscoped_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ void NonscopedBlock::copyname()
auto len = strlen(m_name);
m_runtimeName = static_cast<char*>(malloc(len + 1));

if (!m_runtimeName)
destroy();

// memcpy should be faster than strncpy because we know
// actual bytes number and both strings have the same size
memcpy(m_runtimeName, m_name, len);
Expand Down
12 changes: 6 additions & 6 deletions easy_profiler_core/reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ extern "C" PROFILER_API profiler::block_index_t fillTreesFromStream(std::atomic<
//validate_pointers(progress, olddata, serialized_descriptors, descriptors, descriptors.size());

uint64_t i = 0;
while (!inStream.eof() && descriptors.size() < descriptors_count)
while (!inStream.eof() && !inStream.fail() && descriptors.size() < descriptors_count)
{
uint16_t sz = 0;
read(inStream, sz);
Expand Down Expand Up @@ -985,7 +985,7 @@ extern "C" PROFILER_API profiler::block_index_t fillTreesFromStream(std::atomic<

ReaderThreadPool pool;

while (!inStream.eof() && threads_read_number++ < header.threads_count)
while (!inStream.eof() && !inStream.fail() && threads_read_number++ < header.threads_count)
{
EASY_BLOCK("Read thread data", profiler::colors::DarkGreen);

Expand Down Expand Up @@ -1020,7 +1020,7 @@ extern "C" PROFILER_API profiler::block_index_t fillTreesFromStream(std::atomic<
uint32_t blocks_number_in_thread = 0;
read(inStream, blocks_number_in_thread);
auto threshold = read_number + blocks_number_in_thread;
while (!inStream.eof() && read_number < threshold)
while (!inStream.eof() && !inStream.fail() && read_number < threshold)
{
EASY_BLOCK("Read context switch", profiler::colors::Green);

Expand Down Expand Up @@ -1091,7 +1091,7 @@ extern "C" PROFILER_API profiler::block_index_t fillTreesFromStream(std::atomic<
blocks_number_in_thread = 0;
read(inStream, blocks_number_in_thread);
threshold = read_number + blocks_number_in_thread;
while (!inStream.eof() && read_number < threshold)
while (!inStream.eof() && !inStream.fail() && read_number < threshold)
{
EASY_BLOCK("Read block", profiler::colors::Green);

Expand Down Expand Up @@ -1282,7 +1282,7 @@ extern "C" PROFILER_API profiler::block_index_t fillTreesFromStream(std::atomic<
std::vector<char> stringBuffer;
read_number = 0;

while (!inStream.eof() && read_number < header.bookmarks_count)
while (!inStream.eof() && !inStream.fail() && read_number < header.bookmarks_count)
{
profiler::Bookmark bookmark;

Expand Down Expand Up @@ -1511,7 +1511,7 @@ extern "C" PROFILER_API bool readDescriptionsFromStream(std::atomic<int>& progre
//validate_pointers(progress, olddata, serialized_descriptors, descriptors, descriptors.size());

uint64_t i = 0;
while (!inStream.eof() && descriptors.size() < descriptors_count)
while (!inStream.eof() && !inStream.fail() && descriptors.size() < descriptors_count)
{
uint16_t sz = 0;
read(inStream, sz);
Expand Down
19 changes: 10 additions & 9 deletions profiler_gui/arbitrary_value_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1658,7 +1658,7 @@ GraphicsChart::GraphicsChart(QWidget* _parent)

GraphicsChart::~GraphicsChart()
{

delete m_chartItem;
}

void GraphicsChart::onAutoAdjustChartChanged()
Expand Down Expand Up @@ -1857,7 +1857,8 @@ void ArbitraryTreeWidgetItem::interrupt()
return;

m_collection->interrupt();
m_collection.release();
auto* raw = m_collection.release();
delete raw;
}

profiler::color_t ArbitraryTreeWidgetItem::color() const
Expand Down Expand Up @@ -2077,10 +2078,10 @@ ArbitraryTreeWidgetItem* findSimilarItem(QTreeWidgetItem* _parentItem, Arbitrary
for (int c = 0, childrenCount = _parentItem->childCount(); c < childrenCount; ++c)
{
auto child = _parentItem->child(c);
if (child->type() == ValueItemType)
if (child != nullptr && child->type() == ValueItemType)
{
auto item = reinterpret_cast<ArbitraryTreeWidgetItem*>(child);
if (item->getSelfIndexInArray() == index)
if (item != nullptr && item->getSelfIndexInArray() == index)
{
if (&_item->value() == &item->value())
{
Expand Down Expand Up @@ -2148,7 +2149,7 @@ ArbitraryValuesWidget::ArbitraryValuesWidget(const QList<ArbitraryTreeWidgetItem
for (int i = 0, childCount = parentItem->childCount(); i < childCount; ++i)
{
auto child = parentItem->child(i);
if (child->checkState(CheckColumn) != Qt::Checked)
if (child != nullptr && child->checkState(CheckColumn) != Qt::Checked)
{
newState = Qt::PartiallyChecked;
break;
Expand Down Expand Up @@ -2285,7 +2286,7 @@ void ArbitraryValuesWidget::onItemChanged(QTreeWidgetItem* _item, int _column)
for (int i = 0; i < parentItem->childCount(); ++i)
{
auto child = parentItem->child(i);
if (child->checkState(CheckColumn) != Qt::Checked)
if (child != nullptr && child->checkState(CheckColumn) != Qt::Checked)
{
newState = Qt::PartiallyChecked;
break;
Expand All @@ -2303,7 +2304,7 @@ void ArbitraryValuesWidget::onItemChanged(QTreeWidgetItem* _item, int _column)
for (int i = 0; i < item->childCount(); ++i)
{
auto child = static_cast<ArbitraryTreeWidgetItem*>(item->child(i));
if (child->checkState(CheckColumn) != Qt::Checked)
if (child != nullptr && child->checkState(CheckColumn) != Qt::Checked)
{
child->setCheckState(CheckColumn, Qt::Checked);
m_checkedItems.push_back(child);
Expand Down Expand Up @@ -2343,7 +2344,7 @@ void ArbitraryValuesWidget::onItemChanged(QTreeWidgetItem* _item, int _column)
for (int i = 0; i < parentItem->childCount(); ++i)
{
auto child = parentItem->child(i);
if (child->checkState(CheckColumn) != Qt::Unchecked)
if (child != nullptr && child->checkState(CheckColumn) != Qt::Unchecked)
{
newState = Qt::PartiallyChecked;
break;
Expand All @@ -2361,7 +2362,7 @@ void ArbitraryValuesWidget::onItemChanged(QTreeWidgetItem* _item, int _column)
for (int i = 0; i < item->childCount(); ++i)
{
auto child = static_cast<ArbitraryTreeWidgetItem*>(item->child(i));
if (child->checkState(CheckColumn) == Qt::Checked)
if (child != nullptr && child->checkState(CheckColumn) == Qt::Checked)
{
child->setCheckState(CheckColumn, Qt::Unchecked);
uncheckedItems.push_back(child);
Expand Down
2 changes: 1 addition & 1 deletion profiler_gui/blocks_graphics_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1649,7 +1649,7 @@ void BlocksGraphicsView::mouseReleaseEvent(QMouseEvent* _event)
if (changedSelection)
{
profiler::timestamp_t left=0, right=0;
if (changedSelectionBySelectingItem)
if (selectedBlock != nullptr && changedSelectionBySelectingItem)
{
left = selectedBlock->tree.node->begin() - m_beginTime;
right = selectedBlock->tree.node->end() - m_beginTime;
Expand Down
2 changes: 1 addition & 1 deletion profiler_gui/dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ Dialog::Dialog(QWidget* parent, const QString& title, QWidget* content, WindowHe
mainLayout->addWidget(m_header, 0, Qt::AlignTop);
mainLayout->addWidget(content, 1);

auto buttonsLayout = new QHBoxLayout(m_buttonBox);
if (buttons != QMessageBox::NoButton)
{
auto buttonsLayout = new QHBoxLayout(m_buttonBox);
buttonsLayout->addStretch(1);
createButtons(buttonsLayout, buttons);
mainLayout->addWidget(m_buttonBox, 0, Qt::AlignBottom);
Expand Down
5 changes: 1 addition & 4 deletions profiler_gui/file_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ The Apache License, Version 2.0 (the "License");
#undef max
#endif

FileReader::FileReader()
{

}
FileReader::FileReader() = default;

FileReader::~FileReader()
{
Expand Down
2 changes: 1 addition & 1 deletion profiler_gui/graphics_block_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ const ::profiler_gui::EasyBlock* GraphicsBlockItem::intersect(const QPointF& _po
const auto dw = 5. / currentScale;
unsigned int i = 0;
size_t itemIndex = ::std::numeric_limits<size_t>::max();
size_t firstItem = 0, lastItem = static_cast<unsigned int>(level0.size());
size_t firstItem = 0, lastItem = level0.size();
while (i <= levelIndex)
{
const auto& level = m_levels[i];
Expand Down
4 changes: 2 additions & 2 deletions profiler_gui/graphics_scrollbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,7 @@ void GraphicsHistogramItem::updateImageAsync(QRectF _boundingRect, HistRegime _r
if (jt != it)
{
// bypass merged columns
it = jt;
it = std::move(jt);
--it;
}
}
Expand Down Expand Up @@ -1496,7 +1496,7 @@ void GraphicsHistogramItem::updateImageAsync(QRectF _boundingRect, HistRegime _r
if (jt != it)
{
// bypass merged columns
it = jt;
it = std::move(jt);
--it;
}
}
Expand Down
38 changes: 22 additions & 16 deletions profiler_gui/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ MainWindow::~MainWindow()
void MainWindow::validateLastDir()
{
if (m_lastFiles.empty())
EASY_GLOBALS.lastFileDir = QString();
EASY_GLOBALS.lastFileDir.clear();
else
EASY_GLOBALS.lastFileDir = QFileInfo(m_lastFiles.front()).absoluteDir().canonicalPath();
}
Expand Down Expand Up @@ -2061,23 +2061,26 @@ void MainWindow::onListenerTimerTimeout()
const auto passedTime = std::chrono::duration_cast<std::chrono::milliseconds>(now - m_listenStartTime).count();
const auto seconds = static_cast<double>(passedTime) * 1e-3;

switch (m_listener.regime())
if (m_listenerDialog)
{
case ListenerRegime::Capture:
switch (m_listener.regime())
{
m_listenerDialog->setTitle(QString("Capturing frames... %1s").arg(seconds, 0, 'f', 1));
break;
}
case ListenerRegime::Capture:
{
m_listenerDialog->setTitle(QString("Capturing frames... %1s").arg(seconds, 0, 'f', 1));
break;
}

case ListenerRegime::Capture_Receive:
{
m_listenerDialog->setTitle(QString("Receiving data... %1s").arg(seconds, 0, 'f', 1));
break;
}
case ListenerRegime::Capture_Receive:
{
m_listenerDialog->setTitle(QString("Receiving data... %1s").arg(seconds, 0, 'f', 1));
break;
}

default:
{
break;
default:
{
break;
}
}
}

Expand All @@ -2097,8 +2100,11 @@ void MainWindow::onListenerTimerTimeout()

m_listener.finalizeCapture();

m_listenerDialog->accept();
m_listenerDialog = nullptr;
if (m_listenerDialog)
{
m_listenerDialog->accept();
m_listenerDialog = nullptr;
}

if (m_listener.size() != 0)
{
Expand Down
2 changes: 1 addition & 1 deletion profiler_gui/round_progress_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ RoundProgressWidget::RoundProgressWidget(const QString& title, QWidget* parent)

RoundProgressWidget::~RoundProgressWidget()
{

delete m_indicator;
}

void RoundProgressWidget::setTitle(const QString& title)
Expand Down
3 changes: 1 addition & 2 deletions reader/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ class TreePrinter
std::vector<Info> m_rows;

public:
TreePrinter(){
TreePrinter() = default;

}
void addNewRow(int level)
{

Expand Down
2 changes: 1 addition & 1 deletion sample/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ int main(int argc, char* argv[])
EASY_ARRAY("threads count", grrr, 3, false, true, "blabla", profiler::colors::Blue/*, EASY_VIN("threads count")*/, profiler::OFF);
#endif

int* intPtr = new int(2);
int* intPtr = new int[2];
EASY_VALUE("count", *intPtr);

std::vector<std::thread> threads;
Expand Down