For bug hunting I created 2 version:
Please test first the simple called version. It contains only the single
instance checker. When starting a second instance it doesn't start the second
instance, all command line parameters are then ignored. (Maybe you have to
delete a previous lock file.)
Only when this one works, please test the second one. It basicly the version 5
with some little changes. The main difference are many DEBUG_TRACE calls to
find out where it crashes. So you have to compile as debug and not as release.
So I hope the find the bug with the output to stderr.
Thanks in advance
Thomas
--
Neu: GMX FreeDSL Komplettanschluss mit DSL 6.000 Flatrate + Telefonanschluss
für nur 17,95 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"hugin and other free panoramic software" group.
A list of frequently asked questions is available at:
http://wiki.panotools.org/Hugin_FAQ
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at http://groups.google.com/group/hugin-ptx
-~----------~----~----~----~------~----~------~--~---
Index: src/hugin1/ptbatcher/PTBatcherGUI.cpp
===================================================================
--- src/hugin1/ptbatcher/PTBatcherGUI.cpp (Revision 3757)
+++ src/hugin1/ptbatcher/PTBatcherGUI.cpp (Arbeitskopie)
@@ -36,6 +36,14 @@
bool PTBatcherGUI::OnInit()
{
+ const wxString name = wxString::Format(_T(".PTBatcherGUI-%s"),
wxGetUserId().c_str());
+ m_checker = new wxSingleInstanceChecker(name);
+ if(m_checker->IsAnotherRunning())
+ {
+ delete m_checker;
+ return false;
+ };
+
// Required to access the preferences of hugin
SetAppName(wxT("hugin"));
@@ -296,6 +304,12 @@
return true;
}
+int PTBatcherGUI::OnExit()
+{
+ delete m_checker;
+ return wxApp::OnExit();
+}
+
void PTBatcherGUI::OnItemActivated(wxListEvent &event)
{
wxCommandEvent dummy;
Index: src/hugin1/ptbatcher/PTBatcherGUI.h
===================================================================
--- src/hugin1/ptbatcher/PTBatcherGUI.h (Revision 3757)
+++ src/hugin1/ptbatcher/PTBatcherGUI.h (Arbeitskopie)
@@ -33,6 +33,7 @@
#include <wx/dir.h>
#include <wx/wfstream.h>
#include <wx/filefn.h>
+#include <wx/snglinst.h>
#include <hugin_config.h>
#include <wx/cmdline.h>
@@ -56,7 +57,8 @@
/** pseudo constructor. with the ability to fail gracefully.
*/
virtual bool OnInit();
-
+ virtual int OnExit();
+
//Handles some input keys for the frame
void OnItemActivated(wxListEvent &event);
void OnKeyDown(wxKeyEvent &event);
@@ -77,6 +79,8 @@
wxLocale m_locale;
wxString m_xrcPrefix;
PTPrograms progs;
+ wxSingleInstanceChecker *m_checker;
+
#ifdef __WXMAC__
wxString m_macFileNameToOpenOnStart;
#endif
Index: src/hugin1/ptbatcher/BatchFrame.cpp
===================================================================
--- src/hugin1/ptbatcher/BatchFrame.cpp (Revision 3757)
+++ src/hugin1/ptbatcher/BatchFrame.cpp (Arbeitskopie)
@@ -184,10 +184,33 @@
bool change = false;
bool loaded = false;
+#ifndef PTBATCHER_USE_WXCONNECTION
+ wxString
fileCommand(workingDir->GetName()+wxFileName::GetPathSeparator()+_T(".ptbatcher.command"));
+ bool startRemoteBatch=false;
+#endif
int projectCount = m_batch->GetProjectCount();
//we constantly poll the working dir for new files and wait a bit on
each loop
while(!m_closeThread)
{
+#ifndef PTBATCHER_USE_WXCONNECTION
+ //check if other instance is requesting update
+ if(wxFileName::FileExists(fileCommand))
+ {
+ wxFFile aFile(fileCommand,wxT("r"));
+ wxString command;
+ aFile.ReadAll(&command);
+ aFile.Close();
+ startRemoteBatch=(command==wxT("RunBatch"));
+ m_batch->ClearBatch();
+ m_batch->LoadTemp();
+ loaded = true;
+ SetCheckboxes();
+ wxRemoveFile(fileCommand);
+ if(!startRemoteBatch)
+ RequestUserAttention();
+ SetStatusText(wxT(""));
+ };
+#endif
//check, if ptbt file was changed
wxFileName aFile(m_batch->GetLastFile());
if(!aFile.FileExists())
@@ -296,6 +319,15 @@
m_batch->SaveTemp();
}
+#ifndef PTBATCHER_USE_WXCONNECTION
+ if(startRemoteBatch)
+ {
+ startRemoteBatch = false;
+ wxCommandEvent MyEvent(wxEVT_COMMAND_TOOL_CLICKED
,XRCID("tool_start"));
+ AddPendingEvent(MyEvent);
+ };
+#endif
+
GetThread()->Sleep(1000);
//wxFile file;
//file.Create(workingDir->GetName()+wxFileName::GetPathSeparator()+_T("krneki.txt"));
@@ -756,21 +788,48 @@
}*/
}
+void BatchFrame::SetCheckboxes()
+{
+ wxConfigBase *config=wxConfigBase::Get();
+ int i;
+ i=config->Read(wxT("/BatchFrame/DeleteCheck"), 0l);
+ if(i==0)
+ XRCCTRL(*this,"cb_delete",wxCheckBox)->SetValue(false);
+ else
+ XRCCTRL(*this,"cb_delete",wxCheckBox)->SetValue(true);
+ i=config->Read(wxT("/BatchFrame/ParallelCheck"), 0l);
+ if(i==0)
+ XRCCTRL(*this,"cb_parallel",wxCheckBox)->SetValue(false);
+ else
+ XRCCTRL(*this,"cb_parallel",wxCheckBox)->SetValue(true);
+ i=config->Read(wxT("/BatchFrame/ShutdownCheck"), 0l);
+ if(i==0)
+ XRCCTRL(*this,"cb_shutdown",wxCheckBox)->SetValue(false);
+ else
+ XRCCTRL(*this,"cb_shutdown",wxCheckBox)->SetValue(true);
+ i=config->Read(wxT("/BatchFrame/OverwriteCheck"), 0l);
+ if(i==0)
+ XRCCTRL(*this,"cb_overwrite",wxCheckBox)->SetValue(false);
+ else
+ XRCCTRL(*this,"cb_overwrite",wxCheckBox)->SetValue(true);
+ i=config->Read(wxT("/BatchFrame/VerboseCheck"), 0l);
+ if(i==0)
+ XRCCTRL(*this,"cb_verbose",wxCheckBox)->SetValue(false);
+ else
+ XRCCTRL(*this,"cb_verbose",wxCheckBox)->SetValue(true);
+};
-
-
-
void BatchFrame::OnCheckDelete(wxCommandEvent &event)
{
if(event.IsChecked())
{
m_batch->deleteFiles = true;
- wxConfigBase::Get()->Write(wxT("/BatchFrame/DeleteCheck"), 1);
+ wxConfigBase::Get()->Write(wxT("/BatchFrame/DeleteCheck"), 1l);
}
else
{
m_batch->deleteFiles = false;
- wxConfigBase::Get()->Write(wxT("/BatchFrame/DeleteCheck"), 0);
+ wxConfigBase::Get()->Write(wxT("/BatchFrame/DeleteCheck"), 0l);
}
}
@@ -780,12 +839,12 @@
if(event.IsChecked())
{
m_batch->overwrite = true;
- wxConfigBase::Get()->Write(wxT("/BatchFrame/OverwriteCheck"),
1);
+ wxConfigBase::Get()->Write(wxT("/BatchFrame/OverwriteCheck"),
1l);
}
else
{
m_batch->overwrite = false;
- wxConfigBase::Get()->Write(wxT("/BatchFrame/OverwriteCheck"),
0);
+ wxConfigBase::Get()->Write(wxT("/BatchFrame/OverwriteCheck"),
0l);
}
}
void BatchFrame::OnCheckParallel(wxCommandEvent &event)
@@ -793,12 +852,12 @@
if(event.IsChecked())
{
m_batch->parallel = true;
- wxConfigBase::Get()->Write(wxT("/BatchFrame/ParallelCheck"), 1);
+ wxConfigBase::Get()->Write(wxT("/BatchFrame/ParallelCheck"),
1l);
}
else
{
m_batch->parallel = false;
- wxConfigBase::Get()->Write(wxT("/BatchFrame/ParallelCheck"), 0);
+ wxConfigBase::Get()->Write(wxT("/BatchFrame/ParallelCheck"),
0l);
}
}
@@ -807,12 +866,12 @@
if(event.IsChecked())
{
m_batch->shutdown = true;
- wxConfigBase::Get()->Write(wxT("/BatchFrame/ShutdownCheck"), 1);
+ wxConfigBase::Get()->Write(wxT("/BatchFrame/ShutdownCheck"),
1l);
}
else
{
m_batch->shutdown = false;
- wxConfigBase::Get()->Write(wxT("/BatchFrame/ShutdownCheck"), 0);
+ wxConfigBase::Get()->Write(wxT("/BatchFrame/ShutdownCheck"),
0l);
}
}
@@ -821,12 +880,12 @@
if(event.IsChecked())
{
m_batch->verbose = true;
- wxConfigBase::Get()->Write(wxT("/BatchFrame/VerboseCheck"), 1);
+ wxConfigBase::Get()->Write(wxT("/BatchFrame/VerboseCheck"), 1l);
}
else
{
m_batch->verbose = false;
- wxConfigBase::Get()->Write(wxT("/BatchFrame/VerboseCheck"), 0);
+ wxConfigBase::Get()->Write(wxT("/BatchFrame/VerboseCheck"), 0l);
}
}
@@ -835,10 +894,10 @@
//wxMessageBox(_T("Closing..."));
//save windows position
if(this->IsMaximized())
- wxConfigBase::Get()->Write(wxT("/BatchFrame/Max"), 1);
+ wxConfigBase::Get()->Write(wxT("/BatchFrame/Max"), 1l);
else
{
- wxConfigBase::Get()->Write(wxT("/BatchFrame/Max"), 0);
+ wxConfigBase::Get()->Write(wxT("/BatchFrame/Max"), 0l);
wxConfigBase::Get()->Write(wxT("/BatchFrame/Width"),
this->GetSize().GetWidth());
wxConfigBase::Get()->Write(wxT("/BatchFrame/Height"),
this->GetSize().GetHeight());
}
@@ -978,9 +1037,9 @@
void BatchFrame::RestoreSize()
{
//get saved size
- int width = wxConfigBase::Get()->Read(wxT("/BatchFrame/Width"), -1);
- int height = wxConfigBase::Get()->Read(wxT("/BatchFrame/Height"), -1);
- int max = wxConfigBase::Get()->Read(wxT("/BatchFrame/Max"), -1);;
+ int width = wxConfigBase::Get()->Read(wxT("/BatchFrame/Width"), -1l);
+ int height = wxConfigBase::Get()->Read(wxT("/BatchFrame/Height"), -1l);
+ int max = wxConfigBase::Get()->Read(wxT("/BatchFrame/Max"), -1l);;
if((width != -1) && (height != -1))
this->SetSize(width,height);
else
Index: src/hugin1/ptbatcher/BatchFrame.h
===================================================================
--- src/hugin1/ptbatcher/BatchFrame.h (Revision 3757)
+++ src/hugin1/ptbatcher/BatchFrame.h (Arbeitskopie)
@@ -79,6 +79,8 @@
void OnClose(wxCloseEvent &event);
//Resets all checkboxes based on m_batch object properties
void PropagateDefaults();
+ //Sets all checkboxes corresponding the setting in config
+ void SetCheckboxes();
//Starts batch execution
void RunBatch();
//Sets locale and XRC prefix pointers from main app
Index: src/hugin1/ptbatcher/PTBatcherGUI.cpp
===================================================================
--- src/hugin1/ptbatcher/PTBatcherGUI.cpp (Revision 3757)
+++ src/hugin1/ptbatcher/PTBatcherGUI.cpp (Arbeitskopie)
@@ -25,6 +25,9 @@
*/
#include "PTBatcherGUI.h"
+#ifndef PTBATCHER_USE_WXCONNECTION
+#include <wx/stdpaths.h>
+#endif
// make wxwindows use this class as the main application
IMPLEMENT_APP(PTBatcherGUI)
@@ -86,21 +89,36 @@
// set the name of locale recource to look for
m_locale.AddCatalog(wxT("hugin"));
- if ( ! wxFile::Exists(m_xrcPrefix + wxT("/batch_frame.xrc")) ) {
- wxMessageBox(_("xrc directory not found, hugin needs to be properly
installed\nTried Path:" + m_xrcPrefix ), _("Fatal Error"));
- return false;
- }
- // initialize image handlers
- wxInitAllImageHandlers();
+ const wxString name = wxString::Format(_T(".PTBatcherGUI-%s"),
wxGetUserId().c_str());
+ DEBUG_TRACE("Single Instance, lock file name: " <<
name.mb_str(wxConvLocal));
+ m_checker = new wxSingleInstanceChecker(name);
+ bool IsFirstInstance=(!m_checker->IsAnotherRunning());
+#ifndef PTBATCHER_USE_WXCONNECTION
+ wxString
fileCommand(wxStandardPaths::Get().GetUserConfigDir()+wxFileName::GetPathSeparator()+_T(".ptbatcher.command"));
+ DEBUG_TRACE("File command name: " <<fileCommand.mb_str(wxConvLocal));
+ if(wxFileName::FileExists(fileCommand))
+ wxRemoveFile(fileCommand);
+#endif
- // Initialize all the XRC handlers.
- wxXmlResource::Get()->InitAllHandlers();
- wxXmlResource::Get()->AddHandler(new ProjectListBoxXmlHandler());
- // load XRC files
- wxXmlResource::Get()->Load(m_xrcPrefix + wxT("batch_frame.xrc"));
- wxXmlResource::Get()->Load(m_xrcPrefix + wxT("batch_toolbar.xrc"));
- wxXmlResource::Get()->Load(m_xrcPrefix + wxT("batch_menu.xrc"));
+ if(IsFirstInstance)
+ {
+ DEBUG_TRACE("First Instance, init all");
+ if ( ! wxFile::Exists(m_xrcPrefix + wxT("/batch_frame.xrc")) ) {
+ wxMessageBox(_("xrc directory not found, hugin needs to
be properly installed\nTried Path:") + m_xrcPrefix , _("Fatal Error"));
+ return false;
+ }
+ // initialize image handlers
+ wxInitAllImageHandlers();
+ // Initialize all the XRC handlers.
+ wxXmlResource::Get()->InitAllHandlers();
+ wxXmlResource::Get()->AddHandler(new
ProjectListBoxXmlHandler());
+ // load XRC files
+ wxXmlResource::Get()->Load(m_xrcPrefix +
wxT("batch_frame.xrc"));
+ wxXmlResource::Get()->Load(m_xrcPrefix +
wxT("batch_toolbar.xrc"));
+ wxXmlResource::Get()->Load(m_xrcPrefix + wxT("batch_menu.xrc"));
+ };
+
// parse arguments
static const wxCmdLineEntryDesc cmdLineDesc[] =
{
@@ -151,10 +169,46 @@
} */
#endif
- m_frame = new BatchFrame(&m_locale,m_xrcPrefix);
- m_frame->RestoreSize();
- SetTopWindow(m_frame);
- m_frame->Show(true);
+#ifdef PTBATCHER_USE_WXCONNECTION
+ wxClient client;
+ wxConnectionBase *conn;
+#else
+ Batch* batch;
+#endif
+ if(IsFirstInstance)
+ {
+ DEBUG_TRACE("Starting first instance");
+ m_frame = new BatchFrame(&m_locale,m_xrcPrefix);
+ m_frame->RestoreSize();
+ SetTopWindow(m_frame);
+ m_frame->Show(true);
+#ifdef PTBATCHER_USE_WXCONNECTION
+ DEBUG_TRACE("Init wxServer");
+ m_server = new BatchIPCServer();
+ if (!m_server->Create(name+_T(".ipc")))
+ {
+ delete m_server;
+ m_server = NULL;
+ };
+ }
+ else
+ {
+ conn=client.MakeConnection(wxEmptyString, name + _T(".ipc"),
IPC_START);
+ if(!conn)
+ {
+ DEBUG_TRACE("Failed to connect to server");
+ return false;
+ };
+#else
+ }
+ else
+ {
+ DEBUG_TRACE("Init batch object");
+ batch=new Batch(NULL,argv[0],false);
+ batch->LoadTemp();
+ DEBUG_TRACE("Loaded batch");
+#endif
+ };
//m_frame->SetLocaleAndXRC(&m_locale,m_xrcPrefix);
//projectsRunning=0;
unsigned int count = 0;
@@ -167,20 +221,31 @@
if(!projectSpecified) //next parameter must be new script file
{
wxFileName name(param);
- Project *proj = new
Project(param,name.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) +
name.GetName());
- projList.Add(proj);
- m_frame->SetStatusText(_("Added project ")+param);
-
- m_frame->projListBox->AppendProject(proj);
+ name.MakeAbsolute();
+ if(IsFirstInstance)
+ m_frame->AddToList(name.GetFullPath());
+ else
+#ifdef PTBATCHER_USE_WXCONNECTION
+ conn->Request(wxT("A ")+name.GetFullPath());
+#else
+ batch->AddProjectToBatch(name.GetFullPath());
+#endif
projectSpecified = true;
}
else //parameter could be previous project's output prefix
{
wxFileName fn(param);
+ fn.MakeAbsolute();
if(!fn.HasExt()) //if there is no extension we
have a prefix
{
- projList.Last().prefix = param;
-
m_frame->projListBox->ReloadProject(m_frame->projListBox->GetItemCount()-1,((Project*)&projList.Last()));
+ if(IsFirstInstance)
+
m_frame->ChangePrefix(-1,fn.GetFullPath());
+ else
+#ifdef PTBATCHER_USE_WXCONNECTION
+ conn->Request(wxT("P
")+fn.GetFullPath());
+#else
+
batch->ChangePrefix(batch->GetProjectCount()-1,fn.GetFullPath());
+#endif
projectSpecified = false;
}
else
@@ -193,8 +258,14 @@
ext.CmpNoCase(wxT("pnm")) == 0 ||
ext.CmpNoCase(wxT("hdr")) == 0)
{
//extension will be removed before
stitch, so there is no need to do it now
- projList.Last().prefix = param;
-
m_frame->projListBox->ReloadProject(m_frame->projListBox->GetItemCount()-1,((Project*)&projList.Last()));
+ if(IsFirstInstance)
+
m_frame->ChangePrefix(-1,fn.GetFullPath());
+ else
+#ifdef PTBATCHER_USE_WXCONNECTION
+ conn->Request(wxT("P
")+fn.GetFullPath());
+#else
+
batch->ChangePrefix(batch->GetProjectCount()-1,fn.GetFullPath());
+#endif
projectSpecified = false;
}
else //if parameter has a different extension
we presume it is a new script file
@@ -223,79 +294,76 @@
m_frame->projListBox->Deselect(m_frame->projListBox->GetItemCount()-1);*/
//we add the new project
- wxFileName name(param);
- Project *proj = new
Project(param,name.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) +
name.GetName());
- projList.Add(proj);
- m_frame->SetStatusText(_("Added project
")+param);
-
m_frame->projListBox->AppendProject(proj);
+ if(IsFirstInstance)
+
m_frame->AddToList(fn.GetFullPath());
+ else
+#ifdef PTBATCHER_USE_WXCONNECTION
+ conn->Request(wxT("A
")+fn.GetFullPath());
+#else
+
batch->AddProjectToBatch(fn.GetFullPath());
+#endif
projectSpecified = true;
}
} //else of if(!fn.HasExt())
}
}
- if (parser.Found(wxT("d")) ) {
- XRCCTRL(*m_frame,"cb_delete",wxCheckBox)->SetValue(true);
- wxConfigBase::Get()->Write(wxT("/BatchFrame/DeleteCheck"), 1);
- }
- else{
- int del =
wxConfigBase::Get()->Read(wxT("/BatchFrame/DeleteCheck"), (long)0);
- if(del==0)
-
XRCCTRL(*m_frame,"cb_delete",wxCheckBox)->SetValue(false);
+ DEBUG_TRACE("Readed command line parameters");
+ wxConfigBase *config=wxConfigBase::Get();
+ if (parser.Found(wxT("d")))
+ config->Write(wxT("/BatchFrame/DeleteCheck"), 1l);
+ if (parser.Found(wxT("p")))
+ config->Write(wxT("/BatchFrame/ParallelCheck"), 1l);
+ if (parser.Found(wxT("s")))
+ config->Write(wxT("/BatchFrame/ShutdownCheck"), 1l);
+ if (parser.Found(wxT("o")))
+ config->Write(wxT("/BatchFrame/OverwriteCheck"), 1l);
+ if (parser.Found(wxT("v")))
+ config->Write(wxT("/BatchFrame/VerboseCheck"), 1l);
+ DEBUG_TRACE("Save parameters");
+ config->Flush();
+ if(!IsFirstInstance)
+ {
+#ifdef PTBATCHER_USE_WXCONNECTION
+ conn->Request(wxT("BringWindowToTop"));
+ if(parser.Found(wxT("b")))
+ conn->Request(wxT("RunBatch"));
+ conn->Disconnect();
+ delete conn;
+#else
+ batch->SaveTemp();
+ DEBUG_TRACE("Saved batch");
+ wxFile aFile(fileCommand,wxFile::write);
+ if(parser.Found(wxT("b")))
+ aFile.Write(wxT("RunBatch"));
else
-
XRCCTRL(*m_frame,"cb_delete",wxCheckBox)->SetValue(true);
- }
- if (parser.Found(wxT("p")) ) {
- XRCCTRL(*m_frame,"cb_parallel",wxCheckBox)->SetValue(true);
- wxConfigBase::Get()->Write(wxT("/BatchFrame/ParallelCheck"), 1);
- }
- else{
- int par =
wxConfigBase::Get()->Read(wxT("/BatchFrame/ParallelCheck"), (long)0);
- if(par==0)
-
XRCCTRL(*m_frame,"cb_parallel",wxCheckBox)->SetValue(false);
- else
-
XRCCTRL(*m_frame,"cb_parallel",wxCheckBox)->SetValue(true);
- }
- if (parser.Found(wxT("s")) ) {
- XRCCTRL(*m_frame,"cb_shutdown",wxCheckBox)->SetValue(true);
- wxConfigBase::Get()->Write(wxT("/BatchFrame/ShutdownCheck"), 1);
- }
- else{
- int shtdwn =
wxConfigBase::Get()->Read(wxT("/BatchFrame/ShutdownCheck"), (long)0);
- if(shtdwn==0)
-
XRCCTRL(*m_frame,"cb_shutdown",wxCheckBox)->SetValue(false);
- else
-
XRCCTRL(*m_frame,"cb_shutdown",wxCheckBox)->SetValue(true);
- }
- if (parser.Found(wxT("o")) ) {
- XRCCTRL(*m_frame,"cb_overwrite",wxCheckBox)->SetValue(true);
- wxConfigBase::Get()->Write(wxT("/BatchFrame/OverwriteCheck"),
1);
- }
- else{
- int overwrite =
wxConfigBase::Get()->Read(wxT("/BatchFrame/OverwriteCheck"), (long)0);
- if(overwrite==0)
-
XRCCTRL(*m_frame,"cb_overwrite",wxCheckBox)->SetValue(false);
- else
-
XRCCTRL(*m_frame,"cb_overwrite",wxCheckBox)->SetValue(true);
- }
- if (parser.Found(wxT("v")) ) {
- XRCCTRL(*m_frame,"cb_verbose",wxCheckBox)->SetValue(true);
- wxConfigBase::Get()->Write(wxT("/BatchFrame/VerboseCheck"), 1);
- }
- else{
- int overwrite =
wxConfigBase::Get()->Read(wxT("/BatchFrame/VerboseCheck"), (long)0);
- if(overwrite==0)
-
XRCCTRL(*m_frame,"cb_verbose",wxCheckBox)->SetValue(false);
- else
-
XRCCTRL(*m_frame,"cb_verbose",wxCheckBox)->SetValue(true);
- }
+ aFile.Write(wxT("Update"));
+ aFile.Close();
+ DEBUG_TRACE("Saved command file");
+#endif
+ delete m_checker;
+ return false;
+ };
+ DEBUG_TRACE("Set checkboxes");
+ m_frame->SetCheckboxes();
+ DEBUG_TRACE("Propagate defaults");
m_frame->PropagateDefaults();
if (parser.Found(wxT("b")) ) {
m_frame->RunBatch();
}
+ DEBUG_TRACE("Finished OnInit");
return true;
}
+int PTBatcherGUI::OnExit()
+{
+ delete m_checker;
+#ifdef PTBATCHER_USE_WXCONNECTION
+ delete m_server;
+#endif
+ return 0;
+}
+
void PTBatcherGUI::OnItemActivated(wxListEvent &event)
{
wxCommandEvent dummy;
@@ -333,3 +401,31 @@
m_macFileNameToOpenOnStart = fileName;
}
#endif
+
+#ifdef PTBATCHER_USE_WXCONNECTION
+wxChar* BatchIPCConnection::OnRequest(const wxString& topic, const wxString&
item, int *size, wxIPCFormat format)
+{
+ BatchFrame *MyBatchFrame=wxGetApp().GetFrame();
+ if(item.Left(1)==wxT("A"))
+ MyBatchFrame->AddToList(item.Mid(2));
+ if(item.Left(1)==wxT("P"))
+ MyBatchFrame->ChangePrefix(-1,item.Mid(2));
+ MyBatchFrame->SetCheckboxes();
+ if(item==wxT("BringWindowToTop"))
+ MyBatchFrame->RequestUserAttention();
+ if(item==wxT("RunBatch"))
+ {
+ wxCommandEvent myEvent(wxEVT_COMMAND_TOOL_CLICKED
,XRCID("tool_start"));
+ MyBatchFrame->AddPendingEvent(myEvent);
+ };
+ return wxT("");
+};
+
+wxConnectionBase* BatchIPCServer::OnAcceptConnection (const wxString& topic)
+{
+ if(topic==IPC_START)
+ return new BatchIPCConnection;
+ return NULL;
+};
+
+#endif
Index: src/hugin1/ptbatcher/PTBatcherGUI.h
===================================================================
--- src/hugin1/ptbatcher/PTBatcherGUI.h (Revision 3757)
+++ src/hugin1/ptbatcher/PTBatcherGUI.h (Arbeitskopie)
@@ -24,6 +24,20 @@
*
*/
+#ifdef _WINDOWS
+#define PTBATCHER_USE_WXCONNECTION
+#else
+//on Linux wxConnection causes a X windows error BadImplemention: server
doesn't implement operation
+//when try to use it, you must add wxNet to wxWidgets_USE_LIBS because on linux
+//wxServer is a wxTCPServer which is in wxNet
+//in trunk/CMakeLists.txt (rev. 3750) change
+//SET(wxWidgets_USE_LIBS base core xrc html xml adv gl)
+//to
+//SET(wxWidgets_USE_LIBS base core xrc html xml adv gl net)
+
+#undef PTBATCHER_USE_WXCONNECTION
+#endif
+
#include "RunStitchFrame.h"
#include "Batch.h"
#include "BatchFrame.h"
@@ -33,6 +47,10 @@
#include <wx/dir.h>
#include <wx/wfstream.h>
#include <wx/filefn.h>
+#include <wx/snglinst.h>
+#ifdef PTBATCHER_USE_WXCONNECTION
+#include <wx/ipc.h>
+#endif
#include <hugin_config.h>
#include <wx/cmdline.h>
@@ -46,17 +64,38 @@
#define PTBATCHERGUI_H
// **********************************************************************
+#ifdef PTBATCHER_USE_WXCONNECTION
+class BatchIPCConnection : public wxConnection
+{
+public:
+ //request handler
+ virtual wxChar *OnRequest(const wxString& topic, const wxString& item,
int *size = NULL, wxIPCFormat format = wxIPC_TEXT);
+};
+
+class BatchIPCServer : public wxServer
+{ public:
+ //accept conncetion handler
+ virtual wxConnectionBase *OnAcceptConnection (const wxString& topic);
+};
+
+const wxString IPC_START(wxT("BatchStart"));
+#endif
+
/** The application class for hugin_stitch_project
*
* it contains the main frame.
*/
class PTBatcherGUI : public wxApp
{
+#ifdef PTBATCHER_USE_WXCONNECTION
+ friend class BatchIPCConnection;
+#endif
public:
/** pseudo constructor. with the ability to fail gracefully.
*/
virtual bool OnInit();
-
+ virtual int OnExit();
+
//Handles some input keys for the frame
void OnItemActivated(wxListEvent &event);
void OnKeyDown(wxKeyEvent &event);
@@ -77,6 +116,11 @@
wxLocale m_locale;
wxString m_xrcPrefix;
PTPrograms progs;
+ wxSingleInstanceChecker *m_checker;
+#ifdef PTBATCHER_USE_WXCONNECTION
+ BatchIPCServer *m_server;
+#endif
+
#ifdef __WXMAC__
wxString m_macFileNameToOpenOnStart;
#endif