Skip to content

Commit e40991e

Browse files
author
timlinux
committed
Fix bug in plugin manager introduced by recent changes I made that causes it to not remember loaded plugns properly
git-svn-id: http://svn.osgeo.org/qgis/trunk@8792 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 82971f4 commit e40991e

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/app/qgspluginmanager.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,7 @@ void QgsPluginManager::getPythonPluginDescriptions()
161161
//myData.setIcon(pixmap); //todo use a python logo here
162162
myData.setCheckable(true);
163163
myData.setRenderAsWidget(false);
164-
QVariant myVariant = qVariantFromValue(myData);
165-
mypDetailItem->setData(myVariant,PLUGIN_DATA_ROLE);
164+
myData.setChecked(false); //start off assuming false
166165

167166
// check to see if the plugin is loaded and set the checkbox accordingly
168167
QgsPluginRegistry *pRegistry = QgsPluginRegistry::instance();
@@ -177,9 +176,11 @@ void QgsPluginManager::getPythonPluginDescriptions()
177176
if (libName == packageName)
178177
{
179178
// set the checkbox
180-
mypDetailItem->setCheckState(Qt::Checked);
179+
myData.setChecked(true);
181180
}
182181
}
182+
QVariant myVariant = qVariantFromValue(myData);
183+
mypDetailItem->setData(myVariant,PLUGIN_DATA_ROLE);
183184
// Add item to model
184185
mModelPlugins->appendRow(mypDetailItem);
185186
}
@@ -358,7 +359,9 @@ void QgsPluginManager::unload()
358359
{
359360
// FPV - I want to use index. You can do evrething with item.
360361
QModelIndex myIndex=mModelPlugins->index(row,0);
361-
if (mModelPlugins->data(myIndex,Qt::CheckStateRole).toInt() == 0)
362+
QgsDetailedItemData myData =
363+
qVariantValue<QgsDetailedItemData>(mModelPlugins->data(myIndex,PLUGIN_DATA_ROLE));
364+
if (!myData.isChecked())
362365
{
363366
// iThe plugin name without version string in its data PLUGIN_LIB [ts]
364367
myIndex=mModelPlugins->index(row,0);
@@ -402,7 +405,10 @@ std::vector < QgsPluginItem > QgsPluginManager::getSelectedPlugins()
402405
// FPV - I want to use item here. You can do everything with index if you want.
403406
for (int row=0;row < mModelPlugins->rowCount();row++)
404407
{
405-
if (mModelPlugins->item(row,0)->checkState() == Qt::Checked)
408+
QgsDetailedItemData myData =
409+
qVariantValue<QgsDetailedItemData>(mModelPlugins->item(row,0)->data(PLUGIN_DATA_ROLE));
410+
411+
if (myData.isChecked())
406412
{
407413
QString pluginName = mModelPlugins->item(row,0)->data(PLUGIN_LIBRARY_NAME_ROLE).toString();
408414
bool pythonic = false;

0 commit comments

Comments
 (0)