Merge pull request #2408 from Cacodemon345/winbuildfix
qt: Fix crashes and freezes when switching to/from Direct3D 9
This commit is contained in:
@@ -142,6 +142,7 @@ void D3D9Renderer::blit(int x, int y, int w, int h)
|
|||||||
video_blit_complete();
|
video_blit_complete();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
surfaceInUse = true;
|
||||||
source.setRect(x, y, w, h);
|
source.setRect(x, y, w, h);
|
||||||
RECT srcRect;
|
RECT srcRect;
|
||||||
D3DLOCKED_RECT lockRect;
|
D3DLOCKED_RECT lockRect;
|
||||||
@@ -150,7 +151,6 @@ void D3D9Renderer::blit(int x, int y, int w, int h)
|
|||||||
srcRect.left = source.left();
|
srcRect.left = source.left();
|
||||||
srcRect.right = source.right();
|
srcRect.right = source.right();
|
||||||
|
|
||||||
surfaceInUse = true;
|
|
||||||
if (screenshots) {
|
if (screenshots) {
|
||||||
video_screenshot((uint32_t *) &(buffer32->line[y][x]), 0, 0, 2048);
|
video_screenshot((uint32_t *) &(buffer32->line[y][x]), 0, 0, 2048);
|
||||||
}
|
}
|
||||||
|
@@ -583,24 +583,25 @@ void MachineStatus::updateTip(int tag)
|
|||||||
{
|
{
|
||||||
int category = tag & 0xfffffff0;
|
int category = tag & 0xfffffff0;
|
||||||
int item = tag & 0xf;
|
int item = tag & 0xf;
|
||||||
|
if (!MediaMenu::ptr) return;
|
||||||
switch (category) {
|
switch (category) {
|
||||||
case SB_CASSETTE:
|
case SB_CASSETTE:
|
||||||
d->cassette.label->setToolTip(MediaMenu::ptr->cassetteMenu->title());
|
if (d->cassette.label && MediaMenu::ptr->cassetteMenu) d->cassette.label->setToolTip(MediaMenu::ptr->cassetteMenu->title());
|
||||||
break;
|
break;
|
||||||
case SB_CARTRIDGE:
|
case SB_CARTRIDGE:
|
||||||
d->cartridge[item].label->setToolTip(MediaMenu::ptr->cartridgeMenus[item]->title());
|
if (d->cartridge[item].label && MediaMenu::ptr->cartridgeMenus[item]) d->cartridge[item].label->setToolTip(MediaMenu::ptr->cartridgeMenus[item]->title());
|
||||||
break;
|
break;
|
||||||
case SB_FLOPPY:
|
case SB_FLOPPY:
|
||||||
d->fdd[item].label->setToolTip(MediaMenu::ptr->floppyMenus[item]->title());
|
if (d->fdd[item].label && MediaMenu::ptr->floppyMenus[item]) d->fdd[item].label->setToolTip(MediaMenu::ptr->floppyMenus[item]->title());
|
||||||
break;
|
break;
|
||||||
case SB_CDROM:
|
case SB_CDROM:
|
||||||
d->cdrom[item].label->setToolTip(MediaMenu::ptr->cdromMenus[item]->title());
|
if (d->cdrom[item].label && MediaMenu::ptr->cdromMenus[item]) d->cdrom[item].label->setToolTip(MediaMenu::ptr->cdromMenus[item]->title());
|
||||||
break;
|
break;
|
||||||
case SB_ZIP:
|
case SB_ZIP:
|
||||||
d->zip[item].label->setToolTip(MediaMenu::ptr->zipMenus[item]->title());
|
if (d->zip[item].label && MediaMenu::ptr->zipMenus[item]) d->zip[item].label->setToolTip(MediaMenu::ptr->zipMenus[item]->title());
|
||||||
break;
|
break;
|
||||||
case SB_MO:
|
case SB_MO:
|
||||||
d->mo[item].label->setToolTip(MediaMenu::ptr->moMenus[item]->title());
|
if (d->mo[item].label && MediaMenu::ptr->moMenus[item]) d->mo[item].label->setToolTip(MediaMenu::ptr->moMenus[item]->title());
|
||||||
break;
|
break;
|
||||||
case SB_HDD:
|
case SB_HDD:
|
||||||
break;
|
break;
|
||||||
|
@@ -501,6 +501,7 @@ void MediaMenu::zipEject(int i) {
|
|||||||
zip_t *dev = (zip_t *) zip_drives[i].priv;
|
zip_t *dev = (zip_t *) zip_drives[i].priv;
|
||||||
|
|
||||||
zip_disk_close(dev);
|
zip_disk_close(dev);
|
||||||
|
zip_drives[i].image_path[0] = 0;
|
||||||
if (zip_drives[i].bus_type) {
|
if (zip_drives[i].bus_type) {
|
||||||
/* Signal disk change to the emulated machine. */
|
/* Signal disk change to the emulated machine. */
|
||||||
zip_insert(dev);
|
zip_insert(dev);
|
||||||
@@ -600,6 +601,7 @@ void MediaMenu::moEject(int i) {
|
|||||||
mo_t *dev = (mo_t *) mo_drives[i].priv;
|
mo_t *dev = (mo_t *) mo_drives[i].priv;
|
||||||
|
|
||||||
mo_disk_close(dev);
|
mo_disk_close(dev);
|
||||||
|
mo_drives[i].image_path[0] = 0;
|
||||||
if (mo_drives[i].bus_type) {
|
if (mo_drives[i].bus_type) {
|
||||||
/* Signal disk change to the emulated machine. */
|
/* Signal disk change to the emulated machine. */
|
||||||
mo_insert(dev);
|
mo_insert(dev);
|
||||||
|
@@ -226,20 +226,27 @@ RendererStack::switchRenderer(Renderer renderer)
|
|||||||
{
|
{
|
||||||
startblit();
|
startblit();
|
||||||
if (current) {
|
if (current) {
|
||||||
|
rendererWindow->finalize();
|
||||||
if (rendererWindow->hasBlitFunc()) {
|
if (rendererWindow->hasBlitFunc()) {
|
||||||
while (directBlitting) {}
|
while (directBlitting) {}
|
||||||
|
connect(this, &RendererStack::blit, this, &RendererStack::blitDummy, Qt::DirectConnection);
|
||||||
disconnect(this, &RendererStack::blit, this, &RendererStack::blitRenderer);
|
disconnect(this, &RendererStack::blit, this, &RendererStack::blitRenderer);
|
||||||
video_blit_complete();
|
} else {
|
||||||
|
connect(this, &RendererStack::blit, this, &RendererStack::blitDummy, Qt::DirectConnection);
|
||||||
|
disconnect(this, &RendererStack::blit, this, &RendererStack::blitCommon);
|
||||||
}
|
}
|
||||||
rendererWindow->finalize();
|
|
||||||
|
|
||||||
removeWidget(current.get());
|
removeWidget(current.get());
|
||||||
disconnect(this, &RendererStack::blitToRenderer, nullptr, nullptr);
|
disconnect(this, &RendererStack::blitToRenderer, nullptr, nullptr);
|
||||||
|
|
||||||
/* Create new renderer only after previous is destroyed! */
|
/* Create new renderer only after previous is destroyed! */
|
||||||
connect(current.get(), &QObject::destroyed, [this, renderer](QObject *) { video_blit_complete(); createRenderer(renderer); video_blit_complete(); });
|
connect(current.get(), &QObject::destroyed, [this, renderer](QObject *) {
|
||||||
|
createRenderer(renderer);
|
||||||
|
disconnect(this, &RendererStack::blit, this, &RendererStack::blitDummy);
|
||||||
|
blitDummied = false;
|
||||||
|
});
|
||||||
|
|
||||||
current.release()->deleteLater();
|
rendererWindow->hasBlitFunc() ? current.reset() : current.release()->deleteLater();
|
||||||
} else {
|
} else {
|
||||||
createRenderer(renderer);
|
createRenderer(renderer);
|
||||||
}
|
}
|
||||||
@@ -318,7 +325,6 @@ RendererStack::createRenderer(Renderer renderer)
|
|||||||
});
|
});
|
||||||
connect(hw, &D3D9Renderer::initialized, this, [this]()
|
connect(hw, &D3D9Renderer::initialized, this, [this]()
|
||||||
{
|
{
|
||||||
qDebug() << "initialized";
|
|
||||||
endblit();
|
endblit();
|
||||||
emit rendererChanged();
|
emit rendererChanged();
|
||||||
});
|
});
|
||||||
@@ -388,9 +394,17 @@ RendererStack::createRenderer(Renderer renderer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
RendererStack::blitDummy(int x, int y, int w, int h)
|
||||||
|
{
|
||||||
|
video_blit_complete();
|
||||||
|
blitDummied = true;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
RendererStack::blitRenderer(int x, int y, int w, int h)
|
RendererStack::blitRenderer(int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
|
if (blitDummied) { blitDummied = false; video_blit_complete(); return; }
|
||||||
directBlitting = true;
|
directBlitting = true;
|
||||||
rendererWindow->blit(x, y, w, h);
|
rendererWindow->blit(x, y, w, h);
|
||||||
directBlitting = false;
|
directBlitting = false;
|
||||||
@@ -400,7 +414,7 @@ RendererStack::blitRenderer(int x, int y, int w, int h)
|
|||||||
void
|
void
|
||||||
RendererStack::blitCommon(int x, int y, int w, int h)
|
RendererStack::blitCommon(int x, int y, int w, int h)
|
||||||
{
|
{
|
||||||
if ((x < 0) || (y < 0) || (w <= 0) || (h <= 0) || (w > 2048) || (h > 2048) || (buffer32 == NULL) || imagebufs.empty() || std::get<std::atomic_flag *>(imagebufs[currentBuf])->test_and_set()) {
|
if ((x < 0) || (y < 0) || (w <= 0) || (h <= 0) || (w > 2048) || (h > 2048) || (buffer32 == NULL) || imagebufs.empty() || std::get<std::atomic_flag *>(imagebufs[currentBuf])->test_and_set() || blitDummied) {
|
||||||
video_blit_complete();
|
video_blit_complete();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -79,6 +79,7 @@ signals:
|
|||||||
public slots:
|
public slots:
|
||||||
void blitCommon(int x, int y, int w, int h);
|
void blitCommon(int x, int y, int w, int h);
|
||||||
void blitRenderer(int x, int y, int w, int h);
|
void blitRenderer(int x, int y, int w, int h);
|
||||||
|
void blitDummy(int x, int y, int w, int h);
|
||||||
void mousePoll();
|
void mousePoll();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -101,7 +102,7 @@ private:
|
|||||||
|
|
||||||
RendererCommon *rendererWindow { nullptr };
|
RendererCommon *rendererWindow { nullptr };
|
||||||
std::unique_ptr<QWidget> current;
|
std::unique_ptr<QWidget> current;
|
||||||
std::atomic<bool> directBlitting{false};
|
std::atomic<bool> directBlitting{false}, blitDummied{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QT_RENDERERCONTAINER_HPP
|
#endif // QT_RENDERERCONTAINER_HPP
|
||||||
|
Reference in New Issue
Block a user