diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp index 8e32426..e5ca84c 100644 --- a/client/mainwindow.cpp +++ b/client/mainwindow.cpp @@ -271,12 +271,15 @@ void MainWindow::initClient() void MainWindow::save() { // Flush current task - PTask t = mTaskTreeModel->getTask(ui->mTaskTree->currentIndex()); - if (t) + if (mTaskTreeModel) { - t->setHtml(ui->mNoteEdit->document()->toPlainText()); - t->save(); - mModifiedLabel->setText(tr("Saved")); + PTask t = mTaskTreeModel->getTask(ui->mTaskTree->currentIndex()); + if (t) + { + t->setHtml(ui->mNoteEdit->document()->toPlainText()); + t->save(); + mModifiedLabel->setText(tr("Saved")); + } } try diff --git a/client/mainwindow.h b/client/mainwindow.h index f943d72..14eed76 100644 --- a/client/mainwindow.h +++ b/client/mainwindow.h @@ -54,18 +54,18 @@ private: TrackingStopReason mStopReason; Ui::MainWindow *ui = nullptr; - TaskTreeModel* mTaskTreeModel; + TaskTreeModel* mTaskTreeModel = nullptr; PTask mCurrentTask, mAutomaticTask; - QTimer* mUpdateTimer; - QLabel* mModifiedLabel; - QLabel* mCurrentIntervalLabel; - QLabel* mDuplicationSignalLabel; - QSystemTrayIcon *mTrayIcon; + QTimer* mUpdateTimer = nullptr; + QLabel* mModifiedLabel = nullptr; + QLabel* mCurrentIntervalLabel = nullptr; + QLabel* mDuplicationSignalLabel = nullptr;; + QSystemTrayIcon *mTrayIcon = nullptr; QSharedPointer mSettings; bool mPasswordFailed; - PasswordDlg* mPasswordDlg; - NewPasswordDlg* mNewPasswordDlg; - QMessageBox* mAlertBox; + PasswordDlg* mPasswordDlg = nullptr; + NewPasswordDlg* mNewPasswordDlg = nullptr; + QMessageBox* mAlertBox = nullptr; // Time when current note was saved to DB last time QDateTime mLastTimelineFlush; @@ -74,7 +74,7 @@ private: QAction* mAttachmentsAction; // Attachments label - QLabel* mAttachmentsLabel; + QLabel* mAttachmentsLabel = nullptr; // Delegate to draw task items in custom way TaskItemDelegate mTaskItemDelegate; @@ -92,7 +92,7 @@ private: QDateTime mTextModificationTime; std::deque mRecentTrackingTasks; - QMenu* mDockRecentMenu; + QMenu* mDockRecentMenu = nullptr; QDialog* mTrayWindow = nullptr; QString mPassword = NOPASSWORDSTRING; ConnectDbWidget* mConnectDbWidget = nullptr;