Skip to content

Commit

Permalink
Replace QString::sprintf with QString::asprintf
Browse files Browse the repository at this point in the history
`QString::sprintf` was deprecated in Qt 5.14, so replace uses with
the static `QString::asprintf` method. This addresses the following
warning:

```
  ../source/view/geniedialog.cc:102:17: warning: 'sprintf' is deprecated: Use asprintf(), arg() or QTextStream instead [-Wdeprecated-declarations]
              str.sprintf("%02X", rawcode.getValue());
                  ^
  /opt/local/libexec/qt5/lib/QtCore.framework/Headers/qstring.h:392:5: note: 'sprintf' has been explicitly marked deprecated here
      QT_DEPRECATED_X("Use asprintf(), arg() or QTextStream instead")
      ^
  /opt/local/libexec/qt5/lib/QtCore.framework/Headers/qglobal.h:294:33: note: expanded from macro 'QT_DEPRECATED_X'
  #  define QT_DEPRECATED_X(text) Q_DECL_DEPRECATED_X(text)
                                  ^
  /opt/local/libexec/qt5/lib/QtCore.framework/Headers/qcompilerdetection.h:675:55: note: expanded from macro 'Q_DECL_DEPRECATED_X'
  #    define Q_DECL_DEPRECATED_X(text) __attribute__ ((__deprecated__(text)))
```
  • Loading branch information
msbit committed Sep 9, 2022
1 parent ae7c47a commit e390110
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions source/view/geniedialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ void GenieDialog::decode() {
NESGameGenieCode ggcode = NESGameGenieCode::create(text);
NESRawCode rawcode = Decoder::decodeNES(ggcode);

str.sprintf("%02X", rawcode.getValue());
str = QString::asprintf("%02X", rawcode.getValue());
ui.valueEdit->setText(str);

str.sprintf("%04X", rawcode.getAddress());
str = QString::asprintf("%04X", rawcode.getAddress());
ui.addressEdit->setText(str);

if (rawcode.hasCompare()) {
str.sprintf("%02X", rawcode.getCompare());
str = QString::asprintf("%02X", rawcode.getCompare());
ui.compareEdit->setText(str);
} else {
ui.compareEdit->clear();
Expand All @@ -115,32 +115,32 @@ void GenieDialog::decode() {
SNESGameGenieCode ggcode = SNESGameGenieCode::create(text);
SNESRawCode rawcode = Decoder::decodeSNES(ggcode);

str.sprintf("%02X", rawcode.getValue());
str = QString::asprintf("%02X", rawcode.getValue());
ui.valueEdit->setText(str);

str.sprintf("%04X", rawcode.getAddress());
str = QString::asprintf("%04X", rawcode.getAddress());
ui.addressEdit->setText(str);
} else if (system == GENESIS) {
GenesisGameGenieCode ggcode = GenesisGameGenieCode::create(text);
GenesisRawCode rawcode = Decoder::decodeGenesis(ggcode);

str.sprintf("%04X", rawcode.getValue());
str = QString::asprintf("%04X", rawcode.getValue());
ui.valueEdit->setText(str);

str.sprintf("%04X", rawcode.getAddress());
str = QString::asprintf("%04X", rawcode.getAddress());
ui.addressEdit->setText(str);
} else if (system == GBGG) {
GBGGGameGenieCode ggcode = GBGGGameGenieCode::create(text);
GBGGRawCode rawcode = Decoder::decodeGBGG(ggcode);

str.sprintf("%02X", rawcode.getValue());
str = QString::asprintf("%02X", rawcode.getValue());
ui.valueEdit->setText(str);

str.sprintf("%04X", rawcode.getAddress());
str = QString::asprintf("%04X", rawcode.getAddress());
ui.addressEdit->setText(str);

if (rawcode.hasCompare()) {
str.sprintf("%02X", rawcode.getCompare());
str = QString::asprintf("%02X", rawcode.getCompare());
ui.compareEdit->setText(str);
} else {
ui.compareEdit->clear();
Expand Down

0 comments on commit e390110

Please sign in to comment.