Merge pull request #8789 from JosJuice/windows-cmake-errors

Fix Windows CMake build errors
This commit is contained in:
Léo Lam 2020-05-03 15:33:58 +02:00 committed by GitHub
commit 1b26929119
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 29 deletions

View File

@ -139,26 +139,26 @@ void VerifyWidget::Verify()
progress.GetRaw()->setMinimumDuration(500); progress.GetRaw()->setMinimumDuration(500);
progress.GetRaw()->setWindowModality(Qt::WindowModal); progress.GetRaw()->setWindowModality(Qt::WindowModal);
auto future = auto future = std::async(
std::async(std::launch::async, std::launch::async,
[&verifier, &progress]() -> std::optional<DiscIO::VolumeVerifier::Result> { [&verifier, &progress, DIVISOR]() -> std::optional<DiscIO::VolumeVerifier::Result> {
progress.SetValue(0); progress.SetValue(0);
verifier.Start(); verifier.Start();
while (verifier.GetBytesProcessed() != verifier.GetTotalBytes()) while (verifier.GetBytesProcessed() != verifier.GetTotalBytes())
{ {
progress.SetValue(static_cast<int>(verifier.GetBytesProcessed() / DIVISOR)); progress.SetValue(static_cast<int>(verifier.GetBytesProcessed() / DIVISOR));
if (progress.WasCanceled()) if (progress.WasCanceled())
return std::nullopt; return std::nullopt;
verifier.Process(); verifier.Process();
} }
verifier.Finish(); verifier.Finish();
const DiscIO::VolumeVerifier::Result result = verifier.GetResult(); const DiscIO::VolumeVerifier::Result result = verifier.GetResult();
progress.Reset(); progress.Reset();
return result; return result;
}); });
progress.GetRaw()->exec(); progress.GetRaw()->exec();
std::optional<DiscIO::VolumeVerifier::Result> result = future.get(); std::optional<DiscIO::VolumeVerifier::Result> result = future.get();

View File

@ -194,11 +194,20 @@ void CodeViewWidget::FontBasedSizing()
constexpr int extra_text_width = 8; constexpr int extra_text_width = 8;
const QFontMetrics fm(Settings::Instance().GetDebugFont()); const QFontMetrics fm(Settings::Instance().GetDebugFont());
const auto width = [&fm](QString text) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
return fm.horizontalAdvance(text);
#else
return fm.width(text);
#endif
};
const int rowh = fm.height() + 1; const int rowh = fm.height() + 1;
verticalHeader()->setMaximumSectionSize(rowh); verticalHeader()->setMaximumSectionSize(rowh);
horizontalHeader()->setMinimumSectionSize(rowh + 5); horizontalHeader()->setMinimumSectionSize(rowh + 5);
setColumnWidth(CODE_VIEW_COLUMN_BREAKPOINT, rowh + 5); setColumnWidth(CODE_VIEW_COLUMN_BREAKPOINT, rowh + 5);
setColumnWidth(CODE_VIEW_COLUMN_ADDRESS, fm.width(QStringLiteral("80000000")) + extra_text_width); setColumnWidth(CODE_VIEW_COLUMN_ADDRESS, width(QStringLiteral("80000000")) + extra_text_width);
// The longest instruction is technically 'ps_merge00' (0x10000420u), but those instructions are // The longest instruction is technically 'ps_merge00' (0x10000420u), but those instructions are
// very rare and would needlessly increase the column size, so let's go with 'rlwinm.' instead. // very rare and would needlessly increase the column size, so let's go with 'rlwinm.' instead.
@ -210,11 +219,10 @@ void CodeViewWidget::FontBasedSizing()
const std::string ins = (split == std::string::npos ? disas : disas.substr(0, split)); const std::string ins = (split == std::string::npos ? disas : disas.substr(0, split));
const std::string param = (split == std::string::npos ? "" : disas.substr(split + 1)); const std::string param = (split == std::string::npos ? "" : disas.substr(split + 1));
setColumnWidth(CODE_VIEW_COLUMN_INSTRUCTION, setColumnWidth(CODE_VIEW_COLUMN_INSTRUCTION,
fm.width(QString::fromStdString(ins)) + extra_text_width); width(QString::fromStdString(ins)) + extra_text_width);
setColumnWidth(CODE_VIEW_COLUMN_PARAMETERS, setColumnWidth(CODE_VIEW_COLUMN_PARAMETERS,
fm.width(QString::fromStdString(param)) + extra_text_width); width(QString::fromStdString(param)) + extra_text_width);
setColumnWidth(CODE_VIEW_COLUMN_DESCRIPTION, setColumnWidth(CODE_VIEW_COLUMN_DESCRIPTION, width(QStringLiteral("0")) * 25 + extra_text_width);
fm.width(QStringLiteral("0")) * 25 + extra_text_width);
Update(); Update();
} }

View File

@ -90,6 +90,16 @@ QTableWidgetItem* GetSocketState(s32 host_fd)
return new QTableWidgetItem(QTableWidget::tr("Unbound")); return new QTableWidgetItem(QTableWidget::tr("Unbound"));
} }
static QString GetAddressAndPort(const sockaddr_in& addr)
{
char buffer[16];
const char* addr_str = inet_ntop(AF_INET, &addr.sin_addr, buffer, sizeof(buffer));
if (!addr_str)
return {};
return QStringLiteral("%1:%2").arg(QString::fromLatin1(addr_str)).arg(ntohs(addr.sin_port));
}
QTableWidgetItem* GetSocketName(s32 host_fd) QTableWidgetItem* GetSocketName(s32 host_fd)
{ {
if (host_fd < 0) if (host_fd < 0)
@ -100,18 +110,19 @@ QTableWidgetItem* GetSocketName(s32 host_fd)
if (getsockname(host_fd, reinterpret_cast<sockaddr*>(&sock_addr), &sock_addr_len) != 0) if (getsockname(host_fd, reinterpret_cast<sockaddr*>(&sock_addr), &sock_addr_len) != 0)
return new QTableWidgetItem(QTableWidget::tr("Unknown")); return new QTableWidgetItem(QTableWidget::tr("Unknown"));
const QString sock_name = QStringLiteral("%1:%2") const QString sock_name = GetAddressAndPort(sock_addr);
.arg(QString::fromLatin1(inet_ntoa(sock_addr.sin_addr))) if (sock_name.isEmpty())
.arg(ntohs(sock_addr.sin_port)); return new QTableWidgetItem(QTableWidget::tr("Unknown"));
sockaddr_in peer_addr; sockaddr_in peer_addr;
socklen_t peer_addr_len = sizeof(sockaddr_in); socklen_t peer_addr_len = sizeof(sockaddr_in);
if (getpeername(host_fd, reinterpret_cast<sockaddr*>(&peer_addr), &peer_addr_len) != 0) if (getpeername(host_fd, reinterpret_cast<sockaddr*>(&peer_addr), &peer_addr_len) != 0)
return new QTableWidgetItem(sock_name); return new QTableWidgetItem(sock_name);
const QString peer_name = QStringLiteral("%1:%2") const QString peer_name = GetAddressAndPort(peer_addr);
.arg(QString::fromLatin1(inet_ntoa(peer_addr.sin_addr))) if (peer_name.isEmpty())
.arg(ntohs(peer_addr.sin_port)); return new QTableWidgetItem(sock_name);
return new QTableWidgetItem(QStringLiteral("%1->%2").arg(sock_name).arg(peer_name)); return new QTableWidgetItem(QStringLiteral("%1->%2").arg(sock_name).arg(peer_name));
} }
} // namespace } // namespace

View File

@ -196,7 +196,7 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
} }
mmio->Register(base | FIFO_BP_LO, MMIO::DirectRead<u16>(MMIO::Utils::LowPart(&fifo.CPBreakpoint)), mmio->Register(base | FIFO_BP_LO, MMIO::DirectRead<u16>(MMIO::Utils::LowPart(&fifo.CPBreakpoint)),
MMIO::ComplexWrite<u16>([](u32, u16 val) { MMIO::ComplexWrite<u16>([WMASK_LO_ALIGN_32BIT](u32, u16 val) {
WriteLow(fifo.CPBreakpoint, val & WMASK_LO_ALIGN_32BIT); WriteLow(fifo.CPBreakpoint, val & WMASK_LO_ALIGN_32BIT);
})); }));
mmio->Register(base | FIFO_BP_HI, mmio->Register(base | FIFO_BP_HI,