kprocess::block & vim -g

Oswald Buddenhagen ossi at kde.org
Sat Feb 22 15:44:10 GMT 2003


On Sat, Feb 22, 2003 at 02:26:23AM +0100, Mickael Marchand wrote:
> > > I just noticed that kprocess->start(KProcess::Block) no longer returns
> > > when starting 'vim -g' inside it. That used to work in 3.1.x
> >
> > which additional options (communication mode, pty settings) were used?
> > is it some code in cvs?
> yes, the current vimpart in KEG-1
> (vimwidget.cpp, look at the constructor)
> 
ok, i had a look. everything works as expected.
passing any communication options is simply inappropriate in your case.
i don't think that kprocess behaved differently any time not so far away ...

btw, you should not use dynamic allocations where local variables can be
used. additionally, you probably should do a mem leak audit.

another thing: are you sure that both the -c and --cmd commands are
needed?

greetings

-- 
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Chaos, panic, and disorder - my work here is done.
-------------- next part --------------
? vimpart.diff
Index: vimwidget.cpp
===================================================================
RCS file: /home/kde/kdeextragear-1/vimpart/src/vimwidget.cpp,v
retrieving revision 1.15
diff -u -r1.15 vimwidget.cpp
--- vimwidget.cpp	22 Feb 2003 02:57:50 -0000	1.15
+++ vimwidget.cpp	22 Feb 2003 15:29:33 -0000
@@ -44,7 +44,6 @@
 	dcopcmd.setAutoDelete(true);
 	_dying = false;
   _vimReady = false;
-  _vimProcess = 0L;
   hideTool=true;
   hideMenu=true;
 	usedcop=true;
@@ -59,21 +58,19 @@
     connect( kwm, SIGNAL(windowAdded(WId)), this, SLOT(embedVimWid(WId)) );
     kwm->doNotManage(_serverName);
 
-    _vimProcess = new KProcess();
-
     QString n = ":set titlestring=";
     n+=_serverName;
 
     QString kvimscript = locate("data", "vimpart/kvim.vim");
     kdDebug() << "kvimscript = " << kvimscript << endl;
 
-    (*_vimProcess) << _vimExecutable << "-g" << "--cmd" << n << "--servername" << _serverName << "-c" << "source " + kvimscript;
+    KProcess vimProcess;
+    vimProcess << _vimExecutable << "-g" << "--cmd" << n << "--servername" << _serverName << "-c" << "source " + kvimscript;
     if (hideMenu)
-      (*_vimProcess) << "--cmd" << ":set guioptions-=m" << "-c" << ":set guioptions-=m";
+      vimProcess << "--cmd" << ":set guioptions-=m" << "-c" << ":set guioptions-=m";
     if (hideTool)
-      (*_vimProcess) << "--cmd" << ":set guioptions-=T" << "-c" << ":set guioptions-=T";
-    _vimProcess->start(KProcess::NotifyOnExit, KProcess::AllOutput);
-		sleep(1); //remove ME #FIXME
+      vimProcess << "--cmd" << ":set guioptions-=T" << "-c" << ":set guioptions-=T";
+    vimProcess.start(KProcess::Block);
   }
 }
 
@@ -156,14 +153,10 @@
 
   // XXX Fix for QXEmbed: XDestroyEvent doesn't seem to be generated,
   // so I generate it manually
-  XDestroyWindowEvent * dwe = new XDestroyWindowEvent;
-  dwe->type = DestroyNotify;
-  dwe->window = embeddedWinId();
-
-  x11Event( (XEvent *) dwe );
-
-  // safe ?
-  delete dwe;
+  XDestroyWindowEvent dwe;
+  dwe.type = DestroyNotify;
+  dwe.window = embeddedWinId();
+  x11Event( (XEvent *) &dwe );
 }
 
 VimWidget::~VimWidget()
Index: vimwidget.h
===================================================================
RCS file: /home/kde/kdeextragear-1/vimpart/src/vimwidget.h,v
retrieving revision 1.13
diff -u -r1.13 vimwidget.h
--- vimwidget.h	22 Feb 2003 02:57:50 -0000	1.13
+++ vimwidget.h	22 Feb 2003 15:29:33 -0000
@@ -147,7 +147,6 @@
 		QString _serverName;
 		QString _vimExecutable;
 		bool _vimReady;
-		KProcess * _vimProcess;
 		KWinModule *kwm;
 		//config file
 		bool hideMenu;


More information about the kde-core-devel mailing list