Fix several compile issues (#261)

Fixed several code issues.  Mostly pedantic compiler warnings.  But also a sign issue exposed by newer compilers (#228, #260)
This commit is contained in:
Jaye Evins
2025-12-06 15:58:38 -05:00
committed by GitHub
parent 44a10fc796
commit b6cac2d208
10 changed files with 41 additions and 18 deletions
+11 -1
View File
@@ -140,7 +140,17 @@ find_package (Qt5Test 5.6 QUIET)
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
#
# Uncomment to compile everything with aggressively pedantic options
# (not recommended -- only for testing -- also not portable)
# (not recommended -- only for testing)
#
#add_compile_options("-Wall" "-Wextra" "-Wpedantic" "-Wno-unused-parameter" "-Werror")
# Uncomment to always compile with debug symbols
add_compile_options("-g")
endif ()
if (${CMAKE_CXX_COMPILER_ID} MATCHES "^.*Clang$") # "Clang", "AppleClang", etc.
#
# Uncomment to compile everything with aggressively pedantic options
# (not recommended -- only for testing)
#
#add_compile_options("-Wall" "-Wextra" "-Wpedantic" "-Wno-unused-parameter" "-Werror")
-3
View File
@@ -28,9 +28,6 @@
namespace
{
const double FONT_SCALE = 0.9;
const int W_PTS_DEFAULT = 144;
const int H_PTS_DEFAULT = 72;
const double TWO_DIVIDED_BY_SQRT3 = 1.15470053837925152902;
}
-2
View File
@@ -36,8 +36,6 @@ namespace glabels
const int wSwatch = 25;
const int hSwatch = 25;
const int hoverBgOutlineWidthPixels = 1;
const int outlineWidthPixels = 1;
}
+2 -1
View File
@@ -823,7 +823,8 @@ namespace glabels
/*
* Calculate new size
*/
double w, h;
double w = 0.0;
double h = 0.0;
switch ( mResizeHandleLocation )
{
case model::Handle::NW:
+3 -3
View File
@@ -130,7 +130,7 @@ namespace glabels
{
model::Settings::setTemplatePickerMode( mode );
for ( unsigned int i = 0; i < count(); i++ )
for ( int i = 0; i < count(); i++ )
{
if (auto* tItem = dynamic_cast<TemplatePickerItem *>(item(i)))
{
@@ -182,7 +182,7 @@ namespace glabels
bool isoMask, bool usMask, bool otherMask,
bool anyCategory, const QStringList& categoryIds )
{
for ( unsigned int i = 0; i < count(); i++ )
for ( int i = 0; i < count(); i++ )
{
if (auto* tItem = dynamic_cast<TemplatePickerItem *>(item(i)))
{
@@ -232,7 +232,7 @@ namespace glabels
///
void TemplatePicker::applyFilter( const QStringList& names )
{
for ( unsigned int i = 0; i < count(); i++ )
for ( int i = 0; i < count(); i++ )
{
if (auto *tItem = dynamic_cast<TemplatePickerItem *>(item(i)))
{
+6
View File
@@ -149,6 +149,9 @@ namespace glabels
case Units::PC:
d = pc();
break;
default:
d = mDPts;
break;
}
return d;
@@ -176,6 +179,9 @@ namespace glabels
case Units::PC:
d = pc();
break;
default:
d = mDPts;
break;
}
return d;
+4 -4
View File
@@ -30,7 +30,7 @@ namespace glabels
{
ParserState::ParserState( const QString& string,
unsigned int pos )
qsizetype pos )
: mString(&string),
mPos( pos )
{
@@ -38,7 +38,7 @@ namespace glabels
QChar
ParserState::operator[]( unsigned int i ) const
ParserState::operator[]( qsizetype i ) const
{
auto ii = mPos + i;
if ( ii < mString->size() )
@@ -55,7 +55,7 @@ namespace glabels
bool
ParserState::isNextSubString( const QString& s ) const
{
for ( unsigned int i = 0; i < s.size(); i++ )
for ( qsizetype i = 0; i < s.size(); i++ )
{
if ( operator[](i) != s[i] ) return false;
}
@@ -78,7 +78,7 @@ namespace glabels
void
ParserState::advanceChars( unsigned int i )
ParserState::advanceChars( qsizetype i )
{
mPos = std::min( mPos + i, mString->size() );
}
+3 -3
View File
@@ -35,15 +35,15 @@ namespace glabels
public:
ParserState() = default;
ParserState( const QString& string,
unsigned int pos = 0 );
qsizetype pos = 0 );
~ParserState() = default;
QChar operator[]( unsigned int i ) const;
QChar operator[]( qsizetype i ) const;
bool isNextSubString( const QString& s ) const;
qsizetype pos() const;
qsizetype charsLeft() const;
void advanceChars( unsigned int i );
void advanceChars( qsizetype i );
private:
+10
View File
@@ -142,6 +142,8 @@ namespace glabels
case Units::PC:
idString = "pc";
break;
default:
idString = "pt";
}
return idString;
@@ -169,6 +171,8 @@ namespace glabels
case Units::PC:
nameString = tr("picas");
break;
default:
nameString = tr("points");
}
return nameString;
@@ -196,6 +200,9 @@ namespace glabels
case Units::PC:
value = 0.01;
break;
default:
value = 0.01;
break;
}
return value;
@@ -223,6 +230,9 @@ namespace glabels
case Units::PC:
digits = 2;
break;
default:
digits = 2;
break;
}
return digits;
+2 -1
View File
@@ -31,7 +31,8 @@ namespace glabels
/// Copy constructor
///
Variables::Variables( const Variables& other )
: QMap<QString,Variable>(other)
: QObject(),
QMap<QString,Variable>(other)
{
}