Skip to content

Commit

Permalink
Deprecate BNLogRegisterLoggerCallback and make its use in the LogView…
Browse files Browse the repository at this point in the history
… unnecessary
  • Loading branch information
plafosse committed Oct 5, 2022
1 parent 76f72f0 commit 197f69d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 37 deletions.
1 change: 0 additions & 1 deletion binaryninjaapi.h
Expand Up @@ -707,7 +707,6 @@ namespace BinaryNinja {
\return a list of registered logger names
*/
static std::vector<std::string> GetLoggerNames();
static void RegisterLoggerCallback(const std::function<void(const std::string&)>& cb);
};

std::string EscapeString(const std::string& s);
Expand Down
1 change: 1 addition & 0 deletions binaryninjacore.h
Expand Up @@ -3008,6 +3008,7 @@ extern "C"
BINARYNINJACOREAPI BNLogger* BNLogCreateLogger(const char* loggerName, size_t sessionId);
BINARYNINJACOREAPI BNLogger* BNLogGetLogger(const char* loggerName, size_t sessionId);
BINARYNINJACOREAPI char** BNLogGetLoggerNames(size_t* count);
// BNLogRegisterLoggerCallback is deprecated and no longer functions
BINARYNINJACOREAPI void BNLogRegisterLoggerCallback(void (*cb)(const char* name, void* ctxt), void* ctxt);

BINARYNINJACOREAPI void BNRegisterLogListener(BNLogListener* listener);
Expand Down
25 changes: 0 additions & 25 deletions log.cpp
Expand Up @@ -305,28 +305,3 @@ vector<string> LogRegistry::GetLoggerNames()
BNFreeStringList(names, count);
return result;
}


struct RegisterLoggerCallbackContext
{
std::function<void(const string&)> func;
};


static void RegisterLoggerCallbackHelper(const char* name, void* ctxt)
{
static const char* noName = "";
RegisterLoggerCallbackContext* cb = (RegisterLoggerCallbackContext*)ctxt;
if (name == nullptr)
name = noName;
cb->func(name);
}


void LogRegistry::RegisterLoggerCallback(const std::function<void(const string&)>& cb)
{
// we leak this LoggerCallback but since you can't unregister them it doesn't really matter
auto loggerCallback = new RegisterLoggerCallbackContext;
loggerCallback->func = cb;
BNLogRegisterLoggerCallback(RegisterLoggerCallbackHelper, loggerCallback);
}
27 changes: 16 additions & 11 deletions ui/logview.h
Expand Up @@ -165,6 +165,21 @@ class BINARYNINJAUIAPI LogItemDelegate : public QStyledItemDelegate
};


class BINARYNINJAUIAPI LogViewComboBox : public QComboBox
{
Q_OBJECT

public:
LogViewComboBox(QWidget* parent);
void updateLoggers();
void showPopup();
public Q_SLOTS:
void signalItemSelected(size_t);
Q_SIGNALS:
void itemSelected(QString text);
};


class BINARYNINJAUIAPI LogView : public GlobalAreaWidget
{
Q_OBJECT
Expand All @@ -177,7 +192,7 @@ class BINARYNINJAUIAPI LogView : public GlobalAreaWidget
LogItemDelegate* m_itemDelegate;
QTimer* m_updateTimer;

QComboBox* m_comboBox;
LogViewComboBox* m_comboBox;
QLineEdit* m_lineEdit;
QWidget* m_filterWidget;
RenderContext m_render;
Expand All @@ -186,15 +201,6 @@ class BINARYNINJAUIAPI LogView : public GlobalAreaWidget
bool m_scrolledToEnd;
bool m_hasSelection = false;

// bool m_subSelectionMode;
// size_t m_baseSelectionIndex;
// size_t m_baseSelectionOffset;
// size_t m_currentSelectionIndex;
// size_t m_currentSelectionOffset;
// size_t m_visibleRows {1};
// size_t m_topLine {0};
// size_t m_selectCount {0};

public:
LogView(LogStatus* logStatus);

Expand Down Expand Up @@ -241,7 +247,6 @@ class BINARYNINJAUIAPI LogView : public GlobalAreaWidget
void updateTimerEvent();
void updateUiStatus();
void showContextMenu();
void loggerAdded(const QString str);
};


Expand Down

0 comments on commit 197f69d

Please sign in to comment.