<div dir="ltr"><div><div><div>Ahh indeed, you are right... I should have paid attention to the Class in which I found the signal. But I was too obsessed by composerWillBeRemoved that I thought I was still in QgisInterface.<br></div>If it can be added to QgisInterface, why not?<br></div>Any idea about my remark on Qt.QueuedConnection and architecture 64bits vs 32bits?<br></div><div><br></div>In the meantime, I think I'll keep the refresh button and find a simple way to deal with the case user doesn't refresh before executing (it might not be that hard :) ). And in this case, I also keep compatibility with all 2.x releases.<br></div><div class="gmail_extra"><br><div class="gmail_quote">2015-04-08 0:16 GMT+02:00 Matthias Kuhn <span dir="ltr"><<a href="mailto:matthias@opengis.ch" target="_blank">matthias@opengis.ch</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
It's in QgisApp but not in QgisInterface.<br>
<br>
It is only used internally by the app (in the composermanager for
exactly the same purpose as you are trying to use it for AFAICS).<br>
Anyway, I don't see any reason not to make this available on the
public interface as well...<div><div class="h5"><br>
<br>
<div>On 04/07/2015 11:51 PM, Junior Delaz
wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">But why does composerRemoved not work? You can find
it in the code on github repo but not on QGIS API website...<br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">2015-04-07 23:35 GMT+02:00 Matthias
Kuhn <span dir="ltr"><<a href="mailto:matthias@opengis.ch" target="_blank">matthias@opengis.ch</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> Oops,<br>
<br>
That should have been composerWillBeRemoved<br>
<br>
Sorry for that...<span><font color="#888888"><br>
<br>
Matthias</font></span>
<div>
<div><br>
<br>
<div>On 04/07/2015 10:07 PM, Junior Delaz wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div><font>Thank you Matthias for your
perseverance. It's very helpful and
encouraging for beginners.<br>
</font></div>
<font>I have already tried composerRemoved but
when loading the plugin, QGIS complains :</font><br>
<span style="color:rgb(255,0,0)"><br>
Impossible de charger l'extension MapsPrinter
provoque une erreur lors de l'appel de sa
méthode initGui()</span><br>
<pre style="margin:12px 0px;text-indent:0px"><span style="font-family:"Courier New,courier"">Traceback (most recent call last):
File "C:/OSGeo4W/apps/qgis/./python\qgis\utils.py", line 228, in startPlugin
plugins[packageName].initGui()
File "C:/Users/harrissou/.qgis2/python/plugins\MapsPrinter\maps_printer.py", line 129, in initGui
self.iface.composerRemoved.connect(self.refreshList)
AttributeError: 'QgisInterface' object has no attribute 'composerRemoved'
</span></pre>
<pre style="margin:12px 0px;text-indent:0px"><font size="4"><span style="font-family:"Courier New,courier"">This happens with all the versions of QGIS I use :
- osgeo4w 32bits (windows 8), </span></font><font size="4"><span style="font-family:"Courier New,courier""><font size="4"><span style="font-family:"Courier New,courier"">osgeo4w </span></font>64bits (windows 7): either with QGIS 2.8, 2.8rel-dev and 2.9
- and Mac OS 10.9 (it is a QGIS 2.4 but composerRemoved is supposed to have been added since QGIS 2.3 [0])
</span></font></pre>
<pre style="margin:12px 0px;text-indent:0px"><font size="4"><span style="font-family:"Courier New,courier"">About Qt.QueuedConnection, my first tests were on the Mac OS (x86-64) and Osgeo4w 64bits versions. But I never encountered crash with the 32 bits version, using the same code. Can the bug be bound to the architecture?
</span></font></pre>
<pre style="margin:12px 0px;text-indent:0px"><font size="4"><span style="font-family:"Courier New,courier"">[0] </span></font><a href="https://github.com/qgis/QGIS/blob/master/src/app/qgisapp.h#L1260" target="_blank">https://github.com/qgis/QGIS/blob/master/src/app/qgisapp.h#L1260</a>
</pre>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">2015-04-06 22:11
GMT+02:00 Matthias Kuhn <span dir="ltr"><<a href="mailto:matthias@opengis.ch" target="_blank">matthias@opengis.ch</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> Hi
Junior,<br>
<br>
The following lines work for a short
test-case.<br>
<br>
def compAdded( composer ):<br>
print composer<br>
<br>
def compRemoved( composer ):<br>
print composer<br>
<br>
iface.composerAdded.connect( compAdded )<br>
iface.composerRemoved.connect( compRemoved )<br>
<br>
It is possible that the QueuedConnection
crashes because along with it a composer is
emitted which at the time the slot is
executed is already deleted. That was only a
possible approach which I did not test and
reading your report seems unstable.<span><font color="#888888"><br>
<br>
Matthias</font></span>
<div>
<div><br>
<br>
<div>On 04/06/2015 12:33 AM, Junior
Delaz wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div>
<div>Hi,<br>
</div>
I do understand nothing.<br>
</div>
<div>After I read your message,
Matthias, I told myself that using
QT. QueuedConnection should be the
easiest way. Then i wrote <br>
self.iface.composerWillBeRemoved.connect(self.refreshList,
Qt.QueuedConnection)<br>
But each time i delete a composer,
QGIS crashes.<br>
</div>
<div>So I've spent the week on
reading about Qt.QueuedConnection
and then signal and slots,
function partial, QSignalMapper,
sender trying to understand how I
can catch the sender and manage to
update my list. All this without
success in the code.<br>
</div>
<div>And today, I tried again
Qt.QueuedConnection, QGIS crashed.
Without any changes, I tried again
and it worked and continues to
work. Adding and deleting composer
in the composer manager echoes in
my list.<br>
</div>
<div>I hope it will remain like
that. <br>
</div>
<div><br>
</div>
<div>But now I realize that I didn't
take into account the renaming of
a composer. :(<br>
<br>
</div>
<div>I think I'd wisely keep the
refreshlist button unless someone
tells me how I can reach the
composer manager dialog
programmatically. So that I will
try to synchronize my list with
its widgetlistitems...<br>
</div>
<div><br>
</div>
<div>Thanks for all...<br>
</div>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">2015-03-31
14:50 GMT+02:00 Matthias Kuhn <span dir="ltr"><<a href="mailto:matthias@opengis.ch" target="_blank">matthias@opengis.ch</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> You should get
a parameter containing the
composer that is being deleted
with composerWillBeRemoved
signal. Try to use that to
infer which composer has been
removed. As the signal name
indicates, at the time it is
emitted, the composer is not
deleted yet.<br>
As an alternative you may make
the connection with
Qt.QueuedConnection. It is
possible that with this
connection style you will
receive the signal after
deletion and are able to
continue using your current
update method.<br>
<br>
Best<span><font color="#888888"><br>
Matthias</font></span>
<div>
<div><br>
<br>
<div>On 03/31/2015 02:04
PM, Junior Delaz wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>Matthias,<br>
</div>
Thanks. I just
give it a try
it and all
goes well with
composerAdded.
<br>
</div>
But not really
well with
composerWillBeRemoved
signal. The
first deletion
in the
composer
manager does
nothing and
deleting a
second
composer does
remove the
first one in
my list. and
so on...<br>
My update
function
should be
rewritten I
think. I'll
try to see how
improving it
and may
(surely) ask
again for help
(if needed).<br>
</div>
<br>
</div>
</div>
While seeking
information about
composerWillBeRemoved,
I found a
composerRemoved [1]
[2] signal (that
doesn't appear in
the API doc) and
without being able
to use it. :(<br>
[1] <a href="https://github.com/qgis/QGIS/blob/master/src/app/composer/qgscomposermanager.cpp" target="_blank">https://github.com/qgis/QGIS/blob/master/src/app/composer/qgscomposermanager.cpp</a>
(line 48<br>
[2] <a href="https://github.com/qgis/QGIS/blob/master/src/app/qgisapp.cpp" target="_blank">https://github.com/qgis/QGIS/blob/master/src/app/qgisapp.cpp</a>
(line 5601)<br>
<br>
</div>
Another thing that may
not be related : what
the
deletePrintComposers
function (<a href="https://github.com/qgis/QGIS/blob/master/src/app/qgisapp.cpp" target="_blank">https://github.com/qgis/QGIS/blob/master/src/app/qgisapp.cpp</a>
line 5698) is for?<br>
<br>
Thanks again for the
clue.</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">2015-03-31
9:43 GMT+02:00
Matthias Kuhn <span dir="ltr"><<a href="mailto:matthias@opengis.ch" target="_blank">matthias@opengis.ch</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
QgisInterface
(iface) has a
composerAdded
and
composerWillBeRemoved
signal.<br>
<br>
Did you try to
connect to
these?<br>
<br>
Best,<br>
Matthias
<div>
<div><br>
<br>
<div>On
03/31/2015
09:34 AM,
Junior wrote:<br>
</div>
<blockquote type="cite">
<div style="font-family:'Calibri','sans-serif'">
<div>Hi all,
Luca</div>
<div>Thanks for
answering. But
i already have
an update
function that
I linked to an
update list
button. I even
linked it to
the icon on
the toolbar so
that when user
calls
foreground the
dialog it's
already
updated.</div>
<div>The case
I'd like to
manage: user
can open
plugin dialog
and composer
manager. The
two dialogs
are visible
(to the eyes)
even
though composer
manager is the
one at
foreground. He
makes changes
and directly
clicked on the
plugin dialog.
He should
update list
but if he
forgets and
executes, this
may lead to
bug I don't
want to /
can't yet
manage.</div>
<div>Reason
why I want to
ensure that
list is always
up to date
when he
interacts with
the dialog</div>
<div><br>
</div>
<div>Envoyé
depuis mon HTC</div>
<br>
<div>-----
Reply message
-----<br>
De : "Luca
Manganelli" <a href="mailto:luca76@gmail.com" target="_blank"><luca76@gmail.com></a><br>
Pour :<br>
Cc : <a href="mailto:qgis-user@lists.osgeo.org" target="_blank">"qgis-user@lists.osgeo.org"</a>
<a href="mailto:qgis-user@lists.osgeo.org" target="_blank"><qgis-user@lists.osgeo.org></a>,
"qgis-developer"
<a href="mailto:qgis-developer@lists.osgeo.org" target="_blank"><qgis-developer@lists.osgeo.org></a><br>
Objet :
[Qgis-developer]
[Qgis-user]
Pyqt4 : which
signal is sent
when dialog
comes to
foreground?<br>
Date : mar.,
mars 31, 2015
07:56</div>
</div>
<br>
<pre style="word-wrap:break-word;white-space:pre-wrap">On Mon, Mar 30, 2015 at 6:12 PM, Junior Delaz <a href="mailto:delazj@gmail.com" target="_blank"><delazj@gmail.com></a> wrote:
> I've read about defining a custom showEvent function but can't understand
> where to put it and what inside.
> If somebody can give some tips...
You could add a "Update list" button
_______________________________________________
Qgis-developer mailing list
<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
</pre>
<br>
<fieldset></fieldset>
<br>
<pre>_______________________________________________
Qgis-developer mailing list
<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a></pre>
</blockquote>
<br>
</div>
</div>
</div>
<br>
_______________________________________________<br>
Qgis-developer
mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</div></div></div>
</blockquote></div><br></div>