"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "gb.gtk/src/watcher.cpp" between
gambas-3.16.2.tar.bz2 and gambas-3.16.3.tar.bz2

About: Gambas is a graphical development environment based on a Basic interpreter with object extensions, a bit like Visual Basic (requires Qt).

watcher.cpp  (gambas-3.16.2.tar.bz2):watcher.cpp  (gambas-3.16.3.tar.bz2)
skipping to change at line 28 skipping to change at line 28
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. MA 02110-1301, USA.
***************************************************************************/ ***************************************************************************/
#include "main.h" #include "main.h"
#include "gambas.h" #include "gambas.h"
#include "watcher.h" #include "watcher.h"
//#define DEBUG_ME 1
static WATCH **watch = NULL; static WATCH **watch = NULL;
static gboolean watch_adaptor(GIOChannel *source, GIOCondition condition, gpoint er param) static gboolean watch_adaptor(GIOChannel *source, GIOCondition condition, gpoint er param)
{ {
WATCH *data = (WATCH *)param; WATCH *data = (WATCH *)param;
//fprintf(stderr, "watch_adaptor: %p: condition = %d, data = %p\n", sourc #if DEBUG_ME
e, (int)condition, (void *)param); fprintf(stderr, "watch_adaptor: %p: condition = %d, data = %p\n", source,
(int)condition, (void *)param);
#endif
if (!data) return true; if (!data) return true;
switch (condition) if (condition & G_IO_IN)
{ (*data->callback_read)(data->fd, GB_WATCH_READ, data->param_read)
case G_IO_IN: ;
(*data->callback_read)(data->fd, GB_WATCH_READ, data->par else if (condition & G_IO_OUT)
am_read); break; (*data->callback_write)(data->fd, GB_WATCH_WRITE, data->param_wri
case G_IO_OUT: te);
(*data->callback_write)(data->fd, GB_WATCH_WRITE, data->p
aram_write); break;
default: break;
}
return true; return true;
} }
void CWatcher::init() void CWatcher::init()
{ {
GB.NewArray(POINTER(&watch), sizeof(WATCH *), 0); GB.NewArray(POINTER(&watch), sizeof(WATCH *), 0);
} }
void CWatcher::exit() void CWatcher::exit()
skipping to change at line 105 skipping to change at line 105
GB.Alloc(POINTER(pwatch), sizeof(WATCH)); GB.Alloc(POINTER(pwatch), sizeof(WATCH));
data = *pwatch; data = *pwatch;
data->fd = fd; data->fd = fd;
data->channel_read = data->channel_write = 0; data->channel_read = data->channel_write = 0;
data->callback_read = data->callback_write = 0; data->callback_read = data->callback_write = 0;
} }
if (data->callback_read && (type == GB_WATCH_NONE || type == GB_WATCH_REA D)) if (data->callback_read && (type == GB_WATCH_NONE || type == GB_WATCH_REA D))
{ {
//fprintf(stderr, "remove watch on fd %d for read (%p)\n", data-> #if DEBUG_ME
fd, data->channel_read); fprintf(stderr, "remove watch on fd %d for read (%p)\n", data->fd
, data->channel_read);
#endif
g_source_remove(data->id_read); g_source_remove(data->id_read);
g_io_channel_unref(data->channel_read); g_io_channel_unref(data->channel_read);
data->callback_read = 0; data->callback_read = 0;
data->channel_read = 0; data->channel_read = 0;
} }
if (data->callback_write && (type == GB_WATCH_NONE || type == GB_WATCH_WR ITE)) if (data->callback_write && (type == GB_WATCH_NONE || type == GB_WATCH_WR ITE))
{ {
//fprintf(stderr, "remove watch on fd %d for read (%p)\n", data-> #if DEBUG_ME
fd, data->channel_write); fprintf(stderr, "remove watch on fd %d for read (%p)\n", data->fd
, data->channel_write);
#endif
g_source_remove(data->id_write); g_source_remove(data->id_write);
g_io_channel_unref(data->channel_write); g_io_channel_unref(data->channel_write);
data->callback_write = 0; data->callback_write = 0;
data->channel_write = 0; data->channel_write = 0;
} }
if (callback) if (callback)
{ {
if (type == GB_WATCH_READ) if (type == GB_WATCH_READ)
{ {
data->callback_read = (WATCH_CALLBACK)callback; data->callback_read = (WATCH_CALLBACK)callback;
data->param_read = param; data->param_read = param;
data->channel_read = g_io_channel_unix_new(fd); data->channel_read = g_io_channel_unix_new(fd);
g_io_channel_set_encoding(data->channel_read, NULL, NULL) ; g_io_channel_set_encoding(data->channel_read, NULL, NULL) ;
data->id_read = g_io_add_watch_full(data->channel_read, G g_io_channel_set_buffered(data->channel_read, FALSE);
_PRIORITY_LOW, G_IO_IN, watch_adaptor, (void*)data, NULL); data->id_read = g_io_add_watch_full(data->channel_read, G
//fprintf(stderr, "add watch on fd %d for read (%p)\n", f _PRIORITY_DEFAULT, G_IO_IN, watch_adaptor, (void*)data, NULL);
d, data->channel_read); #if DEBUG_ME
fprintf(stderr, "add watch on fd %d for read (%p)\n", fd,
data->channel_read);
#endif
} }
else if (type == GB_WATCH_WRITE) else if (type == GB_WATCH_WRITE)
{ {
data->callback_write = (WATCH_CALLBACK)callback; data->callback_write = (WATCH_CALLBACK)callback;
data->param_write = param; data->param_write = param;
data->channel_write = g_io_channel_unix_new(fd); data->channel_write = g_io_channel_unix_new(fd);
g_io_channel_set_encoding(data->channel_write, NULL, NULL ); g_io_channel_set_encoding(data->channel_write, NULL, NULL );
data->id_write = g_io_add_watch_full(data->channel_write, g_io_channel_set_buffered(data->channel_write, FALSE);
G_PRIORITY_LOW, G_IO_OUT, watch_adaptor, (void*)data, NULL); data->id_write = g_io_add_watch_full(data->channel_write,
//fprintf(stderr, "add watch on fd %d for write (%p)\n", G_PRIORITY_DEFAULT, G_IO_OUT, watch_adaptor, (void*)data, NULL);
fd, data->channel_write); #if DEBUG_ME
fprintf(stderr, "add watch on fd %d for write (%p)\n", fd
, data->channel_write);
#endif
} }
} }
if (!data->callback_read && !data->callback_write) if (!data->callback_read && !data->callback_write)
{ {
GB.Free(POINTER(&data)); GB.Free(POINTER(&data));
GB.Remove(&watch, i, 1); GB.Remove(&watch, i, 1);
MAIN_check_quit(); MAIN_check_quit();
} }
} }
 End of changes. 7 change blocks. 
24 lines changed or deleted 34 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)