Re: [Interest] QDesktopServices::openUrl() without inheriting environment?

2020-10-23 Thread Nikos Chantziaras

On 23/10/2020 18:50, Olivier B. wrote:
An application needs custom library search path to use it's own versions 
of external libraries.


You should look into doing that at link-time, not runtime. With a qmake 
project, you should be able to add:


  QMAKE_RPATHDIR += lib

in the project file. Make sure it's a relative directory. In this 
example, the runtime loader will look for a "lib" directory in the same 
directory as the executable and prefer libraries that exist there. This 
uses the linker's $ORIGIN feature to do this.


This means you don't have to set LD_LIBRARY_PATH prior to starting your 
application and thus external processes launched through 
QDesktopServices::openUrl() will not use your bundled libs.


You can also something like "../lib" instead, if your application's 
directory structure uses the traditional "bin" and "lib" layout. The 
important thing is whatever you specify is a relative path.


___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] QDesktopServices::openUrl() without inheriting environment?

2020-10-23 Thread Thiago Macieira
On Friday, 23 October 2020 08:50:07 PDT Olivier B. wrote:
> Is there a way to still use the mechanism to find the application to use
> from system settings, but launch the command with the default system
> environment, not the one inherited from the application's process
> (something like calling the command with env -i) ?

No, there's no such code in Qt and it's not likely we'll ever have it.

Second, you can't clean the environment. At the very least you need the 
DISPLAY and XAUTHORITY variables, possibly all of the XDG_* ones too.

You're far more likely to be able to remove the variables you don't want / 
need from the application's own environment using unsetenv(3).

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel DPG Cloud Engineering



___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] QSharedpointer members are not accessible: isNull and data

2020-10-23 Thread Thiago Macieira
On Friday, 23 October 2020 05:16:08 PDT Tamás Nagy wrote:
> QSharedPointer m_Validator;
> }
> 
> My custom program:
> 
>  if(di.Validator()->isNull())

Are you sure -> is the right operator here?

You didn't give us the implementation of this Validator function, so we have 
to guess. If it is:

QSharedPointer () { return m_validator; }

Then -> is wrong. The type returned by -> is QValidator and that one has no 
isNull() method.

If it is

QSharedPointer *Validator() { return _validator; }

Then -> would be correct but then there's a further problem in your code, 
where you use validator.data().

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel DPG Cloud Engineering



___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] QDesktopServices::openUrl() without inheriting environment?

2020-10-23 Thread Olivier B.
An application needs custom library search path to use it's own versions of
external libraries.
But because of this, when opening files in external applications
using QDesktopServices::openUrl(), the system applications (browser)
registered for the file type will first try to use the application's
version of the libraries, instead of the system ones the browser is
supposed to depend on.
FreeType dependency in particular, seems to make executables that depend on
libfreetype.so.6, name which has been used at least between version 2.6 and
2.9. The newer ones having additional new symbols. The application, here,
uses a 2.7 Freetype, but the browser needs at least FreeType 2.9, so
launching the browser from the application fails because the newer Freetype
symbols are not found.

Is there a way to still use the mechanism to find the application to use
from system settings, but launch the command with the default system
environment, not the one inherited from the application's process
(something like calling the command with env -i) ?
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] QSharedpointer members are not accessible: isNull and data

2020-10-23 Thread Giuseppe D'Angelo via Interest

Hi,

On 23/10/2020 14:16, Tamás Nagy wrote:

class A
{
public:

private:
 QSharedPointer m_Validator;
}

My custom program:

  if(di.Validator()->isNull())
  {
 // unfortunately the di.Validator() is null
 // some A-s in the Map can have nullptr as Validator.

 if(auto validator = di.Validator())   // di is an instance of A
 {
 if(validator != nullptr)
 {


I'm having quite a hard time understanding this code.

In the first if, you dereference the result of di.Validator(). This 
implies it's not null.


Then immediately after you fetch di.Validator() again, assign it to 
"validator", and in the second if you ask if it's not null -- but... you 
already know?.


Then in the third if you ask *again*. What's going on here?

Can you put together a minimal but complete, correct, and compileable 
testcase?


Thanks,
--
Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts



smime.p7s
Description: S/MIME Cryptographic Signature
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] QSharedpointer members are not accessible: isNull and data

2020-10-23 Thread Tamás Nagy
Hi,

class A
{
public:

private:
QSharedPointer m_Validator;
}

My custom program:

 if(di.Validator()->isNull())
 {
// unfortunately the di.Validator() is null
// some A-s in the Map can have nullptr as Validator.

if(auto validator = di.Validator())   // di is an instance of A
{
if(validator != nullptr)
{
// old code that doesn't compile anymore with Qt 5.12.3
//QDomElement dom =
HelperS::Instance()->ValidatorToDomElement(validator.data());
// new code that compiles with Qt 5.12.3
QDomElement dom =
HelperS::Instance()->ValidatorToDomElement(di.Validator());

parameter.appendChild(dom);   // TNagy: .data removed
}
}
 }

The problem is that in spite of the QSharedPointer, the members of the
QSharedPointer:
.data() and .isNull() are not accessible at all. I also tried
parentheses but no success.
Sometimes the Validators can be null sometimes not. I have to check if
it is null or not.

What is the problem with the QSharedPointer, why is it not visible in that case?
If I try to use the intellisense on the di.Validator. it lists only
the members of the QValidator.

Tamas
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest