From aad35fa9baff2a70dcd0a211a67bb6ea4da28357 Mon Sep 17 00:00:00 2001 From: leigh123linux Date: Sun, 2 Apr 2017 11:40:22 +0100 Subject: [PATCH] Redo patches with latest fixes --- fix_format_string_error.patch | 127 +++++++++++++++--- fix_wayland_segmentation_fault.patch | 189 ++++++++++++++++++++++++--- xed.spec | 9 +- 3 files changed, 286 insertions(+), 39 deletions(-) diff --git a/fix_format_string_error.patch b/fix_format_string_error.patch index 6370dab..ee3f9c8 100644 --- a/fix_format_string_error.patch +++ b/fix_format_string_error.patch @@ -1,30 +1,119 @@ -From 27adad6e289e92da8cbf770ddebfc9287588a429 Mon Sep 17 00:00:00 2001 -From: leigh123linux -Date: Sat, 1 Apr 2017 16:56:38 +0100 -Subject: [PATCH] fix 'format not a string literal, format string not checked' - error with gcc-7 +From 96a50bc803949eaee393cd1499f57830ccbe88d3 Mon Sep 17 00:00:00 2001 +From: JosephMcc +Date: Sat, 1 Apr 2017 12:06:22 -0700 +Subject: [PATCH] time-plugin: Use GDateTime +https://github.com/GNOME/gedit/commit/121f02a3ea066565eeae5dd42868f822ecce4924 --- - plugins/time/xed-time-plugin.c | 3 +++ - 1 file changed, 3 insertions(+) + plugins/time/xed-time-plugin.c | 58 ++++++++---------------------------------- + 1 file changed, 10 insertions(+), 48 deletions(-) diff --git a/plugins/time/xed-time-plugin.c b/plugins/time/xed-time-plugin.c -index 3fd3840..a7ffc0f 100644 +index 3fd3840..7d2983e 100644 --- a/plugins/time/xed-time-plugin.c +++ b/plugins/time/xed-time-plugin.c -@@ -346,12 +346,15 @@ get_time (const gchar* format) - clock = time (NULL); - now = localtime (&clock); +@@ -29,10 +29,6 @@ + #endif -+#pragma GCC diagnostic push -+#pragma GCC diagnostic ignored "-Wformat-nonliteral" - do + #include +-#include +- +-#include "xed-time-plugin.h" +-#include + + #include + #include +@@ -43,6 +39,8 @@ + #include + #include + #include ++#include ++#include "xed-time-plugin.h" + + #define XED_TIME_PLUGIN_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), \ + XED_TYPE_TIME_PLUGIN, \ +@@ -71,7 +69,6 @@ static const gchar *formats[] = + "%a %d %b %Y %H:%M:%S", + "%d/%m/%Y", + "%d/%m/%y", +- "%D", + "%A %d %B %Y", + "%A %B %d %Y", + "%Y-%m-%d", +@@ -88,9 +85,7 @@ static const gchar *formats[] = + "%I.%M %p", + "%d/%m/%Y %H:%M:%S", + "%d/%m/%y %H:%M:%S", +-#if __GLIBC__ >= 2 + "%a, %d %b %Y %H:%M:%S %z", +-#endif + NULL + }; + +@@ -319,58 +314,25 @@ get_custom_format (XedTimePlugin *plugin) + } + + static gchar * +-get_time (const gchar* format) ++get_time (const gchar *format) + { +- gchar *out = NULL; +- gchar *out_utf8 = NULL; +- time_t clock; +- struct tm *now; +- size_t out_length = 0; +- gchar *locale_format; ++ gchar *out; ++ GDateTime *now; + + xed_debug (DEBUG_PLUGINS); + + g_return_val_if_fail (format != NULL, NULL); + +- if (strlen (format) == 0) ++ if (*format == '\0') { - out_length += 255; - out = g_realloc (out, out_length); + return g_strdup (" "); } - while (strftime (out, out_length, locale_format, now) == 0); -+#pragma GCC diagnostic pop - g_free (locale_format); +- locale_format = g_locale_from_utf8 (format, -1, NULL, NULL, NULL); +- if (locale_format == NULL) +- { +- return g_strdup (" "); +- } +- +- clock = time (NULL); +- now = localtime (&clock); +- +- do +- { +- out_length += 255; +- out = g_realloc (out, out_length); +- } +- while (strftime (out, out_length, locale_format, now) == 0); +- +- g_free (locale_format); +- +- if (g_utf8_validate (out, -1, NULL)) +- { +- out_utf8 = out; +- } +- else +- { +- out_utf8 = g_locale_to_utf8 (out, -1, NULL, NULL, NULL); +- g_free (out); +- +- if (out_utf8 == NULL) +- { +- out_utf8 = g_strdup (" "); +- } +- } ++ now = g_date_time_new_now_local (); ++ out = g_date_time_format (now, format); ++ g_date_time_unref (now); +- return out_utf8; ++ return out; + } + + static void diff --git a/fix_wayland_segmentation_fault.patch b/fix_wayland_segmentation_fault.patch index dace7ea..3017397 100644 --- a/fix_wayland_segmentation_fault.patch +++ b/fix_wayland_segmentation_fault.patch @@ -1,22 +1,177 @@ -From 28fa1d1bf75ef32c2d77dd8fc9b001a6103d0ca8 Mon Sep 17 00:00:00 2001 -From: leigh123linux -Date: Sat, 1 Apr 2017 13:11:37 +0100 -Subject: [PATCH] Force X11 +From c6ca2a03daed515924bc1d4f9eee95132613ba2c Mon Sep 17 00:00:00 2001 +From: JosephMcc +Date: Sun, 2 Apr 2017 03:01:02 -0700 +Subject: [PATCH] xed-utils: Add runtime checks for x11 specific functions +This should prevent some crashes under wayland. --- - xed/xed.c | 2 ++ - 1 file changed, 2 insertions(+) + xed/xed-utils.c | 116 ++++++++++++++++++++++++++++++-------------------------- + 1 file changed, 63 insertions(+), 53 deletions(-) -diff --git a/xed/xed.c b/xed/xed.c -index 7dc2d6c..62b8bfb 100644 ---- a/xed/xed.c -+++ b/xed/xed.c -@@ -57,6 +57,8 @@ main (int argc, char *argv[]) - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); +diff --git a/xed/xed-utils.c b/xed/xed-utils.c +index 10cb13e..cf97cde 100644 +--- a/xed/xed-utils.c ++++ b/xed/xed-utils.c +@@ -54,8 +54,6 @@ + /* For the workspace/viewport stuff */ + #ifdef GDK_WINDOWING_X11 + #include +-#include +-#include + #include + #endif -+ gdk_set_allowed_backends ("x11"); +@@ -655,12 +653,6 @@ xed_utils_get_current_workspace (GdkScreen *screen) + #ifdef GDK_WINDOWING_X11 + GdkWindow *root_win; + GdkDisplay *display; +- Atom type; +- gint format; +- gulong nitems; +- gulong bytes_after; +- guint *current_desktop; +- gint err, result; + guint ret = 0; + + g_return_val_if_fail (GDK_IS_SCREEN (screen), 0); +@@ -668,24 +660,35 @@ xed_utils_get_current_workspace (GdkScreen *screen) + root_win = gdk_screen_get_root_window (screen); + display = gdk_screen_get_display (screen); + +- gdk_error_trap_push (); +- result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (root_win), +- gdk_x11_get_xatom_by_name_for_display (display, "_NET_CURRENT_DESKTOP"), +- 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems, +- &bytes_after, (gpointer) ¤t_desktop); +- err = gdk_error_trap_pop (); +- +- if (err != Success || result != Success) ++ if (GDK_IS_X11_DISPLAY (display)) + { +- return ret; +- } ++ Atom type; ++ gint format; ++ gulong nitems; ++ gulong bytes_after; ++ guint *current_desktop; ++ gint err, result; + - app = g_object_new (XED_TYPE_APP, - "application-id", "org.x.editor", - "flags", G_APPLICATION_HANDLES_COMMAND_LINE | G_APPLICATION_HANDLES_OPEN, ++ gdk_error_trap_push (); ++ result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (root_win), ++ gdk_x11_get_xatom_by_name_for_display (display, "_NET_CURRENT_DESKTOP"), ++ 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems, ++ &bytes_after, (gpointer) ¤t_desktop); ++ err = gdk_error_trap_pop (); ++ ++ if (err != Success || result != Success) ++ { ++ return ret; ++ } + +- if (type == XA_CARDINAL && format == 32 && nitems > 0) +- { +- ret = current_desktop[0]; ++ if (type == XA_CARDINAL && format == 32 && nitems > 0) ++ { ++ ret = current_desktop[0]; ++ } ++ ++ XFree (current_desktop); + } + +- XFree (current_desktop); + return ret; + #else + /* FIXME: on mac etc proably there are native APIs +@@ -723,24 +726,28 @@ xed_utils_get_window_workspace (GtkWindow *gtkwindow) + window = gtk_widget_get_window (GTK_WIDGET (gtkwindow)); + display = gdk_window_get_display (window); + +- gdk_error_trap_push (); +- result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), +- gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"), +- 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems, +- &bytes_after, (gpointer) &workspace); +- err = gdk_error_trap_pop (); +- +- if (err != Success || result != Success) ++ if (GDK_IS_X11_DISPLAY (display)) + { +- return ret; +- } ++ gdk_error_trap_push (); ++ result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window), ++ gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"), ++ 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems, ++ &bytes_after, (gpointer) &workspace); ++ err = gdk_error_trap_pop (); ++ ++ if (err != Success || result != Success) ++ { ++ return ret; ++ } + +- if (type == XA_CARDINAL && format == 32 && nitems > 0) +- { +- ret = workspace[0]; ++ if (type == XA_CARDINAL && format == 32 && nitems > 0) ++ { ++ ret = workspace[0]; ++ } ++ ++ XFree (workspace); + } + +- XFree (workspace); + return ret; + #else + /* FIXME: on mac etc proably there are native APIs +@@ -783,27 +790,30 @@ xed_utils_get_current_viewport (GdkScreen *screen, + root_win = gdk_screen_get_root_window (screen); + display = gdk_screen_get_display (screen); + +- gdk_error_trap_push (); +- result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (root_win), +- gdk_x11_get_xatom_by_name_for_display (display, "_NET_DESKTOP_VIEWPORT"), +- 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems, +- &bytes_after, (void*) &coordinates); +- err = gdk_error_trap_pop (); +- +- if (err != Success || result != Success) ++ if (GDK_IS_X11_DISPLAY (display)) + { +- return; +- } ++ gdk_error_trap_push (); ++ result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (root_win), ++ gdk_x11_get_xatom_by_name_for_display (display, "_NET_DESKTOP_VIEWPORT"), ++ 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems, ++ &bytes_after, (void*) &coordinates); ++ err = gdk_error_trap_pop (); ++ ++ if (err != Success || result != Success) ++ { ++ return; ++ } + +- if (type != XA_CARDINAL || format != 32 || nitems < 2) +- { ++ if (type != XA_CARDINAL || format != 32 || nitems < 2) ++ { ++ XFree (coordinates); ++ return; ++ } ++ ++ *x = coordinates[0]; ++ *y = coordinates[1]; + XFree (coordinates); +- return; + } +- +- *x = coordinates[0]; +- *y = coordinates[1]; +- XFree (coordinates); + #else + /* FIXME: on mac etc proably there are native APIs + * to get the current workspace etc */ diff --git a/xed.spec b/xed.spec index 5a7d5c7..01a8bc8 100644 --- a/xed.spec +++ b/xed.spec @@ -1,6 +1,6 @@ Name: xed Version: 1.2.2 -Release: 2%{?dist} +Release: 3%{?dist} Summary: X-Apps [Text] Editor (Cross-DE, backward-compatible, GTK3, traditional UI) License: GPLv2+ @@ -9,8 +9,8 @@ Source0: %{url}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz # Patch to recent upstream master. Patch0: %{url}/compare/%{version}...master.patch#/%{name}-%{version}_to_master.patch -Patch1: %{url}/pull/105.patch#/fix_wayland_segmentation_fault.patch -Patch2: %{url}/pull/106.patch#/fix_format_string_error.patch +Patch1: %{url}/pull/108.patch#/fix_wayland_segmentation_fault.patch +Patch2: %{url}/pull/107.patch#/fix_format_string_error.patch BuildRequires: autoconf BuildRequires: automake @@ -138,6 +138,9 @@ export PYTHON=%{__python3} %changelog +* Sun Apr 02 2017 Leigh Scott - 1.2.2-3 +- Redo patches with latest fixes + * Sat Apr 01 2017 Leigh Scott - 1.2.2-2 - Fix start up crash under wayland (rhbz #1438157) - Fix 'format not a string literal' compile error