mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59: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();
|
||||
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;
|
||||
try {
|
||||
m_newNode = nb->copyAsNode(m_parentNode, Node::Flag::Container, folder);
|
||||
|
@ -163,8 +163,12 @@ void ManageNotebooksDialog::loadNotebooks(const Notebook *p_notebook)
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasCurrentItem && !notebooks.isEmpty()) {
|
||||
m_notebookList->setCurrentRow(0);
|
||||
if (!hasCurrentItem) {
|
||||
if (notebooks.isEmpty()) {
|
||||
selectNotebook(nullptr);
|
||||
} else {
|
||||
m_notebookList->setCurrentRow(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,6 +177,10 @@ void ManageNotebooksDialog::selectNotebook(Notebook *p_notebook)
|
||||
m_notebookInfoWidget->setNotebook(p_notebook);
|
||||
setChangesUnsaved(false);
|
||||
|
||||
// Update buttons.
|
||||
m_closeNotebookBtn->setEnabled(p_notebook);
|
||||
m_deleteNotebookBtn->setEnabled(p_notebook);
|
||||
|
||||
WidgetUtils::resizeToHideScrollBarLater(m_infoScrollArea, false, true);
|
||||
}
|
||||
|
||||
@ -217,7 +225,10 @@ bool ManageNotebooksDialog::saveChangesToNotebook()
|
||||
|
||||
void ManageNotebooksDialog::closeNotebook(const Notebook *p_notebook)
|
||||
{
|
||||
Q_ASSERT(p_notebook);
|
||||
if (!p_notebook) {
|
||||
return;
|
||||
}
|
||||
|
||||
int ret = MessageBoxHelper::questionOkCancel(MessageBoxHelper::Question,
|
||||
tr("Close notebook (%1)?")
|
||||
.arg(p_notebook->getName()),
|
||||
@ -244,7 +255,10 @@ void ManageNotebooksDialog::closeNotebook(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,
|
||||
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. "
|
||||
|
Loading…
x
Reference in New Issue
Block a user