I have moved the call to wxExecute(p_szCmd + _T("\r"),p_aszOutput, p_aszOutError);
from my original location to my wxApp:
int CSilverwareIDE_App::OnSendTermCmd(wxString p_szCmd,
wxArrayString & p_aszOutput,
wxArrayString & p_aszOutError)
{
return wxExecute(p_szCmd + _T("\r"),p_aszOutput, p_aszOutError);
}
All works the same as exec sample program except that mine never leaves lines
145 & 146
bool wxApp::Yield(bool onlyIfNeeded)
{
if ( wxIsInsideYield )
{
if ( !onlyIfNeeded )
{
wxFAIL_MSG( wxT("wxYield called recursively" ) );
}
return FALSE;
}
#if wxUSE_THREADS
if ( !wxThread::IsMain() )
{
// can't call gtk_main_iteration() from other threads like this
return TRUE;
}
#endif // wxUSE_THREADS
wxIsInsideYield = TRUE;
// We need to remove idle callbacks or the loop will
// never finish.
wxTheApp->RemoveIdleTag();
#if wxUSE_LOG
// disable log flushing from here because a call to wxYield() shouldn't
// normally result in message boxes popping up &c
wxLog::Suspend();
#endif
while (gtk_events_pending()) <<<<< I get to here
gtk_main_iteration(); <<<<< and here looping never ends
// It's necessary to call ProcessIdle() to update the frames sizes which
// might have been changed (it also will update other things set from
// OnUpdateUI() which is a nice (and desired) side effect). But we
// call ProcessIdle() only once since this is not meant for longish
// background jobs (controlled by wxIdleEvent::RequestMore() and the
// return value of Processidle().
ProcessIdle();
#if wxUSE_LOG
// let the logs be flashed again
wxLog::Resume();
#endif
wxIsInsideYield = FALSE;
return TRUE;
}
static gint wxapp_poll_func( GPollFD *ufds, guint nfds, gint timeout )
{
gdk_threads_enter();
wxMutexGuiLeave();
g_mainThreadLocked = TRUE;
// we rely on the fact that glib GPollFD struct is really just pollfd but
// I wonder how wise is this in the long term (VZ)
gint res = wxPoll( (wxPollFd *) ufds, nfds, timeout );
wxMutexGuiEnter();
g_mainThreadLocked = FALSE;
gdk_threads_leave();
return res;
}
res will return a 2 while the comand is running in stdout.
res will return a 1 while the comand is completed in stdout.
nfds = 2
ufds->fd = 6
ufds->events = 1 never changes
ufds->revents = 0 never changes
this does the same for the exec program and mine.
now if I do the same with samples/exec I have no problem. It works. I start my
program, after it is up and running, if select menu, it sets up the command string
and call my wxApp method, shown above. never returns. when I create my main frame
class, I do build a lot of other items, but I am still in the main thread. I am using
wxGTK-2.6.1 toolkit and gtk 2
I have to have a terminal pof some kind running. this worked in previous releases.
--
Rick Sivernell
Dallas, Texas 75287
972 306-2296
res0...@verizon.net
Registered Linux User
> Rick - I never had a problem with this in gtk on >= 2.4 [is that your
> version? which platform ?], The \r may be a problem ?
>
> you can try
> http://biolpc22.york.ac.uk/wx/wxhatch/release132/wxhatch-1.3-src-2.tar.gz
>
> in which wxhatch.cpp:2889 has the wxExecute call
>
> chris
>
Chris
the \r has no effect at all, I have since removed it. I will look at the link you
gave me, & compare to my code. Thanks, it seems that something is not detecting a
change or event. A lot of this is in gmain.c and gtkmain.c.
>
> is there some reason you can't use something like the following then ?
>
> #include <stdio.h>
> int main()
> {
> system("my_program.exe");
> }
>
> I know it doesn't have as many nice options as wxExecute, but if you are in time
> pinch why not? Plus it may let you trace into your program farther if you are only
> using it as a temporary fix. However, system() does not return until the program
> you are running with it completes it's operation whereas you can do asynchronous
> operation with wxExecute. I think you can maybe use fork() under unix to do
> something like that, although I never tried, fork is a more complicated beast.
>
> --wolf
>
Wolf
That does work. wxExecute just does not return.
#include <stdio.h>
int main()
{
system("my_program.exe");
}
I know it doesn't have as many nice options as wxExecute, but if you are in time pinch why not? Plus it may let you trace into your program farther if you are only using it as a temporary fix. However, system() does not return until the program you are running with it completes it's operation whereas you can do asynchronous operation with wxExecute. I think you can maybe use fork() under unix to do something like that, although I never tried, fork is a more complicated beast.
--wolf
----- Original Message ----
From: Rick Sivernell <res0...@verizon.net>
To: wx-u...@lists.wxwidgets.org
Sent: Tue 07 Feb 2006 11:30:35 AM MST
Subject: Re: wxExecute failure
On Tue, 07 Feb 2006 10:16:49 -0800 (PST)
<wolfendu...@yahoo.com> wrote:
>
> I missed the part about using tk. I had assumed you were using c++ as most people
> here are using that or python. Anyway, doesn't tk have some call to run external
> programs similar to wxExectue ? in c and cpp you can use the stdio.h header file
> and then just call system("MyProgram.exe") . I once had a problem with wxExecute
> and got around it this way. My problem was I had switched from wxGTK to wxX11, with
> no code changes. wxExecute worked with wxGTK but not wxX11 and I never tried to
> investigate why as there was a time crunch. So I ended up using the system() call
> and it worked perfectly.
>
> --wolf
>
>
> ----- Original Message ----
> From: Rick Sivernell <res0...@verizon.net>
> To: wx-u...@lists.wxwidgets.org
> Sent: Tuesday, February 07, 2006 10:04:21 AM
> Subject: Re: wxExecute failure
>
> On Tue, 07 Feb 2006 08:42:29 -0800 (PST)
> <wolfendu...@yahoo.com> wrote:
>
> > Why not do something like (temporarily though) using stdio.h and system
> > ("whatever.exe") ? to see if you can find the problem. Often I've found doing
> > something like this helped me find quirky problems like you are reporting.
> >
> > --wolf
>
> Wolf
>
> Ok, would you kindly expand, I will try anything to get this working.
> I am using Linux wxGTK tk.
>
tk -> toolkit wxGTK-2.6.2 toolkit, yes I am using c++
--
Rick Sivernell
Dallas, Texas 75287
972 306-2296
res0...@verizon.net
Registered Linux User
---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-u...@lists.wxwidgets.org
For additional commands, e-mail: wx-use...@lists.wxwidgets.org