Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GeniusPaste: SIGSEGV fix #35

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 29 additions & 10 deletions geniuspaste/src/geniuspaste.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,12 @@ static void save_settings(void)
g_key_file_free(config);
}

static void paste(const gchar * website)
static void paste(GeanyDocument * doc, const gchar * website)
{
SoupSession *session = soup_session_async_new();
SoupMessage *msg = NULL;

GeanyDocument *doc = document_get_current();

if(doc == NULL)
{
dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("There are no opened documents. Open one and retry.\n"));
return;
}
doc = document_get_current();

GeanyFiletype *ft = doc->file_type;
GError *error = NULL;
Expand Down Expand Up @@ -197,8 +191,13 @@ static void paste(const gchar * website)
gboolean result;

occ_position = last_indexof(f_name, G_DIR_SEPARATOR);
f_title = f_name + occ_position + 1;
if(occ_position == -1)
{
dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("Unable to get the file name"));
return;
}

f_title = f_name + occ_position + 1;
load_settings();

switch (website_selected)
Expand Down Expand Up @@ -388,7 +387,27 @@ static void paste(const gchar * website)

static void item_activate(GtkMenuItem * menuitem, gpointer gdata)
{
paste(websites[website_selected]);
GeanyDocument *doc = document_get_current();

if(doc == NULL)
{
dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("There are no opened documents. Open one and retry.\n"));
return;
}
else if(doc->file_name == NULL)
{
dialogs_show_save_as();
}
else if(doc->changed)
{
if(document_save_file(doc, FALSE) == FALSE)
{
dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("Unable to save the current file"));
return;
}
}

paste(doc, websites[website_selected]);
}

static void on_configure_response(GtkDialog * dialog, gint response, gpointer * user_data)
Expand Down