mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-11-07 06:24:57 +00:00
When enumerating adb devices, reuse old hosts where possible.
* This fixes a crash where an enumeration from application startup is still going when opening the remote manager dialog, and then all the android hosts that are being enumerated get deleted while it's still going.
This commit is contained in:
1 parent
c76b8298f8
commit
06b5b300c3
1 file changed
+23
-3
@@ -170,10 +170,14 @@ void PersistantConfig::applyValues(const QVariantMap &values)
|
||||
|
||||
void PersistantConfig::AddAndroidHosts()
|
||||
{
|
||||
QMap<QString, RemoteHost *> oldHosts;
|
||||
for(int i = RemoteHosts.count() - 1; i >= 0; i--)
|
||||
{
|
||||
if(RemoteHosts[i]->IsHostADB())
|
||||
delete RemoteHosts.takeAt(i);
|
||||
{
|
||||
RemoteHost *host = RemoteHosts.takeAt(i);
|
||||
oldHosts[host->Hostname] = host;
|
||||
}
|
||||
}
|
||||
|
||||
QString adbExePath =
|
||||
@@ -191,8 +195,16 @@ void PersistantConfig::AddAndroidHosts()
|
||||
RENDERDOC_EnumerateAndroidDevices(&androidHosts);
|
||||
for(const QString &hostName : ToQStr(androidHosts).split(QLatin1Char(','), QString::SkipEmptyParts))
|
||||
{
|
||||
RemoteHost *host = new RemoteHost();
|
||||
host->Hostname = lit("adb:") + hostName;
|
||||
RemoteHost *host = NULL;
|
||||
|
||||
QString fullHostname = lit("adb:") + hostName;
|
||||
|
||||
if(oldHosts.contains(fullHostname))
|
||||
host = oldHosts.take(fullHostname);
|
||||
else
|
||||
host = new RemoteHost();
|
||||
|
||||
host->Hostname = fullHostname;
|
||||
rdctype::str friendly;
|
||||
RENDERDOC_GetAndroidFriendlyName(hostName.toUtf8().data(), friendly);
|
||||
host->FriendlyName = ToQStr(friendly);
|
||||
@@ -200,6 +212,14 @@ void PersistantConfig::AddAndroidHosts()
|
||||
host->RunCommand = lit("org.renderdoc.renderdoccmd");
|
||||
RemoteHosts.push_back(host);
|
||||
}
|
||||
|
||||
// delete any leftovers
|
||||
QMapIterator<QString, RemoteHost *> i(oldHosts);
|
||||
while(i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
delete i.value();
|
||||
}
|
||||
}
|
||||
|
||||
PersistantConfig::~PersistantConfig()
|
||||
|
||||
Reference in new issue
Block a user