[gedit] Warn against async methods in doc streams
- From: Paolo Borelli <pborelli src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gedit] Warn against async methods in doc streams
- Date: Mon, 8 Feb 2010 21:41:48 +0000 (UTC)
commit ef8336416023521a09112d5cb22432278cac3c19
Author: Paolo Borelli <pborelli gnome org>
Date: Mon Feb 8 22:35:25 2010 +0100
Warn against async methods in doc streams
Add scary comments about not using async methods on document streams since
they are not only not useful (the buffer is in memory), but also
dangerous since buffer should not be modified from different threads.
gedit/gedit-document-input-stream.c | 9 +++++++--
gedit/gedit-document-output-stream.c | 8 ++++++++
2 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/gedit/gedit-document-input-stream.c b/gedit/gedit-document-input-stream.c
index 31edf19..28e4a72 100644
--- a/gedit/gedit-document-input-stream.c
+++ b/gedit/gedit-document-input-stream.c
@@ -20,16 +20,21 @@
* Boston, MA 02110-1301 USA
*/
-
#include "config.h"
#include <glib.h>
#include <gio/gio.h>
#include <string.h>
-
#include "gedit-document-input-stream.h"
#include "gedit-enum-types.h"
+/* NOTE: never use async methods on this stream, the stream is just
+ * a wrapper around GtkTextBuffer api so that we can use GIO Stream
+ * methods, but the undelying code operates on a GtkTextBuffer, so
+ * there is no I/O involved and should be accessed only by the main
+ * thread */
+
+
G_DEFINE_TYPE (GeditDocumentInputStream, gedit_document_input_stream, G_TYPE_INPUT_STREAM);
struct _GeditDocumentInputStreamPrivate
diff --git a/gedit/gedit-document-output-stream.c b/gedit/gedit-document-output-stream.c
index d48ce61..e6055a6 100644
--- a/gedit/gedit-document-output-stream.c
+++ b/gedit/gedit-document-output-stream.c
@@ -20,9 +20,17 @@
* Boston, MA 02110-1301 USA
*/
+#include "config.h"
+#include <glib.h>
+#include <gio/gio.h>
#include "gedit-document-output-stream.h"
+/* NOTE: never use async methods on this stream, the stream is just
+ * a wrapper around GtkTextBuffer api so that we can use GIO Stream
+ * methods, but the undelying code operates on a GtkTextBuffer, so
+ * there is no I/O involved and should be accessed only by the main
+ * thread */
#define GEDIT_DOCUMENT_OUTPUT_STREAM_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GEDIT_TYPE_DOCUMENT_OUTPUT_STREAM, GeditDocumentOutputStreamPrivate))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]