>> 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; i<paths.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 +392,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 +403,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 +847,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);
+       i=config->Read(wxT("/BatchFrame/VerboseCheck"), (long)0);
+       if(i==0)
+               XRCCTRL(*this,"cb_verbose",wxCheckBox)->SetValue(false);
+       else
+               XRCCTRL(*this,"cb_verbose",wxCheckBox)->SetValue(true);
+};
+
 void BatchFrame::RunBatch()
 {
        m_batch->RunBatch();
Index: src/hugin1/ptbatcher/BatchFrame.h
===================================================================
--- src/hugin1/ptbatcher/BatchFrame.h   (Revision 3750)
+++ src/hugin1/ptbatcher/BatchFrame.h   (Arbeitskopie)
@@ -72,6 +72,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
@@ -80,6 +82,9 @@
        void SwapProject(int index);
        //PanoramaOptions readOptions(wxString projectFile);
        void RestoreSize();
+       void AddToList(wxString aFile);
+       void ChangePrefix(int index,wxString newPrefix);
+
        //wxMutex* projListMutex;
        ProjectListBox *projListBox;
 
Index: src/hugin1/ptbatcher/PTBatcherGUI.cpp
===================================================================
--- src/hugin1/ptbatcher/PTBatcherGUI.cpp       (Revision 3750)
+++ src/hugin1/ptbatcher/PTBatcherGUI.cpp       (Arbeitskopie)
@@ -25,6 +25,7 @@
  */
 
 #include "PTBatcherGUI.h"
+#include <wx/stdpaths.h>
 
 // make wxwindows use this class as the main application
 IMPLEMENT_APP(PTBatcherGUI)
@@ -86,21 +87,31 @@
     // 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(".Lock.PTBatcherGUI-%s"), 
wxGetUserId().c_str());
+       m_checker = new wxSingleInstanceChecker(name);
+       bool IsFirstInstance=(!m_checker->IsAnotherRunning());
+       wxString 
fileCommand(wxStandardPaths::Get().GetUserConfigDir()+wxFileName::GetPathSeparator()+_T(".ptbatcher.command"));
+       if(wxFileName::FileExists(fileCommand))
+               wxRemoveFile(fileCommand);
 
-    // 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)
+       {
+               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 +162,19 @@
     } */
 #endif
 
-       m_frame = new BatchFrame(&m_locale,m_xrcPrefix);
-       m_frame->RestoreSize();
-       SetTopWindow(m_frame);
-       m_frame->Show(true);
+       Batch* batch;
+       if(IsFirstInstance)
+       {
+               m_frame = new BatchFrame(&m_locale,m_xrcPrefix);
+               m_frame->RestoreSize();
+               SetTopWindow(m_frame);
+               m_frame->Show(true);
+       }
+       else
+       {
+               batch=new Batch(NULL,wxGetApp().argv[0],false);
+               batch->LoadTemp();
+       };
        //m_frame->SetLocaleAndXRC(&m_locale,m_xrcPrefix);
        //projectsRunning=0;
        unsigned int count = 0;
@@ -167,20 +187,23 @@
                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
+                               batch->AddProjectToBatch(name.GetFullPath());
                        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
+                                       
batch->ChangePrefix(batch->GetProjectCount()-1,fn.GetFullPath());
                                projectSpecified = false;
                        }
                        else
@@ -193,8 +216,10 @@
                                        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
+                                               
batch->ChangePrefix(batch->GetProjectCount()-1,fn.GetFullPath());
                                        projectSpecified = false;
                                }
                                else //if parameter has a different extension 
we presume it is a new script file
@@ -223,72 +248,40 @@
                                        
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
+                                               
batch->AddProjectToBatch(fn.GetFullPath());
                                        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);
+       wxConfigBase *config=wxConfigBase::Get();
+       if (parser.Found(wxT("d"))) 
+               config->Write(wxT("/BatchFrame/DeleteCheck"), 1);
+       if (parser.Found(wxT("p")))
+               config->Write(wxT("/BatchFrame/ParallelCheck"), 1);
+       if (parser.Found(wxT("s")))
+               config->Write(wxT("/BatchFrame/ShutdownCheck"), 1);
+       if (parser.Found(wxT("o")))
+               config->Write(wxT("/BatchFrame/OverwriteCheck"), 1);
+       if (parser.Found(wxT("v")))
+               config->Write(wxT("/BatchFrame/VerboseCheck"), 1);
+       config->Flush();
+       if(!IsFirstInstance)
+       {
+               batch->SaveTemp();
+               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();
+               return false;
+       };
+       m_frame->SetCheckboxes();
        m_frame->PropagateDefaults();
        if (parser.Found(wxT("b")) ) {
                m_frame->RunBatch();
@@ -296,6 +289,12 @@
        return true;
 }
 
+int PTBatcherGUI::OnExit()
+{
+       delete m_checker;
+       return 0;
+}
+
 void PTBatcherGUI::OnItemActivated(wxListEvent &event)
 {
        wxCommandEvent dummy;
Index: src/hugin1/ptbatcher/PTBatcherGUI.h
===================================================================
--- src/hugin1/ptbatcher/PTBatcherGUI.h (Revision 3750)
+++ 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);
@@ -76,6 +78,8 @@
     wxLocale m_locale;
        wxString m_xrcPrefix;
        PTPrograms progs;
+       wxSingleInstanceChecker *m_checker;
+
 #ifdef __WXMAC__
     wxString m_macFileNameToOpenOnStart;
 #endif

Reply via email to