diff --git a/main.cpp b/main.cpp index 46ea0f8..31aa7a0 100644 --- a/main.cpp +++ b/main.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include bool verbose = false; @@ -23,6 +24,7 @@ void handler(QtMsgType type, const QMessageLogContext &, const QString &msg) { break; case QtFatalMsg: fprintf(stderr, "FATAL: %s\n", localMsg.constData()); + notifications::notify("KShare Fatal Error", msg, QSystemTrayIcon::Critical); break; } } diff --git a/notifications.cpp b/notifications.cpp index d0eb421..1fedd55 100644 --- a/notifications.cpp +++ b/notifications.cpp @@ -4,6 +4,7 @@ #include void notifications::notify(QString title, QString body, QSystemTrayIcon::MessageIcon icon) { + if (!MainWindow::inst()) return; MainWindow::inst()->tray->showMessage(title, body, icon, 5000); MainWindow::inst()->statusBar()->showMessage(title + ": " + body); } diff --git a/uploaders/uploadersingleton.cpp b/uploaders/uploadersingleton.cpp index 4711c3d..6886acd 100644 --- a/uploaders/uploadersingleton.cpp +++ b/uploaders/uploadersingleton.cpp @@ -11,10 +11,12 @@ UploaderSingleton::UploaderSingleton() : QObject(), saveDir(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)) { if (QStandardPaths::writableLocation(QStandardPaths::PicturesLocation).isEmpty()) { - qFatal() << "Cannot determine location for pictures"; + qFatal("Cannot determine location for pictures"); } if (!saveDir.exists()) { - saveDir.mkpath(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)); + if (!saveDir.mkpath(".")) { + qFatal("Could not create the path %s to store images in!", saveDir.absoluteFilePath(".").toLocal8Bit().constData()); + } } QDir configDir(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation)); configDir.mkpath("KShare/uploaders"); diff --git a/uploaders/uploadersingleton.hpp b/uploaders/uploadersingleton.hpp index 8b6f8be..704b26b 100644 --- a/uploaders/uploadersingleton.hpp +++ b/uploaders/uploadersingleton.hpp @@ -2,6 +2,7 @@ #define UPLOADERSINGLETON_HPP #include "uploader.hpp" +#include #include class UploaderSingleton : public QObject { @@ -21,6 +22,7 @@ class UploaderSingleton : public QObject { void newUploader(Uploader *u); private: + QDir saveDir; UploaderSingleton(); QMap uploaders; QString uploader = "imgur";