mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-17 10:59:27 +00:00
Display an error, rather than crashing, if encoding a QR Code failed.
(master workaround in b1a99c3a1fb2613e9c7cecd565e8cc604b03eb6f + 7261945eb5f64423d47a5bff63ecd8b65d88b8ed)
This commit is contained in:
parent
760d9480ed
commit
278074eb23
@ -34,6 +34,9 @@
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
||||
@ -39,17 +39,27 @@ void QRCodeDialog::genCode()
|
||||
QString uri = getURI();
|
||||
//qDebug() << "Encoding:" << uri.toUtf8().constData();
|
||||
QRcode *code = QRcode_encodeString(uri.toUtf8().constData(), 0, QR_ECLEVEL_L, QR_MODE_8, 1);
|
||||
myImage = QImage(code->width + 8, code->width + 8, QImage::Format_RGB32);
|
||||
myImage.fill(0xffffff);
|
||||
unsigned char *p = code->data;
|
||||
for(int y = 0; y < code->width; y++) {
|
||||
for(int x = 0; x < code->width; x++) {
|
||||
myImage.setPixel(x + 4, y + 4, ((*p & 1) ? 0x0 : 0xffffff));
|
||||
p++;
|
||||
if (code)
|
||||
{
|
||||
ui->lblQRCode->setText("");
|
||||
|
||||
QRcode *code = QRcode_encodeString(uri.toUtf8().constData(), 0, QR_ECLEVEL_L, QR_MODE_8, 1);
|
||||
myImage = QImage(code->width + 8, code->width + 8, QImage::Format_RGB32);
|
||||
myImage.fill(0xffffff);
|
||||
unsigned char *p = code->data;
|
||||
for (int y = 0; y < code->width; y++)
|
||||
{
|
||||
for (int x = 0; x < code->width; x++)
|
||||
{
|
||||
myImage.setPixel(x + 4, y + 4, ((*p & 1) ? 0x0 : 0xffffff));
|
||||
p++;
|
||||
}
|
||||
}
|
||||
QRcode_free(code);
|
||||
ui->lblQRCode->setPixmap(QPixmap::fromImage(myImage).scaled(300, 300));
|
||||
}
|
||||
QRcode_free(code);
|
||||
ui->lblQRCode->setPixmap(QPixmap::fromImage(myImage).scaled(300, 300));
|
||||
else
|
||||
ui->lblQRCode->setText(tr("Error encoding URI into QR Code; try to reduce the text for label / message."));
|
||||
}
|
||||
|
||||
QString QRCodeDialog::getURI()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user