Hello,
thanks to Yuv the bug 2292979 came to my attention so I can take a
look at it. Result? I've fixed it. Luckily it wasn't tough bug.

Fix is divided to more files, which two of them are in fact doing the
same thing with a little bit different approach, so I'm going to
describe them.

PanoramaMakefileExport.diff
removes now unnesary ifdefs in pt.mk file

huginConfig_v1.diff
Actually the fix to problem. I've used exception to control if enblend
(or any other program) is defined in config file.
Then assigning application names is put into try block. It's plus is
that it's easy to understand and well arranged.
The main drawback of this solution is that it prints warning only for
first undefined application (which actually is enblend).

huginConfig_v1.diff
This solution also uses exceptions, but in this case every assignment
has it's own try catch block.
It's not so readable, but it prints more warnings if there are more
undefined apps. Personaly I prefer this solution,
because it warns user about all problems and not only about the first one.


PS.: Other solution could be making hugin not to save anything when
cancel is pressed (so it wouldn't generate broken config)
but this is more "bulletproof" solution, because it could also handle
improper user input or manual changes in configuration.
The best would be to combine this two – saving only correct
configuration and checking configuration if it's really valid.
Unfortunately I don't know how to do this. I'm not even sure if it's
problem of hugin because it seems that writing configuration is
handled by wxwidgets itself.

--~--~---------~--~----~------------~-------~--~----~
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/hugin_base/algorithms/panorama_makefile/PanoramaMakefileExport.cpp
===================================================================
--- src/hugin_base/algorithms/panorama_makefile/PanoramaMakefileExport.cpp    (revision 3590)
+++ src/hugin_base/algorithms/panorama_makefile/PanoramaMakefileExport.cpp    (working copy)
@@ -193,14 +193,15 @@
       << "EXIFTOOL=" << quoteStringShell(progs.exiftool) << endl
 #endif
       << endl
-      << "ifndef ENBLEND" << endl
-      << "  ENBLEND=false" << endl
-      << "endif" << endl 
-      << endl
-      << "ifndef ENFUSE" << endl
-      << "  ENFUSE=false" << endl
-      << "endif" << endl
-      << endl
+// This is completely unnecessary because it should be handled by default values in struct progs
+//      << "ifndef ENBLEND" << endl
+//      << "  ENBLEND=false" << endl
+//      << "endif" << endl 
+//      << endl
+//      << "ifndef ENFUSE" << endl
+//      << "  ENFUSE=false" << endl
+//      << "endif" << endl
+//      << endl
 
       << "# options for the programs" << endl << endl;
 
Index: src/hugin1/base_wx/huginConfig.cpp
===================================================================
--- src/hugin1/base_wx/huginConfig.cpp	(revision 3590)
+++ src/hugin1/base_wx/huginConfig.cpp	(working copy)
@@ -33,11 +33,11 @@
 
 using namespace PT;
 
-std::string getProgram(wxConfigBase * config, wxString bindir, wxString file, wxString name)
+std::string getProgram(wxConfigBase * config, wxString bindir, wxString file, wxString name) throw (wxString)
 {
     std::string pname;
 #if defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
-    
+
     if (config->Read(name + wxT("/Custom"), 0l)) {
         wxString fn = config->Read(name + wxT("/Exe"),wxT(""));
         if (wxFileName::FileExists(fn)) {
@@ -59,11 +59,11 @@
         }
         return pname;
     }
-        
+
     CFStringRef filename = MacCreateCFStringWithWxString(file);
     wxString fn = MacGetPathToBundledExecutableFile(filename);
     CFRelease(filename);
-    
+
     if(fn == wxT(""))
     {
         wxMessageBox(wxString::Format(_("External program %s not found in the bundle, reverting to system path"), file.c_str()), _("Error"));
@@ -91,6 +91,8 @@
     if (config->Read(name + wxT("/Custom"), 0l)) {
         wxString fn = config->Read(name + wxT("/Exe"),wxT(""));
         pname = fn.mb_str(HUGIN_CONV_FILENAME);
+        if (pname == "")
+            throw wxString::Format(_("Program %s not found in preferences, reverting to default value"), file.c_str());
         return pname;
 	// TODO: need to search path, a simple FileExists() doesn't work as expected.
 	/*
@@ -103,6 +105,8 @@
 	*/
     }
     pname = file.mb_str(HUGIN_CONV_FILENAME);
+    if (pname == "")
+        throw wxString::Format(_("Program %s not found in preferences, reverting to default value"), file.c_str());
     return pname;
 #endif
 }
@@ -119,25 +123,29 @@
     bindir =  bindirFN.GetPath();
 #endif
 
-    progs.nona = getProgram(config,bindir, wxT("nona"), wxT("nona"));
-    progs.hdrmerge= getProgram(config,bindir, wxT("hugin_hdrmerge"), wxT("hugin_hdrmerge"));
+    try {
+        progs.nona = getProgram(config,bindir, wxT("nona"), wxT("nona"));
+        progs.hdrmerge= getProgram(config,bindir, wxT("hugin_hdrmerge"), wxT("hugin_hdrmerge"));
 
-    progs.PTmender = getProgram(config,bindir, wxT("PTmender"), wxT("PTmender"));
-    progs.PTblender= getProgram(config,bindir, wxT("PTblender"), wxT("PTblender"));
-    progs.PTmasker= getProgram(config,bindir, wxT("PTmasker"), wxT("PTmasker"));
-    progs.PTroller= getProgram(config,bindir, wxT("PTroller"), wxT("PTroller"));
+        progs.PTmender = getProgram(config,bindir, wxT("PTmender"), wxT("PTmender"));
+        progs.PTblender= getProgram(config,bindir, wxT("PTblender"), wxT("PTblender"));
+        progs.PTmasker= getProgram(config,bindir, wxT("PTmasker"), wxT("PTmasker"));
+        progs.PTroller= getProgram(config,bindir, wxT("PTroller"), wxT("PTroller"));
 
-    progs.enblend = getProgram(config,bindir, wxT("enblend"), wxT("Enblend"));
-    progs.enblend_opts = config->Read(wxT("/Enblend/Args"), wxT(HUGIN_ENBLEND_ARGS)).mb_str(wxConvLocal);
-    progs.enfuse = getProgram(config,bindir, wxT("enfuse"), wxT("Enfuse"));
-    progs.enfuse_opts = config->Read(wxT("/Enfuse/Args"), wxT(HUGIN_ENFUSE_ARGS)).mb_str(wxConvLocal);
+        progs.enblend = getProgram(config,bindir, wxT("enblend"), wxT("Enblend"));
+        progs.enblend_opts = config->Read(wxT("/Enblend/Args"), wxT(HUGIN_ENBLEND_ARGS)).mb_str(wxConvLocal);
+        progs.enfuse = getProgram(config,bindir, wxT("enfuse"), wxT("Enfuse"));
+        progs.enfuse_opts = config->Read(wxT("/Enfuse/Args"), wxT(HUGIN_ENFUSE_ARGS)).mb_str(wxConvLocal);
 
-    progs.exiftool = getProgram(config,bindir, wxT("exiftool"), wxT("Exiftool"));
-    progs.exiftool_opts = config->Read(wxT("/Exiftool/CopyArgs"), wxT(HUGIN_EXIFTOOL_COPY_ARGS)).mb_str(wxConvLocal);
+        progs.exiftool = getProgram(config,bindir, wxT("exiftool"), wxT("Exiftool"));
+        progs.exiftool_opts = config->Read(wxT("/Exiftool/CopyArgs"), wxT(HUGIN_EXIFTOOL_COPY_ARGS)).mb_str(wxConvLocal);
 
-    // smartblend (never bundled)
-    progs.smartblend = config->Read(wxT("/Smartblend/SmartblendExe"),wxT("smartblend.exe")).mb_str(HUGIN_CONV_FILENAME);
-    progs.smartblend_opts = config->Read(wxT("/Smartblend/SmartblendArgs"),wxT(HUGIN_SMARTBLEND_ARGS)).mb_str(wxConvLocal);
+        // smartblend (never bundled)
+        progs.smartblend = config->Read(wxT("/Smartblend/SmartblendExe"),wxT("smartblend.exe")).mb_str(HUGIN_CONV_FILENAME);
+        progs.smartblend_opts = config->Read(wxT("/Smartblend/SmartblendArgs"),wxT(HUGIN_SMARTBLEND_ARGS)).mb_str(wxConvLocal);
+    } catch (wxString s) {
+        wxMessageBox(s, _("Warning"));
+    }
 
     return progs;
 }
Index: src/hugin1/base_wx/huginConfig.cpp
===================================================================
--- src/hugin1/base_wx/huginConfig.cpp    (revision 3585)
+++ src/hugin1/base_wx/huginConfig.cpp    (working copy)
@@ -33,11 +33,11 @@
 
 using namespace PT;
 
-std::string getProgram(wxConfigBase * config, wxString bindir, wxString file, wxString name)
+std::string getProgram(wxConfigBase * config, wxString bindir, wxString file, wxString name) throw (wxString)
 {
     std::string pname;
 #if defined __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
-    
+
     if (config->Read(name + wxT("/Custom"), 0l)) {
         wxString fn = config->Read(name + wxT("/Exe"),wxT(""));
         if (wxFileName::FileExists(fn)) {
@@ -59,11 +59,11 @@
         }
         return pname;
     }
-        
+
     CFStringRef filename = MacCreateCFStringWithWxString(file);
     wxString fn = MacGetPathToBundledExecutableFile(filename);
     CFRelease(filename);
-    
+
     if(fn == wxT(""))
     {
         wxMessageBox(wxString::Format(_("External program %s not found in the bundle, reverting to system path"), file.c_str()), _("Error"));
@@ -91,6 +91,8 @@
     if (config->Read(name + wxT("/Custom"), 0l)) {
         wxString fn = config->Read(name + wxT("/Exe"),wxT(""));
         pname = fn.mb_str(HUGIN_CONV_FILENAME);
+        if (pname == "")
+            throw wxString::Format(_("Program %s not found in preferences, reverting to default value"), file.c_str());
         return pname;
     // TODO: need to search path, a simple FileExists() doesn't work as expected.
     /*
@@ -103,6 +105,8 @@
     */
     }
     pname = file.mb_str(HUGIN_CONV_FILENAME);
+    if (pname == "")
+        throw wxString::Format(_("Program %s not found in preferences, reverting to default value"), file.c_str());
     return pname;
 #endif
 }
@@ -119,25 +123,81 @@
     bindir =  bindirFN.GetPath();
 #endif
 
-    progs.nona = getProgram(config,bindir, wxT("nona"), wxT("nona"));
-    progs.hdrmerge= getProgram(config,bindir, wxT("hugin_hdrmerge"), wxT("hugin_hdrmerge"));
+    try {
+        progs.nona = getProgram(config,bindir, wxT("nona"), wxT("nona"));
+    } catch (wxString s) {
+        wxMessageBox(s, _("Warning"));
+    }
+    try {
+        progs.hdrmerge= getProgram(config,bindir, wxT("hugin_hdrmerge"), wxT("hugin_hdrmerge"));
+    } catch (wxString s) {
+        wxMessageBox(s, _("Warning"));
+    }
 
-    progs.PTmender = getProgram(config,bindir, wxT("PTmender"), wxT("PTmender"));
-    progs.PTblender= getProgram(config,bindir, wxT("PTblender"), wxT("PTblender"));
-    progs.PTmasker= getProgram(config,bindir, wxT("PTmasker"), wxT("PTmasker"));
-    progs.PTroller= getProgram(config,bindir, wxT("PTroller"), wxT("PTroller"));
+    try {
+        progs.PTmender = getProgram(config,bindir, wxT("PTmender"), wxT("PTmender"));
+    } catch (wxString s) {
+        wxMessageBox(s, _("Warning"));
+    }
+    try {
+        progs.PTblender= getProgram(config,bindir, wxT("PTblender"), wxT("PTblender"));
+    } catch (wxString s) {
+        wxMessageBox(s, _("Warning"));
+    }
+    try {
+        progs.PTmasker= getProgram(config,bindir, wxT("PTmasker"), wxT("PTmasker"));
+    } catch (wxString s) {
+        wxMessageBox(s, _("Warning"));
+    }
+    try {
+        progs.PTroller= getProgram(config,bindir, wxT("PTroller"), wxT("PTroller"));
+    } catch (wxString s) {
+        wxMessageBox(s, _("Warning"));
+    }
 
-    progs.enblend = getProgram(config,bindir, wxT("enblend"), wxT("Enblend"));
-    progs.enblend_opts = config->Read(wxT("/Enblend/Args"), wxT(HUGIN_ENBLEND_ARGS)).mb_str(wxConvLocal);
-    progs.enfuse = getProgram(config,bindir, wxT("enfuse"), wxT("Enfuse"));
-    progs.enfuse_opts = config->Read(wxT("/Enfuse/Args"), wxT(HUGIN_ENFUSE_ARGS)).mb_str(wxConvLocal);
+    try {
+        progs.enblend = getProgram(config,bindir, wxT("enblend"), wxT("Enblend"));
+    } catch (wxString s) {
+        wxMessageBox(s, _("Warning"));
+    }
+    try {
+        progs.enblend_opts = config->Read(wxT("/Enblend/Args"), wxT(HUGIN_ENBLEND_ARGS)).mb_str(wxConvLocal);
+    } catch (wxString s) {
+        wxMessageBox(s, _("Warning"));
+    }
+    try {
+        progs.enfuse = getProgram(config,bindir, wxT("enfuse"), wxT("Enfuse"));
+    } catch (wxString s) {
+        wxMessageBox(s, _("Warning"));
+    }
+    try {
+        progs.enfuse_opts = config->Read(wxT("/Enfuse/Args"), wxT(HUGIN_ENFUSE_ARGS)).mb_str(wxConvLocal);
+    } catch (wxString s) {
+        wxMessageBox(s, _("Warning"));
+    }
 
-    progs.exiftool = getProgram(config,bindir, wxT("exiftool"), wxT("Exiftool"));
-    progs.exiftool_opts = config->Read(wxT("/Exiftool/CopyArgs"), wxT(HUGIN_EXIFTOOL_COPY_ARGS)).mb_str(wxConvLocal);
+    try {
+        progs.exiftool = getProgram(config,bindir, wxT("exiftool"), wxT("Exiftool"));
+    } catch (wxString s) {
+        wxMessageBox(s, _("Warning"));
+    }
+    try {
+        progs.exiftool_opts = config->Read(wxT("/Exiftool/CopyArgs"), wxT(HUGIN_EXIFTOOL_COPY_ARGS)).mb_str(wxConvLocal);
+    } catch (wxString s) {
+        wxMessageBox(s, _("Warning"));
+    }
 
     // smartblend (never bundled)
-    progs.smartblend = config->Read(wxT("/Smartblend/SmartblendExe"),wxT("smartblend.exe")).mb_str(HUGIN_CONV_FILENAME);
-    progs.smartblend_opts = config->Read(wxT("/Smartblend/SmartblendArgs"),wxT(HUGIN_SMARTBLEND_ARGS)).mb_str(wxConvLocal);
+    try {
+        progs.smartblend = config->Read(wxT("/Smartblend/SmartblendExe"),wxT("smartblend.exe")).mb_str(HUGIN_CONV_FILENAME);
+    } catch (wxString s) {
+        wxMessageBox(s, _("Warning"));
+    }
+    try {
+        progs.smartblend_opts = config->Read(wxT("/Smartblend/SmartblendArgs"),wxT(HUGIN_SMARTBLEND_ARGS)).mb_str(wxConvLocal);
+    } catch (wxString s) {
+        wxMessageBox(s, _("Warning"));
+    }
 
     return progs;
 }

Reply via email to