From: <gpa...@us...> - 2008-07-18 03:24:49
|
Revision: 3205 http://hugin.svn.sourceforge.net/hugin/?rev=3205&view=rev Author: gpatters1 Date: 2008-07-18 03:24:44 +0000 (Fri, 18 Jul 2008) Log Message: ----------- [2000096] Fix for crash when redo-ing a load project. Modified Paths: -------------- hugin/trunk/src/hugin1/PT/PanoCommand.h hugin/trunk/src/hugin1/hugin/MainFrame.cpp hugin/trunk/src/hugin1/hugin/wxPanoCommand.cpp hugin/trunk/src/hugin1/hugin/wxPanoCommand.h Modified: hugin/trunk/src/hugin1/PT/PanoCommand.h =================================================================== --- hugin/trunk/src/hugin1/PT/PanoCommand.h 2008-07-18 03:13:14 UTC (rev 3204) +++ hugin/trunk/src/hugin1/PT/PanoCommand.h 2008-07-18 03:24:44 UTC (rev 3205) @@ -1217,14 +1217,15 @@ class LoadPTProjectCmd : public PanoCommand { public: - LoadPTProjectCmd(Panorama & p, std::istream & i, const std::string & prefix = "") + LoadPTProjectCmd(Panorama & p, const std::string & filename, const std::string & prefix = "") : PanoCommand(p), - in(i), - prefix(prefix) + filename(filename), + prefix(prefix) { } virtual bool processPanorama(Panorama& pano) { + std::ifstream in(filename.c_str()); #ifndef _Hgn1_PANORAMA_H PanoramaMemento newPano; if (newPano.loadPTScript(in,prefix)) { @@ -1240,6 +1241,7 @@ } #endif + in.close(); pano.changeFinished(); return true; @@ -1251,7 +1253,7 @@ } private: - std::istream & in; + const std::string &filename; const std::string &prefix; }; Modified: hugin/trunk/src/hugin1/hugin/MainFrame.cpp =================================================================== --- hugin/trunk/src/hugin1/hugin/MainFrame.cpp 2008-07-18 03:13:14 UTC (rev 3204) +++ hugin/trunk/src/hugin1/hugin/MainFrame.cpp 2008-07-18 03:24:44 UTC (rev 3205) @@ -623,27 +623,23 @@ { DEBUG_TRACE(""); m_filename = filename; + // remove old images from cache // hmm probably not a good idea, if the project is reloaded.. - //ImageCache::getInstance().flush(); + // ImageCache::getInstance().flush(); - wxFileName fname(filename); - wxString path = fname.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR); - SetStatusText( _("Open project: ") + filename); - // get the global config object - wxConfigBase* config = wxConfigBase::Get(); - std::ifstream file((const char *)filename.mb_str(HUGIN_CONV_FILENAME)); - if (file.good()) { + wxFileName fname(filename); + wxString path = fname.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR); + if (fname.IsOk() && fname.FileExists()) { wxBusyCursor wait; GlobalCmdHist::getInstance().addCommand( - new wxLoadPTProjectCmd(pano,file, (const char *)path.mb_str(HUGIN_CONV_FILENAME)) - ); + new wxLoadPTProjectCmd(pano,(const char *)filename.mb_str(HUGIN_CONV_FILENAME), (const char *)path.mb_str(HUGIN_CONV_FILENAME)) + ); DEBUG_DEBUG("project contains " << pano.getNrOfImages() << " after load"); opt_panel->setModeCustom(); SetStatusText(_("Project opened")); - config->Write(wxT("/actualPath"), path); // remember for later this->SetTitle(fname.GetName() + wxT(".") + fname.GetExt() + wxT(" - hugin")); if (! (fname.GetExt() == wxT("pto"))) { // do not remember filename if its not a hugin project @@ -651,6 +647,9 @@ // incompatible one m_filename = wxT(""); } + // get the global config object + wxConfigBase* config = wxConfigBase::Get(); + config->Write(wxT("/actualPath"), path); // remember for later } else { SetStatusText( _("Error opening project: ") + filename); DEBUG_ERROR("Could not open file " << filename); Modified: hugin/trunk/src/hugin1/hugin/wxPanoCommand.cpp =================================================================== --- hugin/trunk/src/hugin1/hugin/wxPanoCommand.cpp 2008-07-18 03:13:14 UTC (rev 3204) +++ hugin/trunk/src/hugin1/hugin/wxPanoCommand.cpp 2008-07-18 03:24:44 UTC (rev 3205) @@ -307,6 +307,7 @@ PanoramaMemento newPano; int ptoVersion = 0; + std::ifstream in(filename.c_str()); if (newPano.loadPTScript(in, ptoVersion, prefix)) { pano.setMemento(newPano); PanoramaOptions opts = pano.getOptions(); @@ -407,6 +408,7 @@ } else { DEBUG_ERROR("could not load panotools script"); } + in.close(); pano.changeFinished(); } Modified: hugin/trunk/src/hugin1/hugin/wxPanoCommand.h =================================================================== --- hugin/trunk/src/hugin1/hugin/wxPanoCommand.h 2008-07-18 03:13:14 UTC (rev 3204) +++ hugin/trunk/src/hugin1/hugin/wxPanoCommand.h 2008-07-18 03:24:44 UTC (rev 3205) @@ -72,9 +72,9 @@ class wxLoadPTProjectCmd : public PanoCommand { public: - wxLoadPTProjectCmd(Panorama & p, std::istream & i, const std::string & prefix = "") + wxLoadPTProjectCmd(Panorama & p, const std::string filename, const std::string prefix = "") : PanoCommand(p), - in(i), + filename(filename), prefix(prefix) { }; @@ -85,8 +85,8 @@ return "load project"; } private: - std::istream & in; - const std::string &prefix; + const std::string filename; + const std::string prefix; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |