Revision: 5656
http://geany.svn.sourceforge.net/geany/?rev=5656&view=rev
Author: ntrel
Date: 2011-03-30 13:09:27 +0000 (Wed, 30 Mar 2011)
Log Message:
-----------
Remove unnecessary use of DOC_VALID() macro.
Modified Paths:
--------------
trunk/plugins/splitwindow.c
Modified: trunk/plugins/splitwindow.c
===================================================================
--- trunk/plugins/splitwindow.c 2011-03-30 12:47:26 UTC (rev 5655)
+++ trunk/plugins/splitwindow.c 2011-03-30 13:09:27 UTC (rev 5656)
@@ -447,7 +447,7 @@
return FALSE;
doc = document_get_current();
- if (DOC_VALID(doc))
+ if (doc)
set_editor(&edit_window, doc->editor);
else
on_unsplit(NULL, NULL);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5653
http://geany.svn.sourceforge.net/geany/?rev=5653&view=rev
Author: ntrel
Date: 2011-03-30 12:20:18 +0000 (Wed, 30 Mar 2011)
Log Message:
-----------
Use STYLE_MAX instead of 127 for editor_set_font(). This fixes a
crash in the Split Window plugin when changing filetype (patch by
Matthew Brush, thanks; fixes #3255968).
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/editor.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2011-03-29 23:52:03 UTC (rev 5652)
+++ trunk/ChangeLog 2011-03-30 12:20:18 UTC (rev 5653)
@@ -1,3 +1,11 @@
+2011-03-30 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
+
+ * src/editor.c:
+ Use STYLE_MAX instead of 127 for editor_set_font(). This fixes a
+ crash in the Split Window plugin when changing filetype (patch by
+ Matthew Brush, thanks; fixes #3255968).
+
+
2011-03-30 Colomban Wendling <colomban(at)geany(dot)org>
* src/plugindata.h, src/pluginprivate.h, src/plugins.c,
Modified: trunk/src/editor.c
===================================================================
--- trunk/src/editor.c 2011-03-29 23:52:03 UTC (rev 5652)
+++ trunk/src/editor.c 2011-03-30 12:20:18 UTC (rev 5653)
@@ -4478,7 +4478,7 @@
font_name = g_strdup_printf("!%s", pango_font_description_get_family(pfd));
pango_font_description_free(pfd);
- for (style = 0; style <= 127; style++)
+ for (style = 0; style <= STYLE_MAX; style++)
sci_set_font(editor->sci, style, font_name, size);
/* line number and braces */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5652
http://geany.svn.sourceforge.net/geany/?rev=5652&view=rev
Author: colombanw
Date: 2011-03-29 23:52:03 +0000 (Tue, 29 Mar 2011)
Log Message:
-----------
Fix a few Doxygen warnings
Modified Paths:
--------------
trunk/ChangeLog
trunk/doc/pluginsymbols.c
trunk/src/sciwrappers.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2011-03-29 23:20:29 UTC (rev 5651)
+++ trunk/ChangeLog 2011-03-29 23:52:03 UTC (rev 5652)
@@ -8,6 +8,8 @@
removed when unloading the plugin, preventing possible crashes.
* plugins/splitwindow.c:
Use new plugin_idle_add(), preventing an unlikely crash.
+ * doc/pluginsymbols.c, src/sciwrappers.c:
+ Fix a few Doxygen warnings.
2011-03-29 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/doc/pluginsymbols.c
===================================================================
--- trunk/doc/pluginsymbols.c 2011-03-29 23:20:29 UTC (rev 5651)
+++ trunk/doc/pluginsymbols.c 2011-03-29 23:52:03 UTC (rev 5652)
@@ -43,7 +43,7 @@
* @param info The data struct which should be initialized by this function. */
void plugin_set_info(PluginInfo *info);
-/** @deprecated Use @ref geany_plugin->info instead.
+/** @deprecated Use @ref GeanyPlugin.info instead.
* Basic information about a plugin, which is set in plugin_set_info(). */
const PluginInfo *plugin_info;
Modified: trunk/src/sciwrappers.c
===================================================================
--- trunk/src/sciwrappers.c 2011-03-29 23:20:29 UTC (rev 5651)
+++ trunk/src/sciwrappers.c 2011-03-29 23:52:03 UTC (rev 5652)
@@ -357,7 +357,8 @@
/** Gets the line number from @a position.
* @param sci Scintilla widget.
- * @param position Position. */
+ * @param position Position.
+ * @return The line. */
gint sci_get_line_from_position(ScintillaObject *sci, gint position)
{
return SSM(sci, SCI_LINEFROMPOSITION, position, 0);
@@ -366,7 +367,8 @@
/** Gets the column number relative to the start of the line that @a position is on.
* @param sci Scintilla widget.
- * @param position Position. */
+ * @param position Position.
+ * @return The column. */
gint sci_get_col_from_position(ScintillaObject *sci, gint position)
{
return SSM(sci, SCI_GETCOLUMN, position, 0);
@@ -419,7 +421,8 @@
/** Gets the total number of lines.
- * @param sci Scintilla widget. */
+ * @param sci Scintilla widget.
+ * @return The line count. */
gint sci_get_line_count(ScintillaObject *sci)
{
return SSM(sci, SCI_GETLINECOUNT, 0, 0);
@@ -451,8 +454,9 @@
/** Gets the position at the end of a line
- * @param sci Scintilla widget
- * @param line Line */
+ * @param sci Scintilla widget.
+ * @param line Line.
+ * @return The position at the end of the line. */
gint sci_get_line_end_position(ScintillaObject *sci, gint line)
{
return SSM(sci, SCI_GETLINEENDPOSITION, line, 0);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5651
http://geany.svn.sourceforge.net/geany/?rev=5651&view=rev
Author: colombanw
Date: 2011-03-29 23:20:29 +0000 (Tue, 29 Mar 2011)
Log Message:
-----------
Use new plugin_idle_add(), preventing an unlikely crash
Modified Paths:
--------------
trunk/ChangeLog
trunk/plugins/splitwindow.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2011-03-29 23:20:14 UTC (rev 5650)
+++ trunk/ChangeLog 2011-03-29 23:20:29 UTC (rev 5651)
@@ -6,6 +6,8 @@
plugin_timeout_add_seconds() to the plugin API. These are
convenience wrappers to ensure the added timeouts are properly
removed when unloading the plugin, preventing possible crashes.
+ * plugins/splitwindow.c:
+ Use new plugin_idle_add(), preventing an unlikely crash.
2011-03-29 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/plugins/splitwindow.c
===================================================================
--- trunk/plugins/splitwindow.c 2011-03-29 23:20:14 UTC (rev 5650)
+++ trunk/plugins/splitwindow.c 2011-03-29 23:20:29 UTC (rev 5651)
@@ -461,7 +461,7 @@
if (doc->editor == edit_window.editor)
{
/* select current or unsplit in IDLE time, so the tab has changed */
- g_idle_add(do_select_current, NULL);
+ plugin_idle_add(geany_plugin, do_select_current, NULL);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5650
http://geany.svn.sourceforge.net/geany/?rev=5650&view=rev
Author: colombanw
Date: 2011-03-29 23:20:14 +0000 (Tue, 29 Mar 2011)
Log Message:
-----------
Add plugin_{idle_add,timeout_add,timeout_add_seconds}() to the plugin API
These functions does the same as the corresponding GLib functions but
makes sure that the added GSource will be removed when the plugin is
unloaded, preventing possible crashes.
These are only convenience functions for the plugin author not to have to
care about the case the plugin gets unloaded, he can still manually
manage hes GSources if he wants to.
Modified Paths:
--------------
trunk/ChangeLog
trunk/plugins/geanyfunctions.h
trunk/src/plugindata.h
trunk/src/pluginprivate.h
trunk/src/plugins.c
trunk/src/pluginutils.c
trunk/src/pluginutils.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2011-03-29 18:06:26 UTC (rev 5649)
+++ trunk/ChangeLog 2011-03-29 23:20:14 UTC (rev 5650)
@@ -1,3 +1,13 @@
+2011-03-30 Colomban Wendling <colomban(at)geany(dot)org>
+
+ * src/plugindata.h, src/pluginprivate.h, src/plugins.c,
+ src/pluginutils.c, src/pluginutils.h plugins/geanyfunctions.h:
+ Add plugin_idle_add(), plugin_timeout_add() and
+ plugin_timeout_add_seconds() to the plugin API. These are
+ convenience wrappers to ensure the added timeouts are properly
+ removed when unloading the plugin, preventing possible crashes.
+
+
2011-03-29 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* doc/geany.txt, doc/geany.html:
Modified: trunk/plugins/geanyfunctions.h
===================================================================
--- trunk/plugins/geanyfunctions.h 2011-03-29 18:06:26 UTC (rev 5649)
+++ trunk/plugins/geanyfunctions.h 2011-03-29 23:20:14 UTC (rev 5650)
@@ -26,6 +26,12 @@
geany_functions->p_plugin->plugin_set_key_group
#define plugin_show_configure \
geany_functions->p_plugin->plugin_show_configure
+#define plugin_timeout_add \
+ geany_functions->p_plugin->plugin_timeout_add
+#define plugin_timeout_add_seconds \
+ geany_functions->p_plugin->plugin_timeout_add_seconds
+#define plugin_idle_add \
+ geany_functions->p_plugin->plugin_idle_add
#define document_new_file \
geany_functions->p_document->document_new_file
#define document_get_current \
Modified: trunk/src/plugindata.h
===================================================================
--- trunk/src/plugindata.h 2011-03-29 18:06:26 UTC (rev 5649)
+++ trunk/src/plugindata.h 2011-03-29 23:20:14 UTC (rev 5650)
@@ -54,7 +54,7 @@
* @warning You should not test for values below 200 as previously
* @c GEANY_API_VERSION was defined as an enum value, not a macro.
*/
-#define GEANY_API_VERSION 204
+#define GEANY_API_VERSION 205
/** The Application Binary Interface (ABI) version, incremented whenever
* existing fields in the plugin data types have to be changed or reordered.
@@ -645,6 +645,11 @@
struct GeanyKeyGroup* (*plugin_set_key_group)(GeanyPlugin *plugin,
const gchar *section_name, gsize count, _GeanyKeyGroupCallback callback);
void (*plugin_show_configure)(GeanyPlugin *plugin);
+ guint (*plugin_timeout_add) (GeanyPlugin *plugin, guint interval, GSourceFunc function,
+ gpointer data);
+ guint (*plugin_timeout_add_seconds) (GeanyPlugin *plugin, guint interval,
+ GSourceFunc function, gpointer data);
+ guint (*plugin_idle_add) (GeanyPlugin *plugin, GSourceFunc function, gpointer data);
}
PluginFuncs;
Modified: trunk/src/pluginprivate.h
===================================================================
--- trunk/src/pluginprivate.h 2011-03-29 18:06:26 UTC (rev 5649)
+++ trunk/src/pluginprivate.h 2011-03-29 23:20:14 UTC (rev 5650)
@@ -57,6 +57,7 @@
GeanyKeyGroup *key_group;
GeanyAutoSeparator toolbar_separator;
GArray *signal_ids; /* SignalConnection's to disconnect when unloading */
+ GList *sources; /* GSources to destroy when unloading */
}
GeanyPluginPrivate;
Modified: trunk/src/plugins.c
===================================================================
--- trunk/src/plugins.c 2011-03-29 18:06:26 UTC (rev 5649)
+++ trunk/src/plugins.c 2011-03-29 23:20:14 UTC (rev 5650)
@@ -85,7 +85,10 @@
&plugin_module_make_resident,
&plugin_signal_connect,
&plugin_set_key_group,
- &plugin_show_configure
+ &plugin_show_configure,
+ &plugin_timeout_add,
+ &plugin_timeout_add_seconds,
+ &plugin_idle_add
};
static DocumentFuncs doc_funcs = {
@@ -760,6 +763,22 @@
}
+static void remove_sources(Plugin *plugin)
+{
+ GList *item;
+
+ item = plugin->sources;
+ while (item != NULL)
+ {
+ GList *next = item->next; /* cache the next pointer because current item will be freed */
+
+ g_source_destroy(item->data);
+ item = next;
+ }
+ /* don't free the list here, it is allocated inside each source's data */
+}
+
+
static gboolean is_active_plugin(Plugin *plugin)
{
return (g_list_find(active_plugin_list, plugin) != NULL);
@@ -776,6 +795,7 @@
plugin->cleanup();
remove_callbacks(plugin);
+ remove_sources(plugin);
if (plugin->key_group)
keybindings_free_group(plugin->key_group);
Modified: trunk/src/pluginutils.c
===================================================================
--- trunk/src/pluginutils.c 2011-03-29 18:06:26 UTC (rev 5649)
+++ trunk/src/pluginutils.c 2011-03-29 23:20:14 UTC (rev 5650)
@@ -131,6 +131,143 @@
}
+typedef struct PluginSourceData
+{
+ Plugin *plugin;
+ GList list_link; /* element of plugin->sources cointaining this GSource */
+ GSourceFunc function;
+ gpointer user_data;
+} PluginSourceData;
+
+
+/* use GSlice if available */
+#if GLIB_CHECK_VERSION(2,10,0)
+# define PSD_ALLOC() (g_slice_alloc(sizeof(PluginSourceData)))
+# define PSD_FREE(psd) (g_slice_free1(sizeof(PluginSourceData), (psd)))
+#else
+# define PSD_ALLOC() (g_malloc(sizeof(PluginSourceData)))
+# define PSD_FREE(psd) (g_free(psd))
+#endif
+
+
+/* prepend psd->list_link to psd->plugin->sources */
+static void psd_register(PluginSourceData *psd, GSource *source)
+{
+ psd->list_link.data = source;
+ psd->list_link.prev = NULL;
+ psd->list_link.next = psd->plugin->sources;
+ if (psd->list_link.next)
+ psd->list_link.next->prev = &psd->list_link;
+ psd->plugin->sources = &psd->list_link;
+}
+
+
+/* removes psd->list_link from psd->plugin->sources */
+static void psd_unregister(PluginSourceData *psd)
+{
+ if (psd->list_link.next)
+ psd->list_link.next->prev = psd->list_link.prev;
+ if (psd->list_link.prev)
+ psd->list_link.prev->next = psd->list_link.next;
+ else /* we were the first of the list, update the plugin->sources pointer */
+ psd->plugin->sources = psd->list_link.next;
+}
+
+
+static void on_plugin_source_destroy(gpointer data)
+{
+ PluginSourceData *psd = data;
+
+ psd_unregister(psd);
+ PSD_FREE(psd);
+}
+
+
+static gboolean on_plugin_source_callback(gpointer data)
+{
+ PluginSourceData *psd = data;
+
+ return psd->function(psd->user_data);
+}
+
+
+/* adds the given source to the default GMainContext and to the list of sources to remove at plugin
+ * unloading time */
+static guint plugin_source_add(GeanyPlugin *plugin, GSource *source, GSourceFunc func, gpointer data)
+{
+ guint id;
+ PluginSourceData *psd = PSD_ALLOC();
+
+ psd->plugin = plugin->priv;
+ psd->function = func;
+ psd->user_data = data;
+
+ g_source_set_callback(source, on_plugin_source_callback, psd, on_plugin_source_destroy);
+ psd_register(psd, source);
+ id = g_source_attach(source, NULL);
+ g_source_unref(source);
+
+ return id;
+}
+
+
+/** Adds a GLib main loop timeout callback that will be removed when unloading the plugin,
+ * preventing it to run after the plugin has been unloaded (which may lead to a segfault).
+ *
+ * @param plugin Must be @ref geany_plugin.
+ * @param interval The time between calls to the function, in milliseconds.
+ * @param function The function to call after the given timeout.
+ * @param data The user data passed to the function.
+ * @return the ID of the event source (you generally won't need it, or better use g_timeout_add()
+ * directly if you want to manage this event source manually).
+ *
+ * @see g_timeout_add()
+ * @since 0.21, plugin API 205.
+ */
+guint plugin_timeout_add(GeanyPlugin *plugin, guint interval, GSourceFunc function, gpointer data)
+{
+ return plugin_source_add(plugin, g_timeout_source_new(interval), function, data);
+}
+
+
+/** Adds a GLib main loop timeout callback that will be removed when unloading the plugin,
+ * preventing it to run after the plugin has been unloaded (which may lead to a segfault).
+ *
+ * @param plugin Must be @ref geany_plugin.
+ * @param interval The time between calls to the function, in seconds.
+ * @param function The function to call after the given timeout.
+ * @param data The user data passed to the function.
+ * @return the ID of the event source (you generally won't need it, or better use
+ * g_timeout_add_seconds() directly if you want to manage this event source manually).
+ *
+ * @see g_timeout_add_seconds()
+ * @since 0.21, plugin API 205.
+ */
+guint plugin_timeout_add_seconds(GeanyPlugin *plugin, guint interval, GSourceFunc function,
+ gpointer data)
+{
+ return plugin_source_add(plugin, g_timeout_source_new_seconds(interval), function, data);
+}
+
+
+/** Adds a GLib main loop IDLE callback that will be removed when unloading the plugin, preventing
+ * it to run after the plugin has been unloaded (which may lead to a segfault).
+ *
+ * @param plugin Must be @ref geany_plugin.
+ * @param function The function to call in IDLE time.
+ * @param data The user data passed to the function.
+ * @return the ID of the event source (you generally won't need it, or better use g_idle_add()
+ * directly if you want to manage this event source manually).
+ *
+ * @see g_idle_add()
+ * @since 0.21, plugin API 205.
+ */
+guint plugin_idle_add(GeanyPlugin *plugin, GSourceFunc function, gpointer data)
+{
+ return plugin_source_add(plugin, g_idle_source_new(), function, data);
+}
+
+
/** Sets up or resizes a keybinding group for the plugin.
* You should then call keybindings_set_item() for each keybinding in the group.
* @param plugin Must be @ref geany_plugin.
Modified: trunk/src/pluginutils.h
===================================================================
--- trunk/src/pluginutils.h 2011-03-29 18:06:26 UTC (rev 5649)
+++ trunk/src/pluginutils.h 2011-03-29 23:20:14 UTC (rev 5650)
@@ -43,6 +43,14 @@
GObject *object, const gchar *signal_name, gboolean after,
GCallback callback, gpointer user_data);
+guint plugin_timeout_add(struct GeanyPlugin *plugin, guint interval, GSourceFunc function,
+ gpointer data);
+
+guint plugin_timeout_add_seconds(struct GeanyPlugin *plugin, guint interval, GSourceFunc function,
+ gpointer data);
+
+guint plugin_idle_add(struct GeanyPlugin *plugin, GSourceFunc function, gpointer data);
+
struct GeanyKeyGroup *plugin_set_key_group(struct GeanyPlugin *plugin,
const gchar *section_name, gsize count, GeanyKeyGroupCallback callback);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5648
http://geany.svn.sourceforge.net/geany/?rev=5648&view=rev
Author: ntrel
Date: 2011-03-29 17:55:26 +0000 (Tue, 29 Mar 2011)
Log Message:
-----------
Fix undocumented parameter.
Modified Paths:
--------------
trunk/src/sciwrappers.c
Modified: trunk/src/sciwrappers.c
===================================================================
--- trunk/src/sciwrappers.c 2011-03-29 16:48:37 UTC (rev 5647)
+++ trunk/src/sciwrappers.c 2011-03-29 17:55:26 UTC (rev 5648)
@@ -826,10 +826,11 @@
}
-/** Sets the font for a particular style
- * @param style The style
- * @param font The font name
- * @param size The font size */
+/** Sets the font for a particular style.
+ * @param sci Scintilla widget.
+ * @param style The style.
+ * @param font The font name.
+ * @param size The font size. */
void sci_set_font(ScintillaObject *sci, gint style, const gchar *font, gint size)
{
SSM(sci, SCI_STYLESETFONT, style, (sptr_t) font);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.