Commit 96c7da47 authored by Patrick Storz's avatar Patrick Storz 🦄

Remove _argv0 from Inkscape::Application

Currently it was only used as the least preferred (and therefore
effectively unused) location where to store the crash backup.

However it wasn't set properly since
  408cb49b
causing assertion errors while crashing.

On top of that argv0 is not a reliable way to determine the path to
the currently running executable anyway.

Fixes inkscape/inkscape#176
parent f73f407c
......@@ -569,7 +569,7 @@ template<>
void
ConcreteInkscapeApplication<Gio::Application>::on_startup2()
{
Inkscape::Application::create(nullptr, false);
Inkscape::Application::create(false);
}
#ifdef GDK_WINDOWING_QUARTZ
......@@ -582,7 +582,7 @@ void
ConcreteInkscapeApplication<Gtk::Application>::on_startup2()
{
// This should be completely rewritten.
Inkscape::Application::create(nullptr, _with_gui); // argv appears to not be used.
Inkscape::Application::create(_with_gui);
if (!_with_gui) {
return;
......
......@@ -161,10 +161,10 @@ Application::operator &() const
* Creates a new Inkscape::Application global object.
*/
void
Application::create(const char *argv0, bool use_gui)
Application::create(bool use_gui)
{
if (!Application::exists()) {
new Application(argv0, use_gui);
new Application(use_gui);
} else {
// g_assert_not_reached(); Can happen with InkscapeApplication
}
......@@ -361,11 +361,6 @@ void Application::autosave_init()
}
}
void Application::argv0(char const* argv)
{
_argv0 = g_strdup(argv);
}
/**
* \brief Add our CSS style sheets
*/
......@@ -489,7 +484,7 @@ Application::add_gtk_css()
* \pre Application::_S_inst == NULL
*/
Application::Application(const char* argv, bool use_gui) :
Application::Application(bool use_gui) :
_menus(nullptr),
_desktops(nullptr),
refCount(1),
......@@ -509,8 +504,6 @@ Application::Application(const char* argv, bool use_gui) :
bus_handler = signal (SIGBUS, Application::crash_handler);
#endif
_argv0 = g_strdup(argv);
// \TODO: this belongs to Application::init but if it isn't here
// then the Filters and Extensions menus don't work.
_S_inst = this;
......@@ -603,11 +596,6 @@ Application::~Application()
_menus = nullptr;
}
if (_argv0) {
g_free(_argv0);
_argv0 = nullptr;
}
_S_inst = nullptr; // this will probably break things
refCount = 0;
......@@ -668,7 +656,6 @@ Application::crash_handler (int /*signum*/)
gint count = 0;
gchar *curdir = g_get_current_dir(); // This one needs to be freed explicitly
gchar *inkscapedir = g_path_get_dirname(INKSCAPE._argv0); // Needs to be freed
std::vector<gchar *> savednames;
std::vector<gchar *> failednames;
for (std::map<SPDocument*,int>::iterator iter = INKSCAPE._document_set.begin(), e = INKSCAPE._document_set.end();
......@@ -714,7 +701,6 @@ Application::crash_handler (int /*signum*/)
g_get_home_dir(),
g_get_tmp_dir(),
curdir,
inkscapedir
};
FILE *file = nullptr;
for(auto & location : locations) {
......@@ -740,7 +726,6 @@ Application::crash_handler (int /*signum*/)
}
}
g_free(curdir);
g_free(inkscapedir);
if (!savednames.empty()) {
fprintf (stderr, "\nEmergency save document locations:\n");
......
......@@ -76,7 +76,7 @@ class Application {
public:
static Application& instance();
static bool exists();
static void create(const char* argv0, bool use_gui);
static void create(bool use_gui);
// returns the mask of the keyboard modifier to map to Alt, zero if no mapping
// Needs to be a guint because gdktypes.h does not define a 'no-modifier' value
......@@ -91,15 +91,12 @@ public:
bool use_gui() const { return _use_gui; }
void use_gui(gboolean guival) { _use_gui = guival; }
char const* argv0() const { return _argv0; }
void argv0(char const *);
// no setter for this -- only we can control this variable
static bool isCrashing() { return _crashIsHappening; }
// useful functions
void autosave_init();
void application_init (const gchar *argv0, gboolean use_gui);
void application_init (gboolean use_gui);
void load_config (const gchar *filename, Inkscape::XML::Document *config, const gchar *skeleton,
unsigned int skel_size, const gchar *e_notreg, const gchar *e_notxml,
const gchar *e_notsp, const gchar *warn);
......@@ -212,7 +209,7 @@ public:
private:
static Inkscape::Application * _S_inst;
Application(const char* argv0, bool use_gui);
Application(bool use_gui);
~Application();
Application(Application const&); // no copy
......@@ -228,7 +225,6 @@ public:
bool _dialogs_toggle;
guint _mapalt;
guint _trackalt;
char * _argv0;
static bool _crashIsHappening;
bool _use_gui;
gint _pdf_page;
......
......@@ -89,7 +89,7 @@ InkviewApplication::on_startup()
Gtk::Application::on_startup();
// Inkscape::Application should disappear!
Inkscape::Application::create(nullptr, true); // argv appears to not be used.
Inkscape::Application::create(true);
}
......
......@@ -457,10 +457,6 @@ char *homedir_path(const char *filename)
static const gchar *homedir = nullptr;
homedir = g_get_home_dir();
// I suspect this is for handling inkscape app packages
/*if (!homedir && Application::exists()) {
homedir = g_path_get_dirname(Application::instance()._argv0);
}*/
return g_build_filename(homedir, filename, NULL);
}
......
......@@ -26,7 +26,7 @@ void DocPerCaseTest::SetUpTestCase()
if ( !Inkscape::Application::exists() )
{
// Create the global inkscape object.
Inkscape::Application::create("", false);
Inkscape::Application::create(false);
}
_doc = SPDocument::createNewDoc( NULL, TRUE, true );
......
......@@ -15,7 +15,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
g_type_init();
Inkscape::GC::init();
if ( !Inkscape::Application::exists() )
Inkscape::Application::create("", false);
Inkscape::Application::create(false);
//void* a= sp_repr_read_mem((const char*)data, size, 0);
SPDocument *doc = SPDocument::createNewDocFromMem( (const char*)data, size, 0);
if(doc)
......
......@@ -40,7 +40,7 @@ T* createSuiteAndDocument( void (*fun)(T*&) )
if ( !Inkscape::Application::exists() )
{
// Create the global inkscape object.
Inkscape::Application::create("", false);
Inkscape::Application::create(false);
}
SPDocument* tmp = SPDocument::createNewDoc( NULL, TRUE, true );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment