Skip to content

Commit 387546c

Browse files
committed
avoid crash when async remesh throws an exception
1 parent ab8e30b commit 387546c

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

src/display/MapCanvasRoomDrawer.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,36 @@ struct NODISCARD RemeshCookie final
6767
&& future.wait_for(std::chrono::nanoseconds(0)) != std::future_status::timeout;
6868
}
6969

70+
private:
71+
static void reportException()
72+
{
73+
try {
74+
std::rethrow_exception(std::current_exception());
75+
} catch (const std::exception &ex) {
76+
qWarning() << "Exception: " << ex.what();
77+
} catch (...) {
78+
qWarning() << "Unknown exception";
79+
}
80+
}
81+
7082
public:
7183
// Don't call this unless isPending() is true.
7284
// NOTE: This can throw an exception thrown by the async function!
7385
NODISCARD SharedMapBatchFinisher get()
7486
{
7587
DECL_TIMER(t, __FUNCTION__);
7688
FutureSharedMapBatchFinisher &future = m_opt_future.value();
77-
auto pFinisher = future.get();
89+
90+
SharedMapBatchFinisher pFinisher;
91+
try {
92+
pFinisher = future.get();
93+
} catch (...) {
94+
reportException();
95+
pFinisher.reset();
96+
}
7897

7998
if (m_ignored) {
80-
pFinisher = SharedMapBatchFinisher{nullptr};
99+
pFinisher.reset();
81100
}
82101

83102
reset();

0 commit comments

Comments
 (0)