[Scummvm-cvs-logs] SF.net SVN: scummvm:[46201] tools/branches/gsoc2009-gui/tools_cli.cpp
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Sun Nov 29 19:45:43 CET 2009
Revision: 46201
http://scummvm.svn.sourceforge.net/scummvm/?rev=46201&view=rev
Author: fingolfin
Date: 2009-11-29 18:45:42 +0000 (Sun, 29 Nov 2009)
Log Message:
-----------
Fix bug #2905689: GUI Tools: cannot select tool with CLI
Modified Paths:
--------------
tools/branches/gsoc2009-gui/tools_cli.cpp
Modified: tools/branches/gsoc2009-gui/tools_cli.cpp
===================================================================
--- tools/branches/gsoc2009-gui/tools_cli.cpp 2009-11-29 18:41:06 UTC (rev 46200)
+++ tools/branches/gsoc2009-gui/tools_cli.cpp 2009-11-29 18:45:42 UTC (rev 46201)
@@ -154,19 +154,22 @@
// Read input
std::cin >> i;
- // Valid ?
- if (std::cin && i >= 1 && (size_t)i < choices.size())
+ // Was it an integer and in range?
+ if (std::cin && i >= 1 && (size_t)i <= choices.size())
break;
- // Clear any error flags
- std::cin.clear();
-
- std::string q;
- std::cin >> q;
- if (q == "q" || q == "exit" || q == "quit" || q == "abort")
- return 0;
+ // If it wasn't an integer, trying reading input again, this time as a string.
+ if (!std::cin) {
+ // Clear any error flags
+ std::cin.clear();
+
+ std::string q;
+ std::cin >> q;
+ if (q == "q" || q == "exit" || q == "quit" || q == "abort")
+ return 0;
+ }
- std::cout << "Invalid input, try again: ";
+ std::cout << "Invalid input, try again ('q' to abort): ";
}
// Account for the fact arrays start at 0
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list