Skip to content

Commit

Permalink
- Fixed: regression: show gdb terminal option is now working again
Browse files Browse the repository at this point in the history
git-svn-id: https://codelite.svn.sourceforge.net/svnroot/codelite/trunk@4354 9da81c78-c036-0410-9e1f-a2b0375e4b5a
  • Loading branch information
eranif committed Aug 30, 2010
1 parent 334db1c commit 64f67e1
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 38 deletions.
6 changes: 3 additions & 3 deletions CodeLite/asyncprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ class IProcess;
# include "unixprocess_impl.h"
#endif

IProcess* CreateAsyncProcess(wxEvtHandler *parent, const wxString& cmd, const wxString &workingDir)
IProcess* CreateAsyncProcess(wxEvtHandler *parent, const wxString& cmd, IProcessCreateFlags flags, const wxString &workingDir)
{
#ifdef __WXMSW__
wxString errMsg;
return WinProcessImpl::Execute(parent, cmd, errMsg, workingDir);
return WinProcessImpl::Execute(parent, cmd, errMsg, flags, workingDir);
#else
return UnixProcessImpl::Execute(parent, cmd, workingDir);
return UnixProcessImpl::Execute(parent, cmd, flags, workingDir);
#endif
}
9 changes: 7 additions & 2 deletions CodeLite/asyncprocess.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
#include <wx/string.h>
#include <wx/event.h>

enum IProcessCreateFlags {
IProcessCreateDefault = 0x0000000, // Default: create process with no console window
IProcessCreateConsole = 0x0000001 // Create with console window shown
};

/**
* @class IProcess
* @author eran
Expand Down Expand Up @@ -52,7 +57,7 @@ class IProcess
int GetExitCode() const {
return m_exitCode;
}

void SetHardKill(bool hardKill) {
this->m_hardKill = hardKill;
}
Expand All @@ -62,5 +67,5 @@ class IProcess
};

// Help method
IProcess* CreateAsyncProcess(wxEvtHandler *parent, const wxString& cmd, const wxString &workingDir = wxEmptyString);
IProcess* CreateAsyncProcess(wxEvtHandler *parent, const wxString& cmd, IProcessCreateFlags flags = IProcessCreateDefault, const wxString &workingDir = wxEmptyString);
#endif // I_PROCESS_H
12 changes: 6 additions & 6 deletions CodeLite/ctags_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ TagsManager::~TagsManager()
// Dont kill the indexer process, just terminate the
// reader-thread (this is done by deleting the indexer object)
m_canRestartIndexer = false;

#ifndef __WXMSW__
m_codeliteIndexerProcess->Terminate();
#endif
Expand Down Expand Up @@ -279,7 +279,7 @@ void TagsManager::StartCodeLiteIndexer()

// concatenate the PID to identifies this channel to this instance of codelite
cmd << wxT("\"") << m_codeliteIndexerPath.GetFullPath() << wxT("\" ") << uid << wxT(" --pid");
m_codeliteIndexerProcess = CreateAsyncProcess(this, cmd, wxStandardPaths::Get().GetUserDataDir());
m_codeliteIndexerProcess = CreateAsyncProcess(this, cmd, IProcessCreateDefault, wxStandardPaths::Get().GetUserDataDir());
}

void TagsManager::RestartCodeLiteIndexer()
Expand Down Expand Up @@ -1320,20 +1320,20 @@ bool TagsManager::GetDerivationList(const wxString &path, std::vector<wxString>
// Make sure that inherits != the current name or we will end up in an infinite loop
if(tmpInhr != tagName) {
wxString possibleScope(wxT("<global>"));

// if the 'inherits' already contains a scope
// dont attempt to fix it
if(inherits.Contains(wxT("::")) == false) {

// Correc the type/scope
IsTypeAndScopeExists(inherits, possibleScope);

if (possibleScope != wxT("<global>")) {
inherits = possibleScope + wxT("::") + inherits;
}

}

// Make sure that this parent was not scanned already
if(scannedInherits.find(inherits) == scannedInherits.end()) {
scannedInherits.insert(inherits);
Expand Down
18 changes: 10 additions & 8 deletions CodeLite/unixprocess_impl.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "unixprocess_impl.h"

#if defined(__WXMAC__)||defined(__WXGTK__)

#include <wx/stdpaths.h>
#include <wx/stdpaths.h>
#include <wx/filename.h>
#include <unistd.h>
#include <signal.h>
Expand Down Expand Up @@ -235,11 +235,11 @@ void UnixProcessImpl::Cleanup()
wxFileName script(exePath.GetPath(), wxT("codelite_kill_children "));
cmd << wxT("/bin/sh -f ") << script.GetFullPath();
cmd << GetPid();

// If hard kill requested, pass -9
if(GetHardKill())
cmd << wxT(" -9");

wxExecute(cmd, wxEXEC_ASYNC);
}

Expand All @@ -249,7 +249,7 @@ void UnixProcessImpl::Cleanup()

#else
wxKill (GetPid(), GetHardKill() ? wxSIGKILL : wxSIGTERM);

// Perform process cleanup
int status(0);
waitpid(GetPid(), &status, 0);
Expand Down Expand Up @@ -306,8 +306,10 @@ bool UnixProcessImpl::Write(const wxString& buff)
return bytes == (int)tmpbuf.length();
}

IProcess* UnixProcessImpl::Execute(wxEvtHandler* parent, const wxString& cmd, const wxString& workingDirectory)
IProcess* UnixProcessImpl::Execute(wxEvtHandler* parent, const wxString& cmd, IProcessCreateFlags flags, const wxString& workingDirectory)
{
wxUnusedVar(flags);

make_argv(cmd);
if ( argc == 0 ) {
return NULL;
Expand Down Expand Up @@ -408,11 +410,11 @@ void UnixProcessImpl::Terminate()
wxFileName script(exePath.GetPath(), wxT("codelite_kill_children "));
cmd << wxT("/bin/sh -f ") << script.GetFullPath();
cmd << GetPid();

// If hard kill requested, pass -9
if(GetHardKill())
cmd << wxT(" -9");

wxExecute(cmd, wxEXEC_ASYNC);
}
#else
Expand Down
4 changes: 2 additions & 2 deletions CodeLite/unixprocess_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class UnixProcessImpl : public IProcess
UnixProcessImpl(wxEvtHandler *parent);
virtual ~UnixProcessImpl();

static IProcess *Execute(wxEvtHandler *parent, const wxString &cmd, const wxString &workingDirectory = wxEmptyString);
static IProcess *Execute(wxEvtHandler *parent, const wxString &cmd, IProcessCreateFlags flags, const wxString &workingDirectory = wxEmptyString);

void SetReadHandle(const int& readHandle) {
this->m_readHandle = readHandle;
Expand All @@ -39,7 +39,7 @@ class UnixProcessImpl : public IProcess
virtual bool Read(wxString& buff);
virtual bool Write(const wxString& buff);
virtual void Terminate();

};
#endif //#if defined(__WXMAC )||defined(__WXGTK__)
#endif // __unixprocessimpl__
24 changes: 13 additions & 11 deletions CodeLite/winprocess_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class MyDirGuard {
};

/*static*/
IProcess* WinProcessImpl::Execute(wxEvtHandler *parent, const wxString& cmd, wxString &errMsg, const wxString &workingDir)
IProcess* WinProcessImpl::Execute(wxEvtHandler *parent, const wxString& cmd, wxString &errMsg, IProcessCreateFlags flags, const wxString &workingDir)
{
SECURITY_ATTRIBUTES saAttr;
BOOL fSuccess;
Expand Down Expand Up @@ -170,21 +170,23 @@ IProcess* WinProcessImpl::Execute(wxEvtHandler *parent, const wxString& cmd, wxS
siStartInfo.hStdError = prc->hChildStderrWr;

// Set the window to hide
siStartInfo.wShowWindow = SW_HIDE;
siStartInfo.wShowWindow = flags & IProcessCreateConsole ? SW_SHOW : SW_HIDE;
DWORD creationFlags = flags & IProcessCreateConsole ? CREATE_NEW_CONSOLE : CREATE_NO_WINDOW;

BOOL ret = CreateProcess( NULL,
#if wxVERSION_NUMBER < 2900
(WCHAR*)cmd.GetData(),
#else
cmd.wchar_str(), // shell line execution command
cmd.wchar_str(), // shell line execution command
#endif
NULL, // process security attributes
NULL, // primary thread security attributes
TRUE, // handles are inherited
CREATE_NO_WINDOW, // creation flags
NULL, // use parent's environment
NULL, // CD to tmp dir
&siStartInfo, // STARTUPINFO pointer
&prc->piProcInfo); // receives PROCESS_INFORMATION
NULL, // process security attributes
NULL, // primary thread security attributes
TRUE, // handles are inherited
creationFlags, // creation flags
NULL, // use parent's environment
NULL, // CD to tmp dir
&siStartInfo, // STARTUPINFO pointer
&prc->piProcInfo); // receives PROCESS_INFORMATION
if ( ret ) {
prc->dwProcessId = prc->piProcInfo.dwProcessId;
} else {
Expand Down
2 changes: 1 addition & 1 deletion CodeLite/winprocess_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class WinProcessImpl : public IProcess
virtual ~WinProcessImpl();

// Create process asynchronously and return a process object
static IProcess* Execute(wxEvtHandler *parent, const wxString& cmd, wxString &errMsg, const wxString &workingDir = wxEmptyString);
static IProcess* Execute(wxEvtHandler *parent, const wxString& cmd, wxString &errMsg, IProcessCreateFlags flags = IProcessCreateDefault,const wxString &workingDir = wxEmptyString);

/**
* @brief read data from stdout, if no data is available, return
Expand Down
2 changes: 1 addition & 1 deletion ContinuousBuild/buildprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bool BuildProcess::Execute(const wxString& cmd, const wxString &fileName, const
if(m_process)
return false;

m_process = CreateAsyncProcess(evtHandler, cmd, workingDirectory);
m_process = CreateAsyncProcess(evtHandler, cmd, IProcessCreateDefault, workingDirectory);
if(!m_process)
return false;

Expand Down
6 changes: 5 additions & 1 deletion Debugger/debuggergdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,11 @@ bool DbgGdb::Start( const wxString &debuggerPath, const wxString &exeName, const
m_observer->UpdateAddLine( wxString::Format( wxT( "Current working dir: %s" ), wxGetCwd().c_str() ) );
m_observer->UpdateAddLine( wxString::Format( wxT( "Launching gdb from : %s" ), cwd.c_str() ) );
m_observer->UpdateAddLine( wxString::Format( wxT( "Starting debugger : %s" ), cmd.c_str() ) );
m_gdbProcess = CreateAsyncProcess( this, cmd, cwd );
m_gdbProcess = CreateAsyncProcess( this,
cmd,
// show console?
m_info.showTerminal ? IProcessCreateConsole : IProcessCreateDefault,
cwd );
if ( !m_gdbProcess ) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion Plugin/wxterminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ void wxTerminal::DoProcessCommand(const wxString& command)

} else {
// real command
IProcess *cmdPrc = CreateAsyncProcess(this, cmdShell, m_workingDir);
IProcess *cmdPrc = CreateAsyncProcess(this, cmdShell, IProcessCreateDefault, m_workingDir);
if( cmdPrc ) {
m_process = cmdPrc;
} else {
Expand Down
2 changes: 1 addition & 1 deletion Subversion2/svn_console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ bool SvnConsole::DoExecute(const wxString& cmd, SvnCommandHandler* handler, cons
bool useOverrideMap = m_plugin->GetSettings().GetFlags() & SvnUsePosixLocale;
EnvSetter env(m_plugin->GetManager()->GetEnv(), useOverrideMap ? &om : NULL);

m_process = CreateAsyncProcess(this, cmdShell, workingDirectory);
m_process = CreateAsyncProcess(this, cmdShell, IProcessCreateDefault, workingDirectory);
if (!m_process) {
AppendText(wxT("Failed to launch Subversion client.\n"));
return false;
Expand Down
2 changes: 1 addition & 1 deletion Subversion2/svncommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ bool SvnCommand::Execute(const wxString &command, const wxString &workingDirecto
EnvSetter env(m_plugin->GetManager()->GetEnv(), useOverrideMap ? &om : NULL);


m_process = CreateAsyncProcess(this, command, workingDirectory);
m_process = CreateAsyncProcess(this, command, IProcessCreateDefault, workingDirectory);
if ( !m_process ) {
return false;
}
Expand Down

0 comments on commit 64f67e1

Please sign in to comment.