Fix the "all green" navbar (#2305)

* Specify the search range for search.in
* Add  config_set(key, const char*) overloads to prevent char* being automatically casted to bool and config_set(key, bool) being chosen unexpectedly.
This commit is contained in:
Itay Cohen 2020-07-20 23:11:31 +03:00 committed by GitHub
parent e14d0d8ef6
commit c923576b7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 1 deletions

View File

@ -34,6 +34,16 @@ TempConfig &TempConfig::set(const QString &key, const QString &value)
return *this; return *this;
} }
TempConfig &TempConfig::set(const QString &key, const char *value)
{
if (!resetValues.contains(key)) {
resetValues[key] = Core()->getConfig(key);
}
Core()->setConfig(key, value);
return *this;
}
TempConfig &TempConfig::set(const QString &key, int value) TempConfig &TempConfig::set(const QString &key, int value)
{ {
if (!resetValues.contains(key)) { if (!resetValues.contains(key)) {

View File

@ -29,6 +29,7 @@ public:
~TempConfig(); ~TempConfig();
TempConfig &set(const QString &key, const QString &value); TempConfig &set(const QString &key, const QString &value);
TempConfig &set(const QString &key, const char *value);
TempConfig &set(const QString &key, int value); TempConfig &set(const QString &key, int value);
TempConfig &set(const QString &key, bool value); TempConfig &set(const QString &key, bool value);

View File

@ -956,6 +956,18 @@ QString CutterCore::itoa(ut64 num, int rdx)
return QString::number(num, rdx); return QString::number(num, rdx);
} }
void CutterCore::setConfig(const char *k, const char *v)
{
CORE_LOCK();
r_config_set(core->config, k, v);
}
void CutterCore::setConfig(const QString &k, const char *v)
{
CORE_LOCK();
r_config_set(core->config, k.toUtf8().constData(), v);
}
void CutterCore::setConfig(const char *k, const QString &v) void CutterCore::setConfig(const char *k, const QString &v)
{ {
CORE_LOCK(); CORE_LOCK();
@ -3397,7 +3409,15 @@ BlockStatistics CutterCore::getBlockStatistics(unsigned int blocksCount)
return blockStats; return blockStats;
} }
QJsonObject statsObj = cmdj("p-j " + QString::number(blocksCount)).object(); QJsonObject statsObj;
// User TempConfig here to set the search boundaries to all sections. This makes sure
// that the Visual Navbar will show all the relevant addresses.
{
TempConfig tempConfig;
tempConfig.set("search.in", "bin.sections");
statsObj = cmdj("p-j " + QString::number(blocksCount)).object();
}
blockStats.from = statsObj[RJsonKey::from].toVariant().toULongLong(); blockStats.from = statsObj[RJsonKey::from].toVariant().toULongLong();
blockStats.to = statsObj[RJsonKey::to].toVariant().toULongLong(); blockStats.to = statsObj[RJsonKey::to].toVariant().toULongLong();

View File

@ -287,6 +287,8 @@ public:
QString itoa(ut64 num, int rdx = 16); QString itoa(ut64 num, int rdx = 16);
/* Config functions */ /* Config functions */
void setConfig(const char *k, const char *v);
void setConfig(const QString &k, const char *v);
void setConfig(const char *k, const QString &v); void setConfig(const char *k, const QString &v);
void setConfig(const QString &k, const QString &v) { setConfig(k.toUtf8().constData(), v); } void setConfig(const QString &k, const QString &v) { setConfig(k.toUtf8().constData(), v); }
void setConfig(const char *k, int v); void setConfig(const char *k, int v);