Plug-in code working differently when called directly and when run under Plugin Creator

• Aug 6, 2015 - 23:38
Priority
P3 - Low
Type
Plugins
Frequency
Once
Severity
S4 - Minor
Reproducibility
Always
Status
active
Regression
No
Workaround
No
Project

While attempting to use in a dialogue plug-in of mines a combo box dynamically filled, I discovered that a procedure which works correctly if run from the Plugin Creator, no longer works if the plug-in is run directly.

Context: all versions from 2.0.0 to current github master code, run under Linux Mint 17.1.

Reference: some discussion at https://musescore.org/en/node/71081

Sample code: this is a minimal plug-in (of the dialogue type) which just displays a combo box and fills it with strings at run time (just some boring "Name 0", "Name 1", ... strings).

The combo box is correctly filled if the plug-in is run from the Plugin Creator, but remains empty if the plug-in is run directly from the "Plugins" menu.

Note that, in both cases, the dynamically created strings are correctly inserted in the ListModel attached to the ComboBox (as the few diagnostic logs at the end show), but this seems not to affect the combo box itself.

1) Anybody can confirm (or falsify) this under other platforms?

2) Can anybody explain the difference?

Thanks!

import QtQuick 2.0
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.1
import MuseScore 1.0

MuseScore
{
version:	"2.0"
description:	qsTr("To test ComboBox working")
menuPath:	"Plugins.Test Combo"
pluginType:	"dialog"

//
//	The UI
//

id:	window
property	int	wdgMargin:	8
property	int	wndWidth:	300
property	int	wndHeight:	200
width:		wndWidth;
height:		wndHeight;

RowLayout
{
	id:			rowSelect
	anchors.top:		window.top
	anchors.left:		window.left
	anchors.right:		window.right
	anchors.margins:	window.wdgMargin
	spacing:		window.wdgMargin
	Label
	{
		id:			label
		text:			qsTr("Combo:")
		Layout.alignment:	Qt.AlignVCenter
	}
	ComboBox
	{
		id:			combo
		Layout.fillWidth:	true
		model: ListModel
		{
			id: listModel
		}
	}
}

//
// Components and Methods
//

onRun:		{ init(); }

//-------------------------------------------------------------------
//	init()
//	initializes the combo box. Called by main object's onRun().
//-------------------------------------------------------------------

function init()
{
	var	i;
	var	names	= [];

	// fill the combo box
//	combo.textRole = "text";			// does anything at all?
	for (i = 0; i < 5; i++)
		names[i] = { "text": "Name " + i };
	listModel.append(names);
// some diagnostics
console.log("Combo text role: " + combo.textRole);
console.log("Num. of names in list model: " + listModel.count);
var model = combo.model;
console.log("Model: " + model);
for (i = 0; i < combo.count; i++)
	console.log("Name " + i + ": " + model.get(i).text);
}

}		// plugin end


Comments

I can't tell you the cause, but this behavior is something I have already seen.
That's why I pushed this commit: c6ad7f596
where I substituted the onRun with onCompleted. It seemed that the component was shown before it was updated with the relevant changes. Probably by comparing the differences in the code between mscorePlugins.cpp and pluginCreator.cpp we could understand why in one case it is updating and not in the other one.
Actually, when I proposed the PR, I didn't check the behavior inside pluginCreator.
Maybe the instruction view->raise();?

EDIT: No, the raise instruction didn't change anything in my build (Windows 8.1)

Frequency Once
Priority P3 - Low
Regression No
Reproducibility Always
Workaround No

Confirmed for 3.0. I am assigning it a low priority since I am not sure how many people are really affected, in case there are more requests the priority may be raised.