added error message if settings initalizion failed
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
#include <csignal>
|
#include <csignal>
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
|
#include "common/Modes.hpp"
|
||||||
#include "common/NetworkManager.hpp"
|
#include "common/NetworkManager.hpp"
|
||||||
#include "singletons/Paths.hpp"
|
#include "singletons/Paths.hpp"
|
||||||
#include "singletons/Resources.hpp"
|
#include "singletons/Resources.hpp"
|
||||||
|
|||||||
+30
-3
@@ -5,6 +5,7 @@
|
|||||||
#include "BrowserExtension.hpp"
|
#include "BrowserExtension.hpp"
|
||||||
#include "RunGui.hpp"
|
#include "RunGui.hpp"
|
||||||
#include "common/Args.hpp"
|
#include "common/Args.hpp"
|
||||||
|
#include "common/Modes.hpp"
|
||||||
#include "singletons/Paths.hpp"
|
#include "singletons/Paths.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
#include "singletons/Settings.hpp"
|
||||||
#include "util/IncognitoBrowser.hpp"
|
#include "util/IncognitoBrowser.hpp"
|
||||||
@@ -28,9 +29,35 @@ int main(int argc, char **argv)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
initArgs(args);
|
initArgs(args);
|
||||||
Paths paths;
|
Paths *paths{};
|
||||||
Settings settings(paths.settingsDirectory);
|
|
||||||
|
|
||||||
runGui(a, paths, settings);
|
try
|
||||||
|
{
|
||||||
|
paths = new Paths;
|
||||||
|
}
|
||||||
|
catch (std::runtime_error &error)
|
||||||
|
{
|
||||||
|
QMessageBox box;
|
||||||
|
if (Modes::getInstance().isPortable)
|
||||||
|
{
|
||||||
|
box.setText(
|
||||||
|
error.what() +
|
||||||
|
QStringLiteral(
|
||||||
|
"\n\nInfo: Portable mode requires the application to "
|
||||||
|
"be in a writeable location. If you don't want "
|
||||||
|
"portable mode reinstall the application. "
|
||||||
|
"https://chatterino.com."));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
box.setText(error.what());
|
||||||
|
}
|
||||||
|
box.exec();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Settings settings(paths->settingsDirectory);
|
||||||
|
|
||||||
|
runGui(a, *paths, settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
#include "common/Modes.hpp"
|
#include "common/Modes.hpp"
|
||||||
#include "util/CombinePath.hpp"
|
#include "util/CombinePath.hpp"
|
||||||
|
|
||||||
|
using namespace std::literals;
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
Paths *Paths::instance = nullptr;
|
Paths *Paths::instance = nullptr;
|
||||||
@@ -22,7 +24,7 @@ Paths::Paths()
|
|||||||
this->initAppFilePathHash();
|
this->initAppFilePathHash();
|
||||||
|
|
||||||
this->initCheckPortable();
|
this->initCheckPortable();
|
||||||
this->initAppDataDirectory();
|
this->initRootDirectory();
|
||||||
this->initSubDirectories();
|
this->initSubDirectories();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +78,7 @@ void Paths::initCheckPortable()
|
|||||||
combinePath(QCoreApplication::applicationDirPath(), "portable"));
|
combinePath(QCoreApplication::applicationDirPath(), "portable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Paths::initAppDataDirectory()
|
void Paths::initRootDirectory()
|
||||||
{
|
{
|
||||||
assert(this->portable_.is_initialized());
|
assert(this->portable_.is_initialized());
|
||||||
|
|
||||||
@@ -95,8 +97,8 @@ void Paths::initAppDataDirectory()
|
|||||||
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||||
if (path.isEmpty())
|
if (path.isEmpty())
|
||||||
{
|
{
|
||||||
throw std::runtime_error(
|
throw std::runtime_error("Could not create directory \""s +
|
||||||
"Error finding writable location for settings");
|
path.toStdString() + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
// create directory Chatterino2 instead of chatterino on windows because the
|
// create directory Chatterino2 instead of chatterino on windows because the
|
||||||
@@ -123,8 +125,8 @@ void Paths::initSubDirectories()
|
|||||||
|
|
||||||
if (!QDir().mkpath(path))
|
if (!QDir().mkpath(path))
|
||||||
{
|
{
|
||||||
throw std::runtime_error(
|
throw std::runtime_error("Could not create directory \""s +
|
||||||
"Error creating appdata path %appdata%/chatterino/" + name);
|
path.toStdString() + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void initAppFilePathHash();
|
void initAppFilePathHash();
|
||||||
void initCheckPortable();
|
void initCheckPortable();
|
||||||
void initAppDataDirectory();
|
void initRootDirectory();
|
||||||
void initSubDirectories();
|
void initSubDirectories();
|
||||||
|
|
||||||
boost::optional<bool> portable_;
|
boost::optional<bool> portable_;
|
||||||
|
|||||||
Reference in New Issue
Block a user