rsx/Qt: Fix Qt shader loading dialog crash

This commit is contained in:
kd-11 2018-07-06 19:32:52 +03:00 committed by kd-11
parent 4d40ed9dbd
commit f0a9799b4b

View File

@ -410,7 +410,7 @@ namespace rsx
struct progress_dialog_helper struct progress_dialog_helper
{ {
std::shared_ptr<MsgDialogBase> dlg; std::shared_ptr<MsgDialogBase> dlg;
atomic_t<bool> initialized{ false }; atomic_t<int> ref_cnt;
virtual void create() virtual void create()
{ {
@ -427,13 +427,15 @@ namespace rsx
}); });
}; };
ref_cnt++;
Emu.CallAfter([&]() Emu.CallAfter([&]()
{ {
dlg->Create("Preloading cached shaders from disk.\nPlease wait...", "Shader Compilation"); dlg->Create("Preloading cached shaders from disk.\nPlease wait...", "Shader Compilation");
initialized.store(true); ref_cnt--;
}); });
while (!initialized.load() && !Emu.IsStopped()) while (ref_cnt.load() && !Emu.IsStopped())
{ {
_mm_pause(); _mm_pause();
} }
@ -441,26 +443,35 @@ namespace rsx
virtual void update_msg(u32 index, u32 processed, u32 entry_count) virtual void update_msg(u32 index, u32 processed, u32 entry_count)
{ {
Emu.CallAfter([=]() ref_cnt++;
Emu.CallAfter([&]()
{ {
const char *text = index == 0 ? "Loading pipeline object %u of %u" : "Compiling pipeline object %u of %u"; const char *text = index == 0 ? "Loading pipeline object %u of %u" : "Compiling pipeline object %u of %u";
dlg->ProgressBarSetMsg(index, fmt::format(text, processed, entry_count)); dlg->ProgressBarSetMsg(index, fmt::format(text, processed, entry_count));
ref_cnt--;
}); });
} }
virtual void inc_value(u32 index, u32 value) virtual void inc_value(u32 index, u32 value)
{ {
Emu.CallAfter([=]() ref_cnt++;
Emu.CallAfter([&]()
{ {
dlg->ProgressBarInc(index, value); dlg->ProgressBarInc(index, value);
ref_cnt--;
}); });
} }
virtual void set_limit(u32 index, u32 limit) virtual void set_limit(u32 index, u32 limit)
{ {
Emu.CallAfter([=]() ref_cnt++;
Emu.CallAfter([&]()
{ {
dlg->ProgressBarSetLimit(index, limit); dlg->ProgressBarSetLimit(index, limit);
ref_cnt--;
}); });
} }
@ -468,7 +479,12 @@ namespace rsx
{}; {};
virtual void close() virtual void close()
{} {
while (ref_cnt.load() && !Emu.IsStopped())
{
_mm_pause();
}
}
}; };
shaders_cache(backend_storage& storage, std::string pipeline_class, std::string version_prefix_str = "v1") shaders_cache(backend_storage& storage, std::string pipeline_class, std::string version_prefix_str = "v1")