Skip to content

Commit e998352

Browse files
committed
Fix QT5 compilation errors
1 parent 7f50f8a commit e998352

34 files changed

+6897
-7013
lines changed

src/asciiview.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <fcntl.h>
55
#include <sys/ioctl.h>
66
#include <unistd.h>
7+
#include <QArrayDataPointer>
78

89
QVector<unsigned char> AsciiView::readSMARTData(const QString& device_path) {
910
int fd;
@@ -14,7 +15,12 @@ QVector<unsigned char> AsciiView::readSMARTData(const QString& device_path) {
1415
unsigned char sense_buffer[SENSE_BUFFER_LEN];
1516
sg_io_hdr_t io_hdr;
1617
QVector<unsigned char> result;
18+
1719
fd = open(device_path.toStdString().c_str(), O_RDONLY);
20+
if (fd < 0) {
21+
return result;
22+
}
23+
1824
memset(&io_hdr, 0, sizeof(sg_io_hdr_t));
1925
io_hdr.interface_id = 'S';
2026
io_hdr.cmd_len = SMART_READ_CMD_LEN;
@@ -28,9 +34,11 @@ QVector<unsigned char> AsciiView::readSMARTData(const QString& device_path) {
2834

2935
if (ioctl(fd, SG_IO, &io_hdr) < 0) {
3036
close(fd);
37+
return result;
3138
}
3239

33-
result.append(QArrayDataPointer<unsigned char>::fromRawData(smart_read_resp, SMART_READ_RESP_LEN));
40+
result.resize(SMART_READ_RESP_LEN);
41+
memcpy(result.data(), smart_read_resp, SMART_READ_RESP_LEN);
3442

3543
memset(&io_hdr, 0, sizeof(sg_io_hdr_t));
3644
io_hdr.interface_id = 'S';
@@ -45,9 +53,13 @@ QVector<unsigned char> AsciiView::readSMARTData(const QString& device_path) {
4553

4654
if (ioctl(fd, SG_IO, &io_hdr) < 0) {
4755
close(fd);
56+
return result;
4857
}
4958

50-
result.append(QArrayDataPointer<unsigned char>::fromRawData(inquiry_resp, INQUIRY_RESP_LEN));
59+
int currentSize = result.size();
60+
result.resize(currentSize + INQUIRY_RESP_LEN);
61+
memcpy(result.data() + currentSize, inquiry_resp, INQUIRY_RESP_LEN);
62+
5163
close(fd);
5264
return result;
5365
}

src/gridview.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void GridView::resizeEvent(QResizeEvent *) {
5858
}
5959

6060
void GridView::setDisks(const QVector<DiskItem> &newDisks) {
61-
disks = newDisks;
61+
disks = newDisks.toList();
6262
populateGrid();
6363
}
6464

0 commit comments

Comments
 (0)