Skip to content

Commit

Permalink
Fixes #13984 custom python init function config is lost in master
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Dec 14, 2015
1 parent 36267f5 commit 8c4d810
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/qgseditformconfig.cpp
Expand Up @@ -140,8 +140,8 @@ void QgsEditFormConfig::readXml( const QDomNode& node )
if ( dotPos >= 0 ) // It's a module
{
setInitCodeSource( QgsEditFormConfig::CodeSourceDialog );
setInitFunction( mInitFunction.mid( dotPos + 1 ) );
setInitCode( QString( "from %1 import %2\n" ).arg( mInitFunction.left( dotPos ), mInitFunction.mid( dotPos + 1 ) ) );
setInitFunction( mInitFunction.mid( dotPos + 1 ) );
}

QDomNode editFormInitFilePathNode = node.namedItem( "editforminitfilepath" );
Expand Down

5 comments on commit 8c4d810

@3nids
Copy link
Member

@3nids 3nids commented on 8c4d810 Dec 17, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not convinced this take care of all the situations. I am getting crashes when opening forms and apparently this is due to a wrong configuration of ui and/or python code.
It would have be good to check that old projects are properly migrated.
I don't mind reconfiguring my projects, but it would be quite annoying if people get crashes with next LTR.

@elpaso
Copy link
Contributor Author

@elpaso elpaso commented on 8c4d810 Dec 17, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you help me providing the projects that crashes?
Of course it shouldn't crash whatever the user (or the import old projects patch) writes into initfunction or initcode.

@3nids
Copy link
Member

@3nids 3nids commented on 8c4d810 Dec 17, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems that the new behavior with load external file is not working properly either.
see my comment in PR #2498 for the code I use.

I can't provide a QGIS project, it comes with a large DB and many external files, and I don't have a 2.12 built anymore.

@3nids
Copy link
Member

@3nids 3nids commented on 8c4d810 Dec 17, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am using load from externalfile with this file:


from PyQt4 import uic
from PyQt4.QtGui import QComboBox, QWidget

subForms = None

def formOpen(dialog, layer, feature):

    typeSelector = dialog.findChild(QComboBox, 'installation_type')
    typeSelector.currentIndexChanged.connect(typeSelection)

    global subForms
    subForms = []

    for i in range(0, typeSelector.count()):
        widgetName = typeSelector.itemData(i)
        childWidget = dialog.findChild(QWidget, widgetName)
        subForms.append(childWidget)

    typeSelection(typeSelector.currentIndex())


def typeSelection( index ):
    for i, widget in enumerate(subForms):
        widget.setVisible( i == index )

I have formOpen for function name

Here is the error I get

An error occured during execution of following code:

from PyQt4 import uic
from PyQt4.QtGui import QComboBox, QWidget

subForms = None

def formOpen(dialog, layer, feature):

typeSelector = dialog.findChild(QComboBox, 'installation_type')
typeSelector.currentIndexChanged.connect(typeSelection)

global subForms
subForms = []

for i in range(0, typeSelector.count()):
widgetName = typeSelector.itemData(i)
childWidget = dialog.findChild(QWidget, widgetName)
subForms.append(childWidget)

typeSelection(typeSelector.currentIndex())


def typeSelection( index ):
for i, widget in enumerate(subForms):
widget.setVisible( i == index )



Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'formOpen' is not defined

@3nids
Copy link
Member

@3nids 3nids commented on 8c4d810 Dec 17, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does find the code, but can't find formOpen, am I doing something wrong?

Please sign in to comment.