Skip to content

Commit

Permalink
Remove documents_array global from plugin API
Browse files Browse the repository at this point in the history
The global was never accessible to plugins on Windows and hasn't been
accessible to plugins on Linux and others since the linkage-cleanup
changes.

Move documentation from the global variable to the GeanyData member
of the same name.

Closes #964
  • Loading branch information
codebrainz committed Mar 14, 2016
1 parent 24f9198 commit 76ede69
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
18 changes: 0 additions & 18 deletions src/document.c
Expand Up @@ -86,24 +86,6 @@


GeanyFilePrefs file_prefs;


/** Dynamic array of GeanyDocument pointers.
* Once a pointer is added to this, it is never freed. This means the same document pointer
* can represent a different document later on, or it may have been closed and become invalid.
* For this reason, you should use document_find_by_id() instead of storing
* document pointers over time if there is a chance the user can close the
* document.
*
* @warning You must check @c GeanyDocument::is_valid when iterating over this array.
* This is done automatically if you use the foreach_document() macro.
*
* @note
* Never assume that the order of document pointers is the same as the order of notebook tabs.
* One reason is that notebook tabs can be reordered.
* Use @c document_get_from_page() to lookup a document from a notebook tab number.
*
* @see documents. */
GPtrArray *documents_array = NULL;


Expand Down
3 changes: 1 addition & 2 deletions src/document.h
Expand Up @@ -118,8 +118,6 @@ typedef struct GeanyDocument
}
GeanyDocument;

extern GPtrArray *documents_array;

/** Wraps @ref documents_array so it can be used with C array syntax.
* @warning Always check the returned document is valid (@c doc->is_valid).
*
Expand Down Expand Up @@ -231,6 +229,7 @@ GeanyDocument *document_find_by_id(guint id);
#endif

extern GeanyFilePrefs file_prefs;
extern GPtrArray *documents_array;


/* These functions will replace the older functions. For now they have a documents_ prefix. */
Expand Down
18 changes: 17 additions & 1 deletion src/plugindata.h
Expand Up @@ -171,7 +171,23 @@ typedef struct GeanyData
{
struct GeanyApp *app; /**< Geany application data fields */
struct GeanyMainWidgets *main_widgets; /**< Important widgets in the main window */
GPtrArray *documents_array; /**< See document.h#documents_array. @elementtype{GeanyDocument} */
/** Dynamic array of GeanyDocument pointers.
* Once a pointer is added to this, it is never freed. This means the same document pointer
* can represent a different document later on, or it may have been closed and become invalid.
* For this reason, you should use document_find_by_id() instead of storing
* document pointers over time if there is a chance the user can close the
* document.
*
* @warning You must check @c GeanyDocument::is_valid when iterating over this array.
* This is done automatically if you use the foreach_document() macro.
*
* @note
* Never assume that the order of document pointers is the same as the order of notebook tabs.
* One reason is that notebook tabs can be reordered.
* Use @c document_get_from_page() to lookup a document from a notebook tab number.
*
* @see documents. */
GPtrArray *documents_array;
GPtrArray *filetypes_array; /**< Dynamic array of GeanyFiletype pointers. @elementtype{GeanyFiletype} */
struct GeanyPrefs *prefs; /**< General settings */
struct GeanyInterfacePrefs *interface_prefs; /**< Interface settings */
Expand Down

0 comments on commit 76ede69

Please sign in to comment.