projects
/
synfig.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Lots more changes which hopefully change nothing but the clarity.
[synfig.git]
/
synfig-studio
/
trunk
/
src
/
gtkmm
/
ipc.cpp
diff --git
a/synfig-studio/trunk/src/gtkmm/ipc.cpp
b/synfig-studio/trunk/src/gtkmm/ipc.cpp
index
3de0d6a
..
7b5cfbd
100644
(file)
--- a/
synfig-studio/trunk/src/gtkmm/ipc.cpp
+++ b/
synfig-studio/trunk/src/gtkmm/ipc.cpp
@@
-2,7
+2,7
@@
/*! \file ipc.cpp
** \brief Template File
**
/*! \file ipc.cpp
** \brief Template File
**
-** $Id
: ipc.cpp,v 1.6 2005/01/16 19:55:57 darco Exp
$
+** $Id$
**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
@@
-39,6
+39,10
@@
#include <sys/stat.h>
#endif
#include <sys/stat.h>
#endif
+#ifdef HAVE_SYS_ERRNO_H
+#include <sys/errno.h>
+#endif
+
#include <synfig/main.h>
#include "app.h"
#include <synfig/main.h>
#include "app.h"
@@
-101,7
+105,7
@@
pipe_listen_thread()
synfig::error("IPC(): Call to CreateNamedPipe failed. Ignore next error. GetLastError=%d",GetLastError());
return;
}
synfig::error("IPC(): Call to CreateNamedPipe failed. Ignore next error. GetLastError=%d",GetLastError());
return;
}
-
+
bool connected;
connected=ConnectNamedPipe(pipe_handle,NULL)?true:(GetLastError()==ERROR_PIPE_CONNECTED);
DWORD read_bytes;
bool connected;
connected=ConnectNamedPipe(pipe_handle,NULL)?true:(GetLastError()==ERROR_PIPE_CONNECTED);
DWORD read_bytes;
@@
-112,7
+116,7
@@
pipe_listen_thread()
if(connected)
do {
String data;
if(connected)
do {
String data;
- char c;
+ char c;
do
{
success= ReadFile(
do
{
success= ReadFile(
@@
-129,7
+133,7
@@
pipe_listen_thread()
cmd_queue.push_back(data);
cmd_dispatcher->emit();
} while(success && read_bytes);
cmd_queue.push_back(data);
cmd_dispatcher->emit();
} while(success && read_bytes);
-
+
CloseHandle(pipe_handle);
}
}
CloseHandle(pipe_handle);
}
}
@@
-157,34
+161,35
@@
IPC::IPC()
cmd_dispatcher=new Glib::Dispatcher;
cmd_dispatcher->connect(sigc::ptr_fun(empty_cmd_queue));
cmd_dispatcher=new Glib::Dispatcher;
cmd_dispatcher->connect(sigc::ptr_fun(empty_cmd_queue));
-
+
Glib::Thread::create(
sigc::ptr_fun(pipe_listen_thread),
false
);
Glib::Thread::create(
sigc::ptr_fun(pipe_listen_thread),
false
);
-
+
#else
#else
-
+
remove(fifo_path().c_str());
fd=-1;
remove(fifo_path().c_str());
fd=-1;
-
+
if(mkfifo(fifo_path().c_str(), S_IRWXU)!=0)
{
synfig::error("IPC(): mkfifo failed for "+fifo_path());
}
if(mkfifo(fifo_path().c_str(), S_IRWXU)!=0)
{
synfig::error("IPC(): mkfifo failed for "+fifo_path());
}
-
+
{
fd=open(fifo_path().c_str(),O_RDWR);
if(fd<0)
{
{
fd=open(fifo_path().c_str(),O_RDWR);
if(fd<0)
{
- synfig::error("IPC(): Failed to open fifo \"%s\". (errno=%d)",fifo_path().c_str(),errno);
+ synfig::error("IPC(): Failed to open fifo \"%s\". (errno=?)",fifo_path().c_str());
+ //synfig::error("IPC(): Failed to open fifo \"%s\". (errno=%d)",fifo_path().c_str(),::errno);
}
else
{
file=SmartFILE(fdopen(fd,"r"));
}
else
{
file=SmartFILE(fdopen(fd,"r"));
-
+
Glib::signal_io().connect(
sigc::mem_fun(this,&IPC::fifo_activity),
fd,
Glib::signal_io().connect(
sigc::mem_fun(this,&IPC::fifo_activity),
fd,
@@
-201,7
+206,7
@@
IPC::~IPC()
// fclose(file.get());
remove(fifo_path().c_str());
// fclose(file.get());
remove(fifo_path().c_str());
-
+
//if(fd>=0)
// close(fd);
}
//if(fd>=0)
// close(fd);
}
@@
-220,7
+225,7
@@
bool
IPC::fifo_activity(Glib::IOCondition cond)
{
synfig::info(__FILE__":%d: fifo activity",__LINE__);
IPC::fifo_activity(Glib::IOCondition cond)
{
synfig::info(__FILE__":%d: fifo activity",__LINE__);
-
+
if(cond&(Glib::IO_ERR|Glib::IO_HUP|Glib::IO_NVAL))
{
if(cond&(Glib::IO_ERR))
if(cond&(Glib::IO_ERR|Glib::IO_HUP|Glib::IO_NVAL))
{
if(cond&(Glib::IO_ERR))
@@
-243,7
+248,7
@@
IPC::fifo_activity(Glib::IOCondition cond)
command+=tmp;
} while(tmp!='\n');
}
command+=tmp;
} while(tmp!='\n');
}
-
+
process_command(command);
return true;
}
process_command(command);
return true;
}
@@
-253,13
+258,13
@@
IPC::process_command(const synfig::String& command_line)
{
if(command_line.empty())
return false;
{
if(command_line.empty())
return false;
-
+
char cmd=command_line[0];
char cmd=command_line[0];
-
+
String args(command_line.begin()+1,command_line.end());
while(!args.empty() && args[0]==' ') args.erase(args.begin());
while(!args.empty() && args[args.size()-1]=='\n' || args[args.size()-1]==' ') args.erase(args.end()-1);
String args(command_line.begin()+1,command_line.end());
while(!args.empty() && args[0]==' ') args.erase(args.begin());
while(!args.empty() && args[args.size()-1]=='\n' || args[args.size()-1]==' ') args.erase(args.end()-1);
-
+
switch(toupper(cmd))
{
case 'F': // Focus/Foreground
switch(toupper(cmd))
{
case 'F': // Focus/Foreground
@@
-281,7
+286,7
@@
IPC::process_command(const synfig::String& command_line)
synfig::warning("Received unknown command '%c' with arg '%s'",cmd,args.c_str());
break;
}
synfig::warning("Received unknown command '%c' with arg '%s'",cmd,args.c_str());
break;
}
-
+
return true;
}
return true;
}
@@
-298,28
+303,34
@@
IPC::make_connection()
NULL, // security attributes
OPEN_EXISTING, // creation disposition
FILE_ATTRIBUTE_NORMAL, // flags and attributes
NULL, // security attributes
OPEN_EXISTING, // creation disposition
FILE_ATTRIBUTE_NORMAL, // flags and attributes
- NULL // template file
+ NULL // template file
);
if(pipe_handle==INVALID_HANDLE_VALUE)
{
);
if(pipe_handle==INVALID_HANDLE_VALUE)
{
- synfig::warning("IPC::make_connection(): Unable to connect to previous instance. GetLastError=%d",GetLastError());
+ DWORD error = GetLastError();
+#ifndef _DEBUG
+ if( error != ERROR_FILE_NOT_FOUND )
+#endif
+ synfig::warning("IPC::make_connection(): Unable to connect to previous instance. GetLastError=%d",error);
}
int fd=_open_osfhandle(reinterpret_cast<long int>(pipe_handle),_O_APPEND|O_WRONLY);
#else
struct stat file_stat;
if(stat(fifo_path().c_str(),&file_stat)!=0)
return ret;
}
int fd=_open_osfhandle(reinterpret_cast<long int>(pipe_handle),_O_APPEND|O_WRONLY);
#else
struct stat file_stat;
if(stat(fifo_path().c_str(),&file_stat)!=0)
return ret;
-
+
if(!S_ISFIFO(file_stat.st_mode))
return ret;
if(!S_ISFIFO(file_stat.st_mode))
return ret;
-
+
int fd=open(fifo_path().c_str(),O_WRONLY|O_NONBLOCK);
#endif
int fd=open(fifo_path().c_str(),O_WRONLY|O_NONBLOCK);
#endif
-
+
if(fd>=0)
ret=SmartFILE(fdopen(fd,"w"));
if(fd>=0)
ret=SmartFILE(fdopen(fd,"w"));
+#ifdef _DEBUG
synfig::info("uplink fd=%d",fd);
synfig::info("uplink fd=%d",fd);
+#endif
return ret;
}
return ret;
}