Skip to content
Permalink
Browse files

Fixes #13984 custom python init function config is lost in master

  • Loading branch information
elpaso committed Dec 14, 2015
1 parent 36267f5 commit 8c4d81023b24ac3bbce4c7e625c11095baf6c24a
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/core/qgseditformconfig.cpp
@@ -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" );

5 comments on commit 8c4d810

@3nids

This comment has been minimized.

Copy link
Member

@3nids 3nids replied Dec 17, 2015

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

This comment has been minimized.

Copy link
Contributor Author

@elpaso elpaso replied Dec 17, 2015

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

This comment has been minimized.

Copy link
Member

@3nids 3nids replied Dec 17, 2015

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

This comment has been minimized.

Copy link
Member

@3nids 3nids replied Dec 17, 2015

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

This comment has been minimized.

Copy link
Member

@3nids 3nids replied Dec 17, 2015

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

Please sign in to comment.
You can’t perform that action at this time.