Fix crash when the input file does not contain any nodeset or edgeset.
authorladanyi
Mon, 19 Dec 2005 16:59:05 +0000
changeset 186715cf1fd6a505
parent 1866 c2de2ed28e59
child 1868 24bf4b8299e7
Fix crash when the input file does not contain any nodeset or edgeset.
gui/mapstorage.cc
     1.1 --- a/gui/mapstorage.cc	Mon Dec 19 14:58:09 2005 +0000
     1.2 +++ b/gui/mapstorage.cc	Mon Dec 19 16:59:05 2005 +0000
     1.3 @@ -212,6 +212,22 @@
     1.4      ContentReader content(lreader);
     1.5      lreader.run();
     1.6  
     1.7 +    if (content.nodeSetNum() < 1)
     1.8 +    {
     1.9 +      Gtk::MessageDialog mdialog("No nodeset found in file.");
    1.10 +      mdialog.run();
    1.11 +      clear();
    1.12 +      return 1;
    1.13 +    }
    1.14 +
    1.15 +    if (content.edgeSetNum() < 1)
    1.16 +    {
    1.17 +      Gtk::MessageDialog mdialog("No edgeset found in file.");
    1.18 +      mdialog.run();
    1.19 +      clear();
    1.20 +      return 1;
    1.21 +    }
    1.22 +
    1.23      const std::vector<std::string>& nodeMapNames = content.nodeSetMaps(0);
    1.24      const std::vector<std::string>& edgeMapNames = content.edgeSetMaps(0);
    1.25  
    1.26 @@ -256,7 +272,7 @@
    1.27      }
    1.28      GuiReader gui_reader(greader, this);
    1.29      greader.run();
    1.30 -  } catch (DataFormatError& error) {
    1.31 +  } catch (Exception& error) {
    1.32      Gtk::MessageDialog mdialog(error.what());
    1.33      mdialog.run();
    1.34      clear();