diff --git a/src/app/ui/color_button.cpp b/src/app/ui/color_button.cpp index 40579b318..4caba893f 100644 --- a/src/app/ui/color_button.cpp +++ b/src/app/ui/color_button.cpp @@ -159,7 +159,12 @@ bool ColorButton::onProcessMessage(Message* msg) gfx::Point screenPos = nativeWindow->pointToScreen(mousePos); Widget* picked = manager()->pickFromScreenPos(screenPos); - IColorSource* colorSource = (picked != this ? dynamic_cast(picked): nullptr); + if (picked == this) { + // Do nothing + break; + } + + IColorSource* colorSource = dynamic_cast(picked); if (colorSource) { nativeWindow = picked->display()->nativeWindow(); mousePos = nativeWindow->pointFromScreen(screenPos); diff --git a/src/app/ui/tile_button.cpp b/src/app/ui/tile_button.cpp index f43c895ef..7658177c0 100644 --- a/src/app/ui/tile_button.cpp +++ b/src/app/ui/tile_button.cpp @@ -96,7 +96,12 @@ bool TileButton::onProcessMessage(Message* msg) // Pick a tile from a ITileSource Widget* picked = window()->pick(mousePos); - ITileSource* tileSource = (picked != this ? dynamic_cast(picked): nullptr); + if (picked == this) { + // Do nothing + break; + } + + ITileSource* tileSource = dynamic_cast(picked); // If there is no tile source in this window, try to get the // tile from other display, i.e. and editor in other native