Fix possible usage of uninitialized variable in wxQt wxDC code

Make sure rasterColourOp is always initialized, even if none of the
switch cases matches, to avoid warnings about possibly uninitialized
variable.

See https://github.com/wxWidgets/wxWidgets/pull/1048
This commit is contained in:
Jay Nabonne
2018-12-06 11:13:54 +00:00
committed by Vadim Zeitlin
parent 194936ab26
commit 82a66e56b2

View File

@@ -220,7 +220,7 @@ void wxQtDCImpl::SetLogicalFunction(wxRasterOperationMode function)
{ {
m_logicalFunction = function; m_logicalFunction = function;
wxQtRasterColourOp rasterColourOp; wxQtRasterColourOp rasterColourOp = wxQtNONE;
switch ( function ) switch ( function )
{ {
case wxCLEAR: // 0 case wxCLEAR: // 0
@@ -229,7 +229,6 @@ void wxQtDCImpl::SetLogicalFunction(wxRasterOperationMode function)
break; break;
case wxXOR: // src XOR dst case wxXOR: // src XOR dst
m_qtPainter->setCompositionMode( QPainter::RasterOp_SourceXorDestination ); m_qtPainter->setCompositionMode( QPainter::RasterOp_SourceXorDestination );
rasterColourOp = wxQtNONE;
break; break;
case wxINVERT: // NOT dst => dst XOR WHITE case wxINVERT: // NOT dst => dst XOR WHITE
m_qtPainter->setCompositionMode( QPainter::RasterOp_SourceXorDestination ); m_qtPainter->setCompositionMode( QPainter::RasterOp_SourceXorDestination );
@@ -241,35 +240,27 @@ void wxQtDCImpl::SetLogicalFunction(wxRasterOperationMode function)
break; break;
case wxAND_REVERSE: // src AND (NOT dst) case wxAND_REVERSE: // src AND (NOT dst)
m_qtPainter->setCompositionMode( QPainter::RasterOp_SourceAndNotDestination ); m_qtPainter->setCompositionMode( QPainter::RasterOp_SourceAndNotDestination );
rasterColourOp = wxQtNONE;
break; break;
case wxCOPY: // src case wxCOPY: // src
m_qtPainter->setCompositionMode( QPainter::CompositionMode_SourceOver ); m_qtPainter->setCompositionMode( QPainter::CompositionMode_SourceOver );
rasterColourOp = wxQtNONE;
break; break;
case wxAND: // src AND dst case wxAND: // src AND dst
m_qtPainter->setCompositionMode( QPainter::RasterOp_SourceAndDestination ); m_qtPainter->setCompositionMode( QPainter::RasterOp_SourceAndDestination );
rasterColourOp = wxQtNONE;
break; break;
case wxAND_INVERT: // (NOT src) AND dst case wxAND_INVERT: // (NOT src) AND dst
m_qtPainter->setCompositionMode( QPainter::RasterOp_NotSourceAndDestination ); m_qtPainter->setCompositionMode( QPainter::RasterOp_NotSourceAndDestination );
rasterColourOp = wxQtNONE;
break; break;
case wxNO_OP: // dst case wxNO_OP: // dst
m_qtPainter->setCompositionMode( QPainter::CompositionMode_DestinationOver ); m_qtPainter->setCompositionMode( QPainter::CompositionMode_DestinationOver );
rasterColourOp = wxQtNONE;
break; break;
case wxNOR: // (NOT src) AND (NOT dst) case wxNOR: // (NOT src) AND (NOT dst)
m_qtPainter->setCompositionMode( QPainter::RasterOp_NotSourceAndNotDestination ); m_qtPainter->setCompositionMode( QPainter::RasterOp_NotSourceAndNotDestination );
rasterColourOp = wxQtNONE;
break; break;
case wxEQUIV: // (NOT src) XOR dst case wxEQUIV: // (NOT src) XOR dst
m_qtPainter->setCompositionMode( QPainter::RasterOp_NotSourceXorDestination ); m_qtPainter->setCompositionMode( QPainter::RasterOp_NotSourceXorDestination );
rasterColourOp = wxQtNONE;
break; break;
case wxSRC_INVERT: // (NOT src) case wxSRC_INVERT: // (NOT src)
m_qtPainter->setCompositionMode( QPainter::RasterOp_NotSource ); m_qtPainter->setCompositionMode( QPainter::RasterOp_NotSource );
rasterColourOp = wxQtNONE;
break; break;
case wxOR_INVERT: // (NOT src) OR dst case wxOR_INVERT: // (NOT src) OR dst
m_qtPainter->setCompositionMode( QPainter::RasterOp_SourceOrDestination ); m_qtPainter->setCompositionMode( QPainter::RasterOp_SourceOrDestination );
@@ -277,11 +268,9 @@ void wxQtDCImpl::SetLogicalFunction(wxRasterOperationMode function)
break; break;
case wxNAND: // (NOT src) OR (NOT dst) case wxNAND: // (NOT src) OR (NOT dst)
m_qtPainter->setCompositionMode( QPainter::RasterOp_NotSourceOrNotDestination ); m_qtPainter->setCompositionMode( QPainter::RasterOp_NotSourceOrNotDestination );
rasterColourOp = wxQtNONE;
break; break;
case wxOR: // src OR dst case wxOR: // src OR dst
m_qtPainter->setCompositionMode( QPainter::RasterOp_SourceOrDestination ); m_qtPainter->setCompositionMode( QPainter::RasterOp_SourceOrDestination );
rasterColourOp = wxQtNONE;
break; break;
case wxSET: // 1 case wxSET: // 1
m_qtPainter->setCompositionMode( QPainter::CompositionMode_SourceOver ); m_qtPainter->setCompositionMode( QPainter::CompositionMode_SourceOver );