mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-12-01 02:04:31 +00:00
Update AppModel, ComputerModel, and StreamUtil asserts to cover negative indices
This commit is contained in:
1 parent
2d600c4e6b
commit
4e8fc3aead
3 files changed
+13
-13
No files matched your search
@@ -13,7 +13,7 @@ void AppModel::initialize(ComputerManager* computerManager, int computerIndex, b
|
|||||||
connect(m_ComputerManager, &ComputerManager::computerStateChanged,
|
connect(m_ComputerManager, &ComputerManager::computerStateChanged,
|
||||||
this, &AppModel::handleComputerStateChanged);
|
this, &AppModel::handleComputerStateChanged);
|
||||||
|
|
||||||
Q_ASSERT(computerIndex < m_ComputerManager->getComputers().count());
|
Q_ASSERT(computerIndex >= 0 && computerIndex < m_ComputerManager->getComputers().count());
|
||||||
m_Computer = m_ComputerManager->getComputers().at(computerIndex);
|
m_Computer = m_ComputerManager->getComputers().at(computerIndex);
|
||||||
m_CurrentGameId = m_Computer->currentGameId;
|
m_CurrentGameId = m_Computer->currentGameId;
|
||||||
m_ShowHiddenGames = showHiddenGames;
|
m_ShowHiddenGames = showHiddenGames;
|
||||||
@@ -41,7 +41,7 @@ QString AppModel::getRunningAppName()
|
|||||||
|
|
||||||
Session* AppModel::createSessionForApp(int appIndex)
|
Session* AppModel::createSessionForApp(int appIndex)
|
||||||
{
|
{
|
||||||
Q_ASSERT(appIndex < m_VisibleApps.count());
|
Q_ASSERT(appIndex >= 0 && appIndex < m_VisibleApps.count());
|
||||||
NvApp app = m_VisibleApps.at(appIndex);
|
NvApp app = m_VisibleApps.at(appIndex);
|
||||||
|
|
||||||
return new Session(m_Computer, app);
|
return new Session(m_Computer, app);
|
||||||
@@ -73,7 +73,7 @@ QVariant AppModel::data(const QModelIndex &index, int role) const
|
|||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
Q_ASSERT(index.row() < m_VisibleApps.count());
|
Q_ASSERT(index.row() >= 0 && index.row() < m_VisibleApps.count());
|
||||||
NvApp app = m_VisibleApps.at(index.row());
|
NvApp app = m_VisibleApps.at(index.row());
|
||||||
|
|
||||||
switch (role)
|
switch (role)
|
||||||
@@ -207,7 +207,7 @@ void AppModel::updateAppList(QVector<NvApp> newList)
|
|||||||
|
|
||||||
void AppModel::setAppHidden(int appIndex, bool hidden)
|
void AppModel::setAppHidden(int appIndex, bool hidden)
|
||||||
{
|
{
|
||||||
Q_ASSERT(appIndex < m_VisibleApps.count());
|
Q_ASSERT(appIndex >= 0 && appIndex < m_VisibleApps.count());
|
||||||
int appId = m_VisibleApps.at(appIndex).id;
|
int appId = m_VisibleApps.at(appIndex).id;
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -226,7 +226,7 @@ void AppModel::setAppHidden(int appIndex, bool hidden)
|
|||||||
|
|
||||||
void AppModel::setAppDirectLaunch(int appIndex, bool directLaunch)
|
void AppModel::setAppDirectLaunch(int appIndex, bool directLaunch)
|
||||||
{
|
{
|
||||||
Q_ASSERT(appIndex < m_VisibleApps.count());
|
Q_ASSERT(appIndex >= 0 && appIndex < m_VisibleApps.count());
|
||||||
int appId = m_VisibleApps.at(appIndex).id;
|
int appId = m_VisibleApps.at(appIndex).id;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ QVariant ComputerModel::data(const QModelIndex& index, int role) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_ASSERT(index.row() < m_Computers.count());
|
Q_ASSERT(index.row() >= 0 && index.row() < m_Computers.count());
|
||||||
|
|
||||||
NvComputer* computer = m_Computers[index.row()];
|
NvComputer* computer = m_Computers[index.row()];
|
||||||
QReadLocker lock(&computer->lock);
|
QReadLocker lock(&computer->lock);
|
||||||
@@ -116,7 +116,7 @@ QHash<int, QByteArray> ComputerModel::roleNames() const
|
|||||||
|
|
||||||
Session* ComputerModel::createSessionForCurrentGame(int computerIndex)
|
Session* ComputerModel::createSessionForCurrentGame(int computerIndex)
|
||||||
{
|
{
|
||||||
Q_ASSERT(computerIndex < m_Computers.count());
|
Q_ASSERT(computerIndex >= 0 && computerIndex < m_Computers.count());
|
||||||
|
|
||||||
NvComputer* computer = m_Computers[computerIndex];
|
NvComputer* computer = m_Computers[computerIndex];
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ Session* ComputerModel::createSessionForCurrentGame(int computerIndex)
|
|||||||
|
|
||||||
void ComputerModel::deleteComputer(int computerIndex)
|
void ComputerModel::deleteComputer(int computerIndex)
|
||||||
{
|
{
|
||||||
Q_ASSERT(computerIndex < m_Computers.count());
|
Q_ASSERT(computerIndex >= 0 && computerIndex < m_Computers.count());
|
||||||
|
|
||||||
beginRemoveRows(QModelIndex(), computerIndex, computerIndex);
|
beginRemoveRows(QModelIndex(), computerIndex, computerIndex);
|
||||||
|
|
||||||
@@ -166,7 +166,7 @@ private:
|
|||||||
|
|
||||||
void ComputerModel::wakeComputer(int computerIndex)
|
void ComputerModel::wakeComputer(int computerIndex)
|
||||||
{
|
{
|
||||||
Q_ASSERT(computerIndex < m_Computers.count());
|
Q_ASSERT(computerIndex >= 0 && computerIndex < m_Computers.count());
|
||||||
|
|
||||||
DeferredWakeHostTask* wakeTask = new DeferredWakeHostTask(m_Computers[computerIndex]);
|
DeferredWakeHostTask* wakeTask = new DeferredWakeHostTask(m_Computers[computerIndex]);
|
||||||
QThreadPool::globalInstance()->start(wakeTask);
|
QThreadPool::globalInstance()->start(wakeTask);
|
||||||
@@ -174,7 +174,7 @@ void ComputerModel::wakeComputer(int computerIndex)
|
|||||||
|
|
||||||
void ComputerModel::renameComputer(int computerIndex, QString name)
|
void ComputerModel::renameComputer(int computerIndex, QString name)
|
||||||
{
|
{
|
||||||
Q_ASSERT(computerIndex < m_Computers.count());
|
Q_ASSERT(computerIndex >= 0 && computerIndex < m_Computers.count());
|
||||||
|
|
||||||
m_ComputerManager->renameHost(m_Computers[computerIndex], name);
|
m_ComputerManager->renameHost(m_Computers[computerIndex], name);
|
||||||
}
|
}
|
||||||
@@ -215,7 +215,7 @@ void ComputerModel::testConnectionForComputer(int)
|
|||||||
|
|
||||||
void ComputerModel::pairComputer(int computerIndex, QString pin)
|
void ComputerModel::pairComputer(int computerIndex, QString pin)
|
||||||
{
|
{
|
||||||
Q_ASSERT(computerIndex < m_Computers.count());
|
Q_ASSERT(computerIndex >= 0 && computerIndex < m_Computers.count());
|
||||||
|
|
||||||
m_ComputerManager->pairHost(m_Computers[computerIndex], pin);
|
m_ComputerManager->pairHost(m_Computers[computerIndex], pin);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -266,7 +266,7 @@ bool StreamUtils::getNativeDesktopMode(int displayIndex, SDL_DisplayMode* mode,
|
|||||||
CGDirectDisplayID displayIds[MAX_DISPLAYS];
|
CGDirectDisplayID displayIds[MAX_DISPLAYS];
|
||||||
uint32_t displayCount = 0;
|
uint32_t displayCount = 0;
|
||||||
CGGetActiveDisplayList(MAX_DISPLAYS, displayIds, &displayCount);
|
CGGetActiveDisplayList(MAX_DISPLAYS, displayIds, &displayCount);
|
||||||
if (displayIndex >= (int)displayCount) {
|
if (displayIndex < 0 || displayIndex >= (int)displayCount) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,7 +343,7 @@ bool StreamUtils::getNativeDesktopMode(int displayIndex, SDL_DisplayMode* mode,
|
|||||||
#else
|
#else
|
||||||
SDL_assert(SDL_WasInit(SDL_INIT_VIDEO));
|
SDL_assert(SDL_WasInit(SDL_INIT_VIDEO));
|
||||||
|
|
||||||
if (displayIndex >= SDL_GetNumVideoDisplays()) {
|
if (displayIndex < 0 || displayIndex >= SDL_GetNumVideoDisplays()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user