- fix crash on exit without opened database

This commit is contained in:
Dmytro Bogovych 2022-05-23 22:48:42 +03:00
parent 9f47e9cb37
commit 0d02f89a4b
2 changed files with 19 additions and 16 deletions

View File

@ -271,12 +271,15 @@ void MainWindow::initClient()
void MainWindow::save() void MainWindow::save()
{ {
// Flush current task // Flush current task
PTask t = mTaskTreeModel->getTask(ui->mTaskTree->currentIndex()); if (mTaskTreeModel)
if (t)
{ {
t->setHtml(ui->mNoteEdit->document()->toPlainText()); PTask t = mTaskTreeModel->getTask(ui->mTaskTree->currentIndex());
t->save(); if (t)
mModifiedLabel->setText(tr("Saved")); {
t->setHtml(ui->mNoteEdit->document()->toPlainText());
t->save();
mModifiedLabel->setText(tr("Saved"));
}
} }
try try

View File

@ -54,18 +54,18 @@ private:
TrackingStopReason mStopReason; TrackingStopReason mStopReason;
Ui::MainWindow *ui = nullptr; Ui::MainWindow *ui = nullptr;
TaskTreeModel* mTaskTreeModel; TaskTreeModel* mTaskTreeModel = nullptr;
PTask mCurrentTask, mAutomaticTask; PTask mCurrentTask, mAutomaticTask;
QTimer* mUpdateTimer; QTimer* mUpdateTimer = nullptr;
QLabel* mModifiedLabel; QLabel* mModifiedLabel = nullptr;
QLabel* mCurrentIntervalLabel; QLabel* mCurrentIntervalLabel = nullptr;
QLabel* mDuplicationSignalLabel; QLabel* mDuplicationSignalLabel = nullptr;;
QSystemTrayIcon *mTrayIcon; QSystemTrayIcon *mTrayIcon = nullptr;
QSharedPointer<Settings> mSettings; QSharedPointer<Settings> mSettings;
bool mPasswordFailed; bool mPasswordFailed;
PasswordDlg* mPasswordDlg; PasswordDlg* mPasswordDlg = nullptr;
NewPasswordDlg* mNewPasswordDlg; NewPasswordDlg* mNewPasswordDlg = nullptr;
QMessageBox* mAlertBox; QMessageBox* mAlertBox = nullptr;
// Time when current note was saved to DB last time // Time when current note was saved to DB last time
QDateTime mLastTimelineFlush; QDateTime mLastTimelineFlush;
@ -74,7 +74,7 @@ private:
QAction* mAttachmentsAction; QAction* mAttachmentsAction;
// Attachments label // Attachments label
QLabel* mAttachmentsLabel; QLabel* mAttachmentsLabel = nullptr;
// Delegate to draw task items in custom way // Delegate to draw task items in custom way
TaskItemDelegate mTaskItemDelegate; TaskItemDelegate mTaskItemDelegate;
@ -92,7 +92,7 @@ private:
QDateTime mTextModificationTime; QDateTime mTextModificationTime;
std::deque<PTask> mRecentTrackingTasks; std::deque<PTask> mRecentTrackingTasks;
QMenu* mDockRecentMenu; QMenu* mDockRecentMenu = nullptr;
QDialog* mTrayWindow = nullptr; QDialog* mTrayWindow = nullptr;
QString mPassword = NOPASSWORDSTRING; QString mPassword = NOPASSWORDSTRING;
ConnectDbWidget* mConnectDbWidget = nullptr; ConnectDbWidget* mConnectDbWidget = nullptr;