Fix uninitialized memory access in toolbar.

pull/387/head
Bauke Conijn 2019-02-19 12:35:56 +01:00 committed by whitequark
parent 8d07a6b4f4
commit 9d1601eea9
2 changed files with 4 additions and 4 deletions

View File

@ -390,6 +390,7 @@ void GraphicsWindow::Init() {
showSnapGrid = false; showSnapGrid = false;
context.active = false; context.active = false;
toolbarHovered = Command::NONE;
if(!window) { if(!window) {
window = Platform::CreateWindow(); window = Platform::CreateWindow();

View File

@ -154,6 +154,9 @@ bool GraphicsWindow::ToolbarDrawOrHitTest(int mx, int my,
bool withinToolbar = bool withinToolbar =
(mx >= aleft && mx <= aright && my <= atop && my >= abot); (mx >= aleft && mx <= aright && my <= atop && my >= abot);
// Initialize/clear menuHit.
if(menuHit) *menuHit = Command::NONE;
if(!canvas && !withinToolbar) { if(!canvas && !withinToolbar) {
// This gets called every MouseMove event, so return quickly. // This gets called every MouseMove event, so return quickly.
@ -224,9 +227,5 @@ bool GraphicsWindow::ToolbarDrawOrHitTest(int mx, int my,
} }
} }
if(!withinToolbar) {
if(menuHit) *menuHit = Command::NONE;
}
return withinToolbar; return withinToolbar;
} }