@@ -105,7 +105,7 @@ void ApplicationList::SaveSettings()
105105 QStringList params;
106106
107107 for (int i = 0 ; i < GetApplicationCount (); i++) {
108- Application app = GetApplication (i);
108+ const Application& app = GetApplication (i);
109109 names << app.getName ();
110110 paths << app.getPath ();
111111 params << app.getParameters ();
@@ -115,28 +115,31 @@ void ApplicationList::SaveSettings()
115115 settings.setValue (SETTINGS_APPLICATION_PATHS, paths);
116116 settings.setValue (SETTINGS_APPLICATION_PARAMS, params);
117117 settings.setValue (SETTINGS_APPLICATION_DEFAULT, mDefaultApplicationIndex );
118-
119118}
120119
121120int ApplicationList::GetApplicationCount () const
122121{
123122 return mApplications .size ();
124123}
125124
126- Application ApplicationList::GetApplication (const int index) const
125+ Application& ApplicationList::GetApplication (const int index)
127126{
128127 if (index >= 0 && index < mApplications .size ()) {
129128 return mApplications [index];
130129 }
131130
132- return Application (QString (), QString (), QString ());
131+ static Application dummy; // TODO: Throw exception instead?
132+ return dummy;
133133}
134134
135- void ApplicationList::SetApplication ( int index, const Application &app)
135+ const Application& ApplicationList::GetApplication ( const int index) const
136136{
137137 if (index >= 0 && index < mApplications .size ()) {
138- mApplications . replace ( index, app) ;
138+ return mApplications [ index] ;
139139 }
140+
141+ static const Application dummy; // TODO: Throw exception instead?
142+ return dummy;
140143}
141144
142145void ApplicationList::AddApplication (const Application &app)
@@ -167,7 +170,7 @@ void ApplicationList::Copy(const ApplicationList *list)
167170
168171 Clear ();
169172 for (int i = 0 ; i < list->GetApplicationCount (); i++) {
170- const Application app = list->GetApplication (i);
173+ const Application& app = list->GetApplication (i);
171174 AddApplication (app);
172175 }
173176 mDefaultApplicationIndex = list->GetDefaultApplication ();
0 commit comments