mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-04 06:12:07 +01:00
Display an error, rather than crashing, if encoding a QR Code failed.
(master workaround inb1a99c3a1f+7261945eb5)
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user