mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 22:09:52 +08:00
fix crash issues
This commit is contained in:
parent
59e8163f27
commit
fb15ed871b
@ -84,6 +84,15 @@ bool ImportFolderDialog::importFolder()
|
|||||||
{
|
{
|
||||||
const auto folder = m_filterWidget->getFolderPath();
|
const auto folder = m_filterWidget->getFolderPath();
|
||||||
auto nb = m_parentNode->getNotebook();
|
auto nb = m_parentNode->getNotebook();
|
||||||
|
if (PathUtils::pathContains(folder, m_parentNode->fetchAbsolutePath()))
|
||||||
|
{
|
||||||
|
// Avoid recursive import.
|
||||||
|
auto msg = tr("Failed to add folder (%1) as node under (%2).").arg(folder, m_parentNode->fetchAbsolutePath());
|
||||||
|
qCritical() << msg;
|
||||||
|
setInformationText(msg, ScrollDialog::InformationLevel::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
m_newNode = nullptr;
|
m_newNode = nullptr;
|
||||||
try {
|
try {
|
||||||
m_newNode = nb->copyAsNode(m_parentNode, Node::Flag::Container, folder);
|
m_newNode = nb->copyAsNode(m_parentNode, Node::Flag::Container, folder);
|
||||||
|
@ -163,16 +163,24 @@ void ManageNotebooksDialog::loadNotebooks(const Notebook *p_notebook)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasCurrentItem && !notebooks.isEmpty()) {
|
if (!hasCurrentItem) {
|
||||||
|
if (notebooks.isEmpty()) {
|
||||||
|
selectNotebook(nullptr);
|
||||||
|
} else {
|
||||||
m_notebookList->setCurrentRow(0);
|
m_notebookList->setCurrentRow(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ManageNotebooksDialog::selectNotebook(Notebook *p_notebook)
|
void ManageNotebooksDialog::selectNotebook(Notebook *p_notebook)
|
||||||
{
|
{
|
||||||
m_notebookInfoWidget->setNotebook(p_notebook);
|
m_notebookInfoWidget->setNotebook(p_notebook);
|
||||||
setChangesUnsaved(false);
|
setChangesUnsaved(false);
|
||||||
|
|
||||||
|
// Update buttons.
|
||||||
|
m_closeNotebookBtn->setEnabled(p_notebook);
|
||||||
|
m_deleteNotebookBtn->setEnabled(p_notebook);
|
||||||
|
|
||||||
WidgetUtils::resizeToHideScrollBarLater(m_infoScrollArea, false, true);
|
WidgetUtils::resizeToHideScrollBarLater(m_infoScrollArea, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +225,10 @@ bool ManageNotebooksDialog::saveChangesToNotebook()
|
|||||||
|
|
||||||
void ManageNotebooksDialog::closeNotebook(const Notebook *p_notebook)
|
void ManageNotebooksDialog::closeNotebook(const Notebook *p_notebook)
|
||||||
{
|
{
|
||||||
Q_ASSERT(p_notebook);
|
if (!p_notebook) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int ret = MessageBoxHelper::questionOkCancel(MessageBoxHelper::Question,
|
int ret = MessageBoxHelper::questionOkCancel(MessageBoxHelper::Question,
|
||||||
tr("Close notebook (%1)?")
|
tr("Close notebook (%1)?")
|
||||||
.arg(p_notebook->getName()),
|
.arg(p_notebook->getName()),
|
||||||
@ -244,7 +255,10 @@ void ManageNotebooksDialog::closeNotebook(const Notebook *p_notebook)
|
|||||||
|
|
||||||
void ManageNotebooksDialog::removeNotebook(const Notebook *p_notebook)
|
void ManageNotebooksDialog::removeNotebook(const Notebook *p_notebook)
|
||||||
{
|
{
|
||||||
Q_ASSERT(p_notebook);
|
if (!p_notebook) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int ret = MessageBoxHelper::questionOkCancel(MessageBoxHelper::Warning,
|
int ret = MessageBoxHelper::questionOkCancel(MessageBoxHelper::Warning,
|
||||||
tr("Delete notebook (%1) from disk?").arg(p_notebook->getName()),
|
tr("Delete notebook (%1) from disk?").arg(p_notebook->getName()),
|
||||||
tr("CALM DOWN! CALM DOWN! CALM DOWN! It will delete all files belonging to this notebook from disk. "
|
tr("CALM DOWN! CALM DOWN! CALM DOWN! It will delete all files belonging to this notebook from disk. "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user