D23326: Fix a crash when running 'amarok -l /path/to/file'

2019-08-21 Thread Christophe Giboudeaux
cgiboudeaux created this revision.
Herald added subscribers: amarok-devel, Amarok.
cgiboudeaux requested review of this revision.

REVISION SUMMARY
  BUG: 410870

TEST PLAN
  amarok -l 
  
  Before: Assert "you need to call AmarokConfig::instance before using"
  
  After: the file is queued and played.

REPOSITORY
  R181 Amarok

BRANCH
  master

REVISION DETAIL
  https://phabricator.kde.org/D23326

AFFECTED FILES
  src/App.cpp

To: cgiboudeaux
Cc: #amarok, amarok-devel


Re: [amarok] cmake/modules: Revert FindMySQLAmarok.cmake fix argumets when calling mysql_config

2011-12-19 Thread Christophe Giboudeaux
On Sunday 18 December 2011 23:27:08 =?utf-8?B?TWF0xJtq?= Laitl wrote:
 On 18. 12. 2011 Christophe Giboudeaux wrote:
  Revert FindMySQLAmarok.cmake fix argumets when calling mysql_config
  This reverts a fix for -Wmissing-include-dirs warnings.
  MYSQL_INCLUDE_DIR must be a path and not contain -Ipath

 Sorry about the incorrect fix, I will build with -Wmissing-include-dirs from
 now on. However I wonder how to fix the original problem.

Your commit doesn't mention the issue you're trying to fix. However, having
the same directory included several times is not an issue (and I'm not aware
of any GCC flag that would throw a warning).


 Would it be legal to remove MYSQL_INCLUDE_DIR entirely and just rely on
 MYSQL_CFLAGS to specify -I/path/to/mysql ?


Well, they don't have the same purpose. MYSQL_CFLAGS is used by the compiler
(used in 'add_definitions..' lines) while MYSQL_INCLUDE_DIR is used by cmake.

Also, if mysql_config is not available, MYSQL_CFLAGS is empty and you can only
count on MYSQL_INCLUDE_DIR.

 E.g. is cmake's include_directories(/dir) just a syntactic sugar for
 add_definitions(-I/dir) or it would break build on non-gcc platforms? I'd
 rather avoid filtering -I out of MYSQL_INCLUDE_DIR in CMakeLists.


Without hint about what you're trying to fix, it's hard to answer this
question.


Christophe


signature.asc
Description: This is a digitally signed message part.
___
Amarok-devel mailing list
Amarok-devel@kde.org
https://mail.kde.org/mailman/listinfo/amarok-devel


Re: [amarok] cmake/modules: Revert FindMySQLAmarok.cmake fix argumets when calling mysql_config

2011-12-19 Thread Christophe Giboudeaux
On Monday 19 December 2011 00:38:47 =?utf-8?B?TWF0xJtq?= Laitl wrote:
 On 19. 12. 2011 Christophe Giboudeaux wrote:
  On Sunday 18 December 2011 23:27:08 Matej Laitl wrote:
   Sorry about the incorrect fix, I will build with -Wmissing-include-dirs
   from now on. However I wonder how to fix the original problem.
  
  Your commit doesn't mention the issue you're trying to fix. However,
  having
  the same directory included several times is not an issue (and I'm not
  aware of any GCC flag that would throw a warning).
 
 Ah, I tried to solve http://mail.kde.org/pipermail/amarok-devel/2011-
 December/009663.html
 
 Specifically, the problem is that mysql_config (since at least 5.1.56)
 doesn't accept --variable=pkgincludedir - it accepts only --include
 argument which returns something like -I/usr/include/mysql

 -- Found MySQL: Usage: /usr/bin/mysql_config [OPTIONS]
[cut]

 So I guess we'll have to strip that -I out of `mysql_config --include`. Can
 we safely assume that it is only a single directory?
 

ok, then it only exists in higher version (the option exists in 5.5.x). 

I see two solutions: 
- only rely on find_path(MYSQL_INCLUDE_DIR...), so move it outside the 
else(MYSQLCONFIG_EXECUTABLE) loop  [1]

- Drop FindMysqlAmarok.cmake and use FindAmarok.cmake from kdelibs instead 
(which worked fine here).

I prefer the second solution as the FindMysql from kdelibs is really cleaner 
than the Amarok copy:

- MYSQL_CFLAGS doesn't look that important

- the linked targets gathered with 'mysql_config --libs' are already 
explicitly added in the CMakeLists.txt files (./src/core-
impl/collections/db/sql/mysqlecollection/CMakeLists.txt, ./src/core-
impl/collections/db/sql/mysqlservercollection/CMakeLists.txt and some unit 
tests) and the output variable is different if mysql_config is not present:

  * with mysql_config, MYSQL_LIBRARIES=-L/usr/lib64 -lmysqlclient -lpthread -
lz -lm -lrt -lssl -lcrypto -ldl
  * without it, MYSQL_LIBRARIES=/usr/lib64/libmysqlclient.so. The second one 
is enough

- the kdelibs FindAmarok has better chances to detect mysql.h under Windows,
- and it also uses a cleaner way to decide if mysqle is there.


The first solution is the easy one, the second one needs more testing on 
different platforms/distributions.

Christophe

[1] attached: fixMySQLAmarok.diff
diff --git a/cmake/modules/FindMySQLAmarok.cmake b/cmake/modules/FindMySQLAmarok.cmake
index 74805ca..44a3fb5 100644
--- a/cmake/modules/FindMySQLAmarok.cmake
+++ b/cmake/modules/FindMySQLAmarok.cmake
@@ -16,8 +16,18 @@ if(NOT WIN32)
 find_program(MYSQLCONFIG_EXECUTABLE NAMES mysql_config mysql_config5 PATHS ${BIN_INSTALL_DIR} ~/usr/bin /usr/local/bin)
 endif(NOT WIN32)
 
+find_path(MYSQL_INCLUDE_DIR mysql.h
+/opt/local/include/mysql5/mysql
+/opt/mysql/mysql/include
+/opt/mysqle/include/mysql
+/opt/ports/include/mysql5/mysql
+/usr/include/mysql
+/usr/local/include/mysql
+/usr/mysql/include/mysql
+~/usr/include/mysql
+)
+
 if(MYSQLCONFIG_EXECUTABLE)
-exec_program(${MYSQLCONFIG_EXECUTABLE} ARGS --variable=pkgincludedir RETURN_VALUE _return_VALUE OUTPUT_VARIABLE MYSQL_INCLUDE_DIR)
 exec_program(${MYSQLCONFIG_EXECUTABLE} ARGS --cflags RETURN_VALUE _return_VALUE OUTPUT_VARIABLE MYSQL_CFLAGS)
 exec_program(${MYSQLCONFIG_EXECUTABLE} ARGS --libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE MYSQL_LIBRARIES)
 exec_program(${MYSQLCONFIG_EXECUTABLE} ARGS --libmysqld-libs RETURN_VALUE _return_VALUE OUTPUT_VARIABLE MYSQL_EMBEDDED_LIBSTEMP)
@@ -49,18 +59,6 @@ if(MYSQLCONFIG_EXECUTABLE)
 
 else(MYSQLCONFIG_EXECUTABLE)
 
-find_path(MYSQL_INCLUDE_DIR mysql.h
-   ~/usr/include/mysql
-   /opt/local/include/mysql5/mysql
-   /opt/mysqle/include/mysql
-   /opt/mysql/mysql/include 
-   /usr/mysql/include/mysql
-   /usr/include/mysql
-   /usr/local/include/mysql
-   /opt/local/include/mysql
-   /opt/ports/include/mysql5/mysql
-)
-
 if(WIN32)
 set(MYSQL_CLIENT_LIBRARY_NAME libmysql)
 else(WIN32)


signature.asc
Description: This is a digitally signed message part.
___
Amarok-devel mailing list
Amarok-devel@kde.org
https://mail.kde.org/mailman/listinfo/amarok-devel