Auto merge of #12535 - Manishearth:try-resource, r=KiChjang

Use Result instead of panicking when the resource dir can't be found

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #12520 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because it's a refactoring

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12535)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-07-21 04:08:49 -05:00 committed by GitHub
commit a39bd7db5b
11 changed files with 81 additions and 64 deletions

View file

@ -136,8 +136,6 @@ impl Window {
// #9996.
let visible = is_foreground && !opts::get().no_native_titlebar;
let mut icon_path = resource_files::resources_dir_path();
icon_path.push("servo.png");
let mut builder =
glutin::WindowBuilder::new().with_title("Servo".to_string())
@ -147,8 +145,13 @@ impl Window {
.with_gl(Window::gl_version())
.with_visibility(visible)
.with_parent(parent)
.with_multitouch()
.with_icon(icon_path);
.with_multitouch();
if let Ok(mut icon_path) = resource_files::resources_dir_path() {
icon_path.push("servo.png");
builder = builder.with_icon(icon_path);
}
if opts::get().enable_vsync {
builder = builder.with_vsync();