[Viewer] Set the current slide first before attaching the fBackendType to fWindow.
If call attach() first, Viewer::onBackendCreated() calls Window::show().
When WM_PAINT occurs, Viewer::drawSlide() is called, where a crash occurs using an uninitialized fCurrentSlide.
Bug: skia:https://bugs.chromium.org/p/skia/issues/detail?id=8792
Change-Id: I22ba6479052cb66e08d8bc2a94539473e899b604
Reviewed-on: https://skia-review.googlesource.com/c/195240
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/tools/viewer/Viewer.cpp b/tools/viewer/Viewer.cpp
index 8752a27..f71dd65 100644
--- a/tools/viewer/Viewer.cpp
+++ b/tools/viewer/Viewer.cpp
@@ -524,8 +524,8 @@
fImGuiGamutPaint.setColor(SK_ColorWHITE);
fImGuiGamutPaint.setFilterQuality(kLow_SkFilterQuality);
- fWindow->attach(backend_type_for_window(fBackendType));
this->setCurrentSlide(this->startupSlide());
+ fWindow->attach(backend_type_for_window(fBackendType));
}
void Viewer::initSlides() {