GUI: fixed race conditions in the optimized logging
This commit is contained in:
parent
518dcd30d4
commit
29b28159b7
|
@ -374,7 +374,7 @@ void StdTable::copyLineToLogSlot()
|
|||
finalText += "\r\n";
|
||||
}
|
||||
}
|
||||
emit Bridge::getBridge()->addMsgToLog(finalText.toUtf8().constData());
|
||||
emit Bridge::getBridge()->addMsgToLog(finalText.toUtf8());
|
||||
}
|
||||
|
||||
QString StdTable::copyTable(const std::vector<int> & colWidths)
|
||||
|
@ -443,7 +443,7 @@ void StdTable::copyTableToLogSlot()
|
|||
int colCount = getColumnCount();
|
||||
for(int i = 0; i < colCount; i++)
|
||||
colWidths.push_back(getColumnWidth(i) / getCharWidth());
|
||||
emit Bridge::getBridge()->addMsgToLog(copyTable(colWidths).toUtf8().constData());
|
||||
emit Bridge::getBridge()->addMsgToLog(copyTable(colWidths).toUtf8());
|
||||
}
|
||||
|
||||
void StdTable::copyTableResizeSlot()
|
||||
|
@ -473,7 +473,7 @@ void StdTable::copyTableResizeToLogSlot()
|
|||
max = std::max(getCellContent(j, i).length(), max);
|
||||
colWidths.push_back(max);
|
||||
}
|
||||
emit Bridge::getBridge()->addMsgToLog(copyTable(colWidths).toUtf8().constData());
|
||||
emit Bridge::getBridge()->addMsgToLog(copyTable(colWidths).toUtf8());
|
||||
}
|
||||
|
||||
void StdTable::copyEntrySlot()
|
||||
|
|
|
@ -94,8 +94,11 @@ void* Bridge::processMessage(GUIMSG type, void* param1, void* param2)
|
|||
break;
|
||||
|
||||
case GUI_ADD_MSG_TO_LOG:
|
||||
emit addMsgToLog((const char*)param1); //Speed up performance: don't convert to UCS-2 QString
|
||||
break;
|
||||
{
|
||||
auto msg = (const char*)param1;
|
||||
emit addMsgToLog(QByteArray(msg, strlen(msg) + 1)); //Speed up performance: don't convert to UCS-2 QString
|
||||
}
|
||||
break;
|
||||
|
||||
case GUI_CLEAR_LOG:
|
||||
emit clearLog();
|
||||
|
|
|
@ -45,7 +45,7 @@ signals:
|
|||
void disassembleAt(dsint va, dsint eip);
|
||||
void repaintGui();
|
||||
void dbgStateChanged(DBGSTATE state);
|
||||
void addMsgToLog(const char* msg);
|
||||
void addMsgToLog(QByteArray msg);
|
||||
void clearLog();
|
||||
void close();
|
||||
void updateRegisters();
|
||||
|
|
|
@ -8,7 +8,7 @@ LogStatusLabel::LogStatusLabel(QStatusBar* parent) : QLabel(parent)
|
|||
|
||||
this->setTextFormat(Qt::PlainText);
|
||||
setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
||||
connect(Bridge::getBridge(), SIGNAL(addMsgToLog(const char*)), this, SLOT(logUpdateUtf8(const char*)));
|
||||
connect(Bridge::getBridge(), SIGNAL(addMsgToLog(QByteArray)), this, SLOT(logUpdateUtf8(QByteArray)));
|
||||
connect(Bridge::getBridge(), SIGNAL(addMsgToStatusBar(QString)), this, SLOT(logUpdate(QString)));
|
||||
connect(Bridge::getBridge(), SIGNAL(getActiveView(ACTIVEVIEW*)), this, SLOT(getActiveView(ACTIVEVIEW*)));
|
||||
connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)), this, SLOT(focusChanged(QWidget*, QWidget*)));
|
||||
|
@ -35,7 +35,7 @@ void LogStatusLabel::logUpdate(QString message)
|
|||
setText(finalLabel);
|
||||
}
|
||||
|
||||
void LogStatusLabel::logUpdateUtf8(const char* message)
|
||||
void LogStatusLabel::logUpdateUtf8(QByteArray message)
|
||||
{
|
||||
logUpdate(QString::fromUtf8(message));
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ public:
|
|||
|
||||
public slots:
|
||||
void logUpdate(QString message);
|
||||
void logUpdateUtf8(const char* message);
|
||||
void logUpdateUtf8(QByteArray message);
|
||||
void focusChanged(QWidget* old, QWidget* now);
|
||||
void getActiveView(ACTIVEVIEW* active);
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ LogView::LogView(QWidget* parent) : QTextBrowser(parent), logRedirection(NULL)
|
|||
|
||||
connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(updateStyle()));
|
||||
connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(updateStyle()));
|
||||
connect(Bridge::getBridge(), SIGNAL(addMsgToLog(const char*)), this, SLOT(addMsgToLogSlot(const char*)));
|
||||
connect(Bridge::getBridge(), SIGNAL(addMsgToLog(QByteArray)), this, SLOT(addMsgToLogSlot(QByteArray)));
|
||||
connect(Bridge::getBridge(), SIGNAL(clearLog()), this, SLOT(clearLogSlot()));
|
||||
connect(Bridge::getBridge(), SIGNAL(setLogEnabled(bool)), this, SLOT(setLoggingEnabled(bool)));
|
||||
connect(this, SIGNAL(anchorClicked(QUrl)), this, SLOT(onAnchorClicked(QUrl)));
|
||||
|
@ -150,7 +150,7 @@ static void linkify(QString & msg)
|
|||
* @brief LogView::addMsgToLogSlot Adds a message to the log view. This function is a slot for Bridge::addMsgToLog.
|
||||
* @param msg The log message
|
||||
*/
|
||||
void LogView::addMsgToLogSlot(const char* msg)
|
||||
void LogView::addMsgToLogSlot(QByteArray msg)
|
||||
{
|
||||
/*
|
||||
* This supports the 'UTF-8 Everywhere' manifesto.
|
||||
|
@ -183,9 +183,9 @@ void LogView::addMsgToLogSlot(const char* msg)
|
|||
std::string temp;
|
||||
size_t offset = 0;
|
||||
size_t buffersize = 0;
|
||||
if(strstr(msg, "\r\n") != nullptr) // Don't replace "\r\n" to "\n" if there is none
|
||||
if(strstr(msg.constData(), "\r\n") != nullptr) // Don't replace "\r\n" to "\n" if there is none
|
||||
{
|
||||
temp = msg;
|
||||
temp = msg.constData();
|
||||
while(true)
|
||||
{
|
||||
size_t index = temp.find("\r\n", offset);
|
||||
|
@ -199,7 +199,7 @@ void LogView::addMsgToLogSlot(const char* msg)
|
|||
}
|
||||
else
|
||||
{
|
||||
data = msg;
|
||||
data = msg.constData();
|
||||
buffersize = strlen(msg);
|
||||
}
|
||||
if(!fwrite(data, buffersize, 1, logRedirection))
|
||||
|
@ -406,5 +406,5 @@ void LogView::pasteSlot()
|
|||
return;
|
||||
if(!clipboardText.endsWith('\n'))
|
||||
clipboardText.append('\n');
|
||||
addMsgToLogSlot(clipboardText.toUtf8().constData());
|
||||
addMsgToLogSlot(clipboardText.toUtf8());
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public:
|
|||
public slots:
|
||||
void refreshShortcutsSlot();
|
||||
void updateStyle();
|
||||
void addMsgToLogSlot(const char* msg);
|
||||
void addMsgToLogSlot(QByteArray msg);
|
||||
void redirectLogSlot();
|
||||
void setLoggingEnabled(bool enabled);
|
||||
void autoScrollSlot();
|
||||
|
|
Loading…
Reference in New Issue