Added logic to not call window update from emulator thread in Qt GUI. Qt widget update() should always be called from within main gui thread.
This commit is contained in:
parent
03cd068439
commit
826a39c83e
|
@ -140,10 +140,17 @@ ppuNameTableViewerDialog_t::ppuNameTableViewerDialog_t(QWidget *parent)
|
|||
connect( scanLineEdit, SIGNAL(textEdited(const QString &)), this, SLOT(scanLineChanged(const QString &)));
|
||||
|
||||
FCEUD_UpdateNTView( -1, true);
|
||||
|
||||
updateTimer = new QTimer( this );
|
||||
|
||||
connect( updateTimer, &QTimer::timeout, this, &ppuNameTableViewerDialog_t::periodicUpdate );
|
||||
|
||||
updateTimer->start( 33 ); // 30hz
|
||||
}
|
||||
//----------------------------------------------------
|
||||
ppuNameTableViewerDialog_t::~ppuNameTableViewerDialog_t(void)
|
||||
{
|
||||
updateTimer->stop();
|
||||
nameTableViewWindow = NULL;
|
||||
|
||||
printf("Name Table Viewer Window Deleted\n");
|
||||
|
@ -164,6 +171,16 @@ void ppuNameTableViewerDialog_t::closeWindow(void)
|
|||
deleteLater();
|
||||
}
|
||||
//----------------------------------------------------
|
||||
void ppuNameTableViewerDialog_t::periodicUpdate(void)
|
||||
{
|
||||
|
||||
if ( redrawtables )
|
||||
{
|
||||
this->update();
|
||||
redrawtables = false;
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------
|
||||
void ppuNameTableViewerDialog_t::scanLineChanged( const QString &txt )
|
||||
{
|
||||
std::string s;
|
||||
|
@ -391,8 +408,8 @@ static void DrawNameTable(int scanline, int ntnum, bool invalidateCache)
|
|||
int attraddr = 0x3C0+((y>>2)<<3)+(x>>2);
|
||||
if (invalid
|
||||
|| (table[ntaddr] != tablecache[ntaddr])
|
||||
|| (table[attraddr] != tablecache[attraddr])) {
|
||||
redrawtables = true;
|
||||
|| (table[attraddr] != tablecache[attraddr]))
|
||||
{
|
||||
int temp = (((y&2)<<1)+(x&2));
|
||||
a = (table[attraddr] & (3<<temp)) >> temp;
|
||||
|
||||
|
@ -504,11 +521,7 @@ void FCEUD_UpdateNTView(int scanline, bool drawall)
|
|||
}
|
||||
|
||||
chrchanged = 0;
|
||||
|
||||
if ( nameTableViewWindow )
|
||||
{
|
||||
nameTableViewWindow->update();
|
||||
}
|
||||
redrawtables = true;
|
||||
return;
|
||||
}
|
||||
//----------------------------------------------------
|
||||
|
|
|
@ -73,10 +73,12 @@ class ppuNameTableViewerDialog_t : public QDialog
|
|||
QCheckBox *ignorePaletteCbox;
|
||||
QSlider *refreshSlider;
|
||||
QLineEdit *scanLineEdit;
|
||||
QTimer *updateTimer;
|
||||
|
||||
public slots:
|
||||
void closeWindow(void);
|
||||
private slots:
|
||||
void periodicUpdate(void);
|
||||
void refreshSliderChanged(int value);
|
||||
void scanLineChanged( const QString &txt );
|
||||
};
|
||||
|
|
|
@ -42,6 +42,7 @@ static QColor ppuv_palette[PALETTEHEIGHT][PALETTEWIDTH];
|
|||
static uint8_t pallast[32+3] = { 0 }; // palette cache for change comparison
|
||||
static uint8_t palcache[36] = { 0 }; //palette cache for drawing
|
||||
static uint8_t chrcache0[0x1000] = {0}, chrcache1[0x1000] = {0}, logcache0[0x1000] = {0}, logcache1[0x1000] = {0}; //cache CHR, fixes a refresh problem when right-clicking
|
||||
static bool redrawWindow = true;
|
||||
|
||||
static void initPPUViewer(void);
|
||||
static ppuPatternTable_t pattern0;
|
||||
|
@ -166,11 +167,18 @@ ppuViewerDialog_t::ppuViewerDialog_t(QWidget *parent)
|
|||
connect( refreshSlider, SIGNAL(valueChanged(int)), this, SLOT(refreshSliderChanged(int)));
|
||||
|
||||
FCEUD_UpdatePPUView( -1, 1 );
|
||||
|
||||
updateTimer = new QTimer( this );
|
||||
|
||||
connect( updateTimer, &QTimer::timeout, this, &ppuViewerDialog_t::periodicUpdate );
|
||||
|
||||
updateTimer->start( 33 ); // 30hz
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
ppuViewerDialog_t::~ppuViewerDialog_t(void)
|
||||
{
|
||||
updateTimer->stop();
|
||||
ppuViewWindow = NULL;
|
||||
|
||||
printf("PPU Viewer Window Deleted\n");
|
||||
|
@ -191,6 +199,15 @@ void ppuViewerDialog_t::closeWindow(void)
|
|||
deleteLater();
|
||||
}
|
||||
//----------------------------------------------------
|
||||
void ppuViewerDialog_t::periodicUpdate(void)
|
||||
{
|
||||
if ( redrawWindow )
|
||||
{
|
||||
this->update();
|
||||
redrawWindow = false;
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------
|
||||
void ppuViewerDialog_t::scanLineChanged( const QString &txt )
|
||||
{
|
||||
std::string s;
|
||||
|
@ -556,10 +573,7 @@ void FCEUD_UpdatePPUView(int scanline, int refreshchr)
|
|||
DrawPatternTable( &pattern0,chrcache0,logcache0,pindex[0]);
|
||||
DrawPatternTable( &pattern1,chrcache1,logcache1,pindex[1]);
|
||||
|
||||
if ( ppuViewWindow )
|
||||
{
|
||||
ppuViewWindow->update();
|
||||
}
|
||||
redrawWindow = true;
|
||||
}
|
||||
//----------------------------------------------------
|
||||
ppuPalatteView_t::ppuPalatteView_t(QWidget *parent)
|
||||
|
|
|
@ -108,10 +108,12 @@ class ppuViewerDialog_t : public QDialog
|
|||
QCheckBox *invertMaskCbox;
|
||||
QSlider *refreshSlider;
|
||||
QLineEdit *scanLineEdit;
|
||||
QTimer *updateTimer;
|
||||
|
||||
public slots:
|
||||
void closeWindow(void);
|
||||
private slots:
|
||||
void periodicUpdate(void);
|
||||
void sprite8x16Changed0(int state);
|
||||
void sprite8x16Changed1(int state);
|
||||
void refreshSliderChanged(int value);
|
||||
|
|
Loading…
Reference in New Issue