[hugin-ptx] PTBatcherGUI single instance
I changed the debug version again. Please test it compiled as debug. (It's using wxLogDebug to output some messages. I hope to identify to lines which cause the problems.) Thomas -- Pt! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger01 --~--~-~--~~~---~--~~ 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 hugin-ptx@googlegroups.com To unsubscribe from this group, send email to hugin-ptx-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/hugin-ptx -~--~~~~--~~--~--~--- 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()) {
[hugin-ptx] PTBatcherGUI single instance
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 hugin-ptx@googlegroups.com To unsubscribe from this group, send email to hugin-ptx-unsubscr...@googlegroups.com 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; +
[hugin-ptx] PTBatcherGUI single instance
Hi, I can't get this ver4 patch to apply, New try. Thomas -- Aufgepasst: Sind Ihre Daten beim Online-Banking auch optimal geschützt? Jetzt absichern: https://homebanking.gmx.net/?mc=m...@footer.hb --~--~-~--~~~---~--~~ 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 hugin-ptx@googlegroups.com To unsubscribe from this group, send email to hugin-ptx-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/hugin-ptx -~--~~~~--~~--~--~--- Index: src/hugin1/ptbatcher/BatchFrame.cpp === --- src/hugin1/ptbatcher/BatchFrame.cpp (Revision 3752) +++ src/hugin1/ptbatcher/BatchFrame.cpp (Arbeitskopie) @@ -153,10 +153,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()) @@ -265,6 +288,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)); @@ -342,12 +374,7 @@ wxArrayString paths; dlg.GetPaths(paths); for(unsigned int i=0; ipaths.GetCount(); i++) - { - wxFileName name(paths.Item(i)); - m_batch-AddProjectToBatch(paths.Item(i),name.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + name.GetName()); - SetStatusText(_(Added project )+paths.Item(i)); - projListBox-AppendProject(m_batch-GetProject(m_batch-GetProjectCount()-1)); - } + AddToList(paths.Item(i)); m_batch-SaveTemp(); } else { // bail @@ -355,6 +382,15 @@ } } +void BatchFrame::AddToList(wxString aFile) +{ + wxFileName name(aFile); + m_batch-AddProjectToBatch(aFile,name.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + name.GetName()); + SetStatusText(_(Added project )+aFile); + projListBox-AppendProject(m_batch-GetProject(m_batch-GetProjectCount()-1)); +} + + void BatchFrame::OnButtonCancel(wxCommandEvent event) { GetToolBar()-ToggleTool(XRCID(tool_pause),false); @@ -373,8 +409,7 @@ if (dlg.ShowModal() == wxID_OK) { wxString outname(dlg.GetPath()); - m_batch-ChangePrefix(selIndex,outname); - projListBox-ChangePrefix(selIndex,outname); + ChangePrefix(selIndex,outname); //SetStatusText(_T(Changed prefix for +projListBox-GetSelectedProject())); m_batch-SaveTemp(); } @@ -385,6 +420,17 @@ } } +void BatchFrame::ChangePrefix(int index,wxString newPrefix) +{ + int i; + if(index!=-1) + i=index; + else + i=m_batch-GetProjectCount()-1; + m_batch-ChangePrefix(i,newPrefix); + projListBox-ChangePrefix(i,newPrefix); +} + void
[hugin-ptx] PTBatcherGUI single instance
Anyway, I see that you've done some patches for refreshing batch queue but it doesn't seem to work (or I've not get the purpose) because when I run PTBatcherGUI, add some project through it's GUI and then run PTBatcher -a some_project.pto everything from the queue is removed. I could not reproduce this behaviour. On windows it works. Nevertheless I added several m_batch-SaveTemp() calls when the queue was changed in PTBatcherGUI to explicit save the changed queue (rev 3752). I hope, this should fix it. Thanks, it now crashes a bit further on: I have no clue, why it crashes now. So I changed the patch to use a file .ptbatcher.command in the temp dir to communicate between the different instances. This removes the usage of wxServer/wxClient. I hope, this works better. It also creates a '~/HuginBatch-bruno' file containing the PID This is a lock file used by wxSingleInstanceChecker. I changed the name to make it hidden. On windows wxSingleInstanceChecker uses a mutex, so this file is never created. Thomas -- Aufgepasst: Sind Ihre Daten beim Online-Banking auch optimal geschützt? Jetzt absichern: https://homebanking.gmx.net/?mc=m...@footer.hb --~--~-~--~~~---~--~~ 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 hugin-ptx@googlegroups.com To unsubscribe from this group, send email to hugin-ptx-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/hugin-ptx -~--~~~~--~~--~--~--- Index: src/hugin1/ptbatcher/BatchFrame.cpp === --- src/hugin1/ptbatcher/BatchFrame.cpp (Revision 3750) +++ src/hugin1/ptbatcher/BatchFrame.cpp (Arbeitskopie) @@ -119,6 +119,8 @@ wxDir* workingDir = new wxDir(wxStandardPaths::Get().GetUserConfigDir()); wxString fileSent = _T(.ptbs*); wxString pending; + wxString fileCommand(workingDir-GetName()+wxFileName::GetPathSeparator()+_T(.ptbatcher.command)); + /*wxString fileTemp = _T(.ptbt*); wxString temp = _T(); //we check for existing temporary files @@ -152,10 +154,27 @@ wxGetApp().AppendBatchFile(workingDir-GetName()+wxFileName::GetPathSeparator()+temp);*/ bool change = false; + bool startRemoteBatch=false; int projectCount = m_batch-GetProjectCount(); //we constantly poll the working dir for new files and wait a bit on each loop while(!m_closeThread) { + 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(); + change=true; + SetCheckboxes(); + wxRemoveFile(fileCommand); + if(!startRemoteBatch) + RequestUserAttention(); + SetStatusText(wxT()); + }; //check, if ptbt file was changed wxFileName aFile(m_batch-GetLastFile()); if(!aFile.FileExists()) @@ -260,7 +279,11 @@ change = false; m_batch-SaveTemp(); } - + if(startRemoteBatch) + { + wxCommandEvent MyEvent(wxEVT_COMMAND_TOOL_CLICKED ,XRCID(tool_start)); + AddPendingEvent(MyEvent); + }; GetThread()-Sleep(1000); //wxFile file; //file.Create(workingDir-GetName()+wxFileName::GetPathSeparator()+_T(krneki.txt)); @@ -336,18 +359,21 @@ wxArrayString paths; dlg.GetPaths(paths); for(unsigned int i=0; ipaths.GetCount(); i++) - { - wxFileName name(paths.Item(i)); - m_batch-AddProjectToBatch(paths.Item(i),name.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + name.GetName()); - SetStatusText(_(Added project )+paths.Item(i)); - projListBox-AppendProject(m_batch-GetProject(m_batch-GetProjectCount()-1)); - } + AddToList(paths.Item(i)); } else { // bail //wxLogError( _(No project files specified)); } } +void BatchFrame::AddToList(wxString aFile) +{ + wxFileName name(aFile); + m_batch-AddProjectToBatch(aFile,name.GetPath(wxPATH_GET_VOLUME
[hugin-ptx] PTBatcherGUI single instance
Attached you will find a patch, which makes PTBatcherGUI a single instance application. PTBatcherGUI can so started only one times. When calling PTBatcherGUI a second time the command line parameters are transfered to the already running instance (e.g. starting run batch in running PTBatcherGUI with command line). It was tested on Windows and worked. Please test it on Linux and Mac. Thomas -- Aufgepasst: Sind Ihre Daten beim Online-Banking auch optimal geschützt? Jetzt informieren und absichern: https://homebanking.web.de/?mc=m...@footer. --~--~-~--~~~---~--~~ 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 hugin-ptx@googlegroups.com To unsubscribe from this group, send email to hugin-ptx-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/hugin-ptx -~--~~~~--~~--~--~--- Index: src/hugin1/ptbatcher/Batch.cpp === --- src/hugin1/ptbatcher/Batch.cpp (Revision 3738) +++ src/hugin1/ptbatcher/Batch.cpp (Arbeitskopie) @@ -622,7 +622,6 @@ if(verbose gui) { stitchFrame-Show( true ); - wxTheApp-SetTopWindow( stitchFrame ); } wxFileName basename(scriptFile); Index: src/hugin1/ptbatcher/BatchFrame.cpp === --- src/hugin1/ptbatcher/BatchFrame.cpp (Revision 3738) +++ src/hugin1/ptbatcher/BatchFrame.cpp (Arbeitskopie) @@ -336,18 +336,21 @@ wxArrayString paths; dlg.GetPaths(paths); for(unsigned int i=0; ipaths.GetCount(); i++) - { - wxFileName name(paths.Item(i)); - m_batch-AddProjectToBatch(paths.Item(i),name.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + name.GetName()); - SetStatusText(_(Added project )+paths.Item(i)); - projListBox-AppendProject(m_batch-GetProject(m_batch-GetProjectCount()-1)); - } + AddToList(paths.Item(i)); } else { // bail //wxLogError( _(No project files specified)); } } +void BatchFrame::AddToList(wxString aFile) +{ + wxFileName name(aFile); + m_batch-AddProjectToBatch(aFile,name.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) + name.GetName()); + SetStatusText(_(Added project )+aFile); + projListBox-AppendProject(m_batch-GetProject(m_batch-GetProjectCount()-1)); +} + void BatchFrame::OnButtonCancel(wxCommandEvent event) { GetToolBar()-ToggleTool(XRCID(tool_pause),false); @@ -366,8 +369,7 @@ if (dlg.ShowModal() == wxID_OK) { wxString outname(dlg.GetPath()); - m_batch-ChangePrefix(selIndex,outname); - projListBox-ChangePrefix(selIndex,outname); + ChangePrefix(selIndex,outname); //SetStatusText(_T(Changed prefix for +projListBox-GetSelectedProject())); //m_batch-SaveTemp(); } @@ -378,6 +380,17 @@ } } +void BatchFrame::ChangePrefix(int index,wxString newPrefix) +{ + int i; + if(index!=-1) + i=index; + else + i=m_batch-GetProjectCount()-1; + m_batch-ChangePrefix(i,newPrefix); + projListBox-ChangePrefix(i,newPrefix); +} + void BatchFrame::OnButtonClear(wxCommandEvent event) { int returnCode = m_batch-ClearBatch(); @@ -811,6 +824,38 @@ else m_batch-verbose = false; } + +void BatchFrame::SetCheckboxes() +{ + wxConfigBase *config=wxConfigBase::Get(); + int i; + i=config-Read(wxT(/BatchFrame/DeleteCheck), (long)0); + if(i==0) + XRCCTRL(*this,cb_delete,wxCheckBox)-SetValue(false); + else + XRCCTRL(*this,cb_delete,wxCheckBox)-SetValue(true); + i=config-Read(wxT(/BatchFrame/ParallelCheck), (long)0); + if(i==0) + XRCCTRL(*this,cb_parallel,wxCheckBox)-SetValue(false); + else + XRCCTRL(*this,cb_parallel,wxCheckBox)-SetValue(true); + i=config-Read(wxT(/BatchFrame/ShutdownCheck), (long)0); + if(i==0) + XRCCTRL(*this,cb_shutdown,wxCheckBox)-SetValue(false); + else + XRCCTRL(*this,cb_shutdown,wxCheckBox)-SetValue(true); + i=config-Read(wxT(/BatchFrame/OverwriteCheck), (long)0); + if(i==0) + XRCCTRL(*this,cb_overwrite,wxCheckBox)-SetValue(false); + else + XRCCTRL(*this,cb_overwrite,wxCheckBox)-SetValue(true); +