summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter LaFosse <peter@vector35.com>2021-05-18 14:35:17 -0400
committerJon Palmisciano <jp@jonpalmisc.com>2021-05-26 11:44:25 -0400
commit1156c58c46a77d9f156e3a45afea381470560b82 (patch)
treeceb24bb898d27f3bd0eddf8c8c4f65839aa431ef
parent7c9ada78241e08bf36bd04d989f742a6de721575 (diff)
TypeDialog: Perform type parsing on separate thread
-rw-r--r--ui/typedialog.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/ui/typedialog.h b/ui/typedialog.h
index afd95ee9..76931d13 100644
--- a/ui/typedialog.h
+++ b/ui/typedialog.h
@@ -15,6 +15,7 @@
#ifdef BINARYNINJAUI_BINDINGS
// QThread has issues working in the bindings on some platforms
class GetTypesListThread;
+class ParseTypeThread;
#else
class BINARYNINJAUIAPI GetTypesListThread: public QThread
{
@@ -35,6 +36,25 @@ public:
const QStringList& getTypes() const { return m_allTypes; }
};
+
+Q_DECLARE_METATYPE(BinaryNinja::QualifiedNameAndType);
+
+//! QThread subclass for handling type string parsing to avoid UI interruptions.
+class ParseTypeThread: public QThread {
+ Q_OBJECT
+
+ BinaryViewRef m_view;
+ std::string m_text;
+
+ void run() override;
+
+Q_SIGNALS:
+ void parsingComplete(bool valid, BinaryNinja::QualifiedNameAndType type, QString error);
+
+public:
+ ParseTypeThread(BinaryViewRef view, QString text);
+ void cancel();
+};
#endif
class BINARYNINJAUIAPI TypeDialog: public QDialog
@@ -55,6 +75,9 @@ class BINARYNINJAUIAPI TypeDialog: public QDialog
BinaryNinja::QualifiedNameAndType m_type;
QPushButton* m_acceptButton;
QTimer* m_updateTimer;
+ QTimer* m_parseTimer;
+ bool m_isParsing;
+ std::atomic_bool m_comboBoxTextChanged;
QPalette m_defaultPalette;
QString m_parseError;
@@ -63,7 +86,8 @@ class BINARYNINJAUIAPI TypeDialog: public QDialog
private Q_SLOTS:
void accepted();
- void checkParse(QString text);
+ void checkParse();
+ void typeParsed(bool valid, BinaryNinja::QualifiedNameAndType type, QString error);
void updateTimerEvent();
public: