mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-27 08:41:02 +08:00
#106 [Core][UI] Fixed reading bookmarks with empty text; Fixed overriding and restoring mouse cursor shape when hovering bookmark at the Diagram widget;
#0 [UI] Waiting until saving file is finished when closing the UI.
This commit is contained in:
parent
c85d15a4e2
commit
f0a588eec5
@ -1016,12 +1016,25 @@ extern "C" PROFILER_API profiler::block_index_t fillTreesFromStream(std::atomic<
|
|||||||
}
|
}
|
||||||
|
|
||||||
usedMemorySize -= static_cast<uint16_t>(profiler::Bookmark::BaseSize) - 1;
|
usedMemorySize -= static_cast<uint16_t>(profiler::Bookmark::BaseSize) - 1;
|
||||||
if (usedMemorySize > 1)
|
if (usedMemorySize > 0)
|
||||||
{
|
{
|
||||||
stringBuffer.resize(usedMemorySize);
|
stringBuffer.resize(usedMemorySize);
|
||||||
|
read(inStream, stringBuffer.data(), usedMemorySize);
|
||||||
|
|
||||||
inStream.read(stringBuffer.data(), usedMemorySize);
|
if (stringBuffer.back() != 0)
|
||||||
bookmark.text = stringBuffer.data();
|
{
|
||||||
|
stringBuffer.resize(stringBuffer.size() + 1);
|
||||||
|
stringBuffer.back() = 0;
|
||||||
|
|
||||||
|
_log << "Bad bookmark description:\n\"" << const_cast<const char*>(stringBuffer.data())
|
||||||
|
<< "\"\nWhich is not zero terminated string.\nLast symbol is: '"
|
||||||
|
<< const_cast<const char*>(stringBuffer.data() + stringBuffer.size() - 2) << "'";
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (usedMemorySize != 1)
|
||||||
|
bookmark.text = stringBuffer.data();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -413,15 +413,20 @@ bool BackgroundItem::mouseMove(const QPointF& scenePos)
|
|||||||
|
|
||||||
if (prev != m_bookmark)
|
if (prev != m_bookmark)
|
||||||
{
|
{
|
||||||
if (m_bookmark < bookmarks.size())
|
if (!profiler_gui::is_max(m_bookmark))
|
||||||
qApp->setOverrideCursor(QCursor(Qt::PointingHandCursor));
|
{
|
||||||
|
if (qApp->overrideCursor() == nullptr || qApp->overrideCursor()->shape() != Qt::PointingHandCursor)
|
||||||
|
qApp->setOverrideCursor(QCursor(Qt::PointingHandCursor));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
qApp->restoreOverrideCursor();
|
qApp->restoreOverrideCursor();
|
||||||
|
}
|
||||||
emit bookmarkChanged(m_bookmark);
|
emit bookmarkChanged(m_bookmark);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_bookmark < bookmarks.size())
|
if (!profiler_gui::is_max(m_bookmark))
|
||||||
{
|
{
|
||||||
if (!m_idleTimer.isActive())
|
if (!m_idleTimer.isActive())
|
||||||
m_idleTimer.start();
|
m_idleTimer.start();
|
||||||
@ -455,7 +460,7 @@ bool BackgroundItem::mouseMove(const QPointF& scenePos)
|
|||||||
|
|
||||||
bool BackgroundItem::mousePress(const QPointF& scenePos)
|
bool BackgroundItem::mousePress(const QPointF& scenePos)
|
||||||
{
|
{
|
||||||
m_bButtonPressed = m_bookmark < EASY_GLOBALS.bookmarks.size() && contains(scenePos);
|
m_bButtonPressed = !profiler_gui::is_max(m_bookmark) && contains(scenePos);
|
||||||
|
|
||||||
delete m_tooltip;
|
delete m_tooltip;
|
||||||
m_tooltip = nullptr;
|
m_tooltip = nullptr;
|
||||||
@ -470,7 +475,7 @@ bool BackgroundItem::mouseRelease(const QPointF& scenePos)
|
|||||||
|
|
||||||
m_bButtonPressed = false;
|
m_bButtonPressed = false;
|
||||||
|
|
||||||
if (m_bookmark < EASY_GLOBALS.bookmarks.size())
|
if (!profiler_gui::is_max(m_bookmark))
|
||||||
{
|
{
|
||||||
auto& bookmarks = EASY_GLOBALS.bookmarks;
|
auto& bookmarks = EASY_GLOBALS.bookmarks;
|
||||||
std::sort(bookmarks.begin(), bookmarks.end(),
|
std::sort(bookmarks.begin(), bookmarks.end(),
|
||||||
@ -492,7 +497,7 @@ bool BackgroundItem::mouseDoubleClick(const QPointF& scenePos)
|
|||||||
if (!contains(scenePos))
|
if (!contains(scenePos))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (m_bookmark < EASY_GLOBALS.bookmarks.size())
|
if (!profiler_gui::is_max(m_bookmark))
|
||||||
{
|
{
|
||||||
qApp->restoreOverrideCursor();
|
qApp->restoreOverrideCursor();
|
||||||
auto editor = new BookmarkEditor(m_bookmark, false, sceneView->parentWidget());
|
auto editor = new BookmarkEditor(m_bookmark, false, sceneView->parentWidget());
|
||||||
@ -515,7 +520,7 @@ bool BackgroundItem::mouseDoubleClick(const QPointF& scenePos)
|
|||||||
|
|
||||||
mouseMove(scenePos);
|
mouseMove(scenePos);
|
||||||
|
|
||||||
if (m_bookmark < bookmarks.size())
|
if (!profiler_gui::is_max(m_bookmark))
|
||||||
{
|
{
|
||||||
qApp->restoreOverrideCursor();
|
qApp->restoreOverrideCursor();
|
||||||
auto editor = new BookmarkEditor(m_bookmark, true, sceneView->parentWidget());
|
auto editor = new BookmarkEditor(m_bookmark, true, sceneView->parentWidget());
|
||||||
@ -534,7 +539,7 @@ void BackgroundItem::mouseLeave()
|
|||||||
if (m_idleTimer.isActive())
|
if (m_idleTimer.isActive())
|
||||||
m_idleTimer.stop();
|
m_idleTimer.stop();
|
||||||
|
|
||||||
if (m_bookmark < EASY_GLOBALS.bookmarks.size())
|
if (!profiler_gui::is_max(m_bookmark))
|
||||||
{
|
{
|
||||||
profiler_gui::set_max(m_bookmark);
|
profiler_gui::set_max(m_bookmark);
|
||||||
qApp->restoreOverrideCursor();
|
qApp->restoreOverrideCursor();
|
||||||
|
@ -1509,7 +1509,7 @@ void MainWindow::showEvent(QShowEvent* show_event)
|
|||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent* close_event)
|
void MainWindow::closeEvent(QCloseEvent* close_event)
|
||||||
{
|
{
|
||||||
if (m_bNetworkFileRegime || EASY_GLOBALS.has_local_changes)
|
if (!m_bCloseAfterSave && (m_bNetworkFileRegime || EASY_GLOBALS.has_local_changes))
|
||||||
{
|
{
|
||||||
// Warn user about unsaved network information and suggest to save
|
// Warn user about unsaved network information and suggest to save
|
||||||
const auto result = Dialog::question(this, "Unsaved session"
|
const auto result = Dialog::question(this, "Unsaved session"
|
||||||
@ -1518,6 +1518,13 @@ void MainWindow::closeEvent(QCloseEvent* close_event)
|
|||||||
if (result == QMessageBox::Yes)
|
if (result == QMessageBox::Yes)
|
||||||
{
|
{
|
||||||
onSaveFileClicked(true);
|
onSaveFileClicked(true);
|
||||||
|
if (m_reader.isSaving() && m_progress != nullptr)
|
||||||
|
{
|
||||||
|
// Wait until finish and close
|
||||||
|
m_bCloseAfterSave = true;
|
||||||
|
close_event->ignore();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (result == QMessageBox::Cancel)
|
else if (result == QMessageBox::Cancel)
|
||||||
{
|
{
|
||||||
@ -2156,6 +2163,11 @@ void MainWindow::onFileReaderTimeout()
|
|||||||
{
|
{
|
||||||
onSavingFinish();
|
onSavingFinish();
|
||||||
closeProgressDialogAndClearReader();
|
closeProgressDialogAndClearReader();
|
||||||
|
if (m_bCloseAfterSave)
|
||||||
|
{
|
||||||
|
setEnabled(false);
|
||||||
|
QTimer::singleShot(1500, this, &This::close);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -302,6 +302,7 @@ protected:
|
|||||||
uint16_t m_lastPort = 0;
|
uint16_t m_lastPort = 0;
|
||||||
bool m_bNetworkFileRegime = false;
|
bool m_bNetworkFileRegime = false;
|
||||||
bool m_bOpenedCacheFile = false;
|
bool m_bOpenedCacheFile = false;
|
||||||
|
bool m_bCloseAfterSave = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user