mirror of https://gitee.com/openkylin/peony.git
fix glib/gio critcal caused by gicon cast.
This commit is contained in:
parent
90cf41bded
commit
701e695118
|
@ -507,10 +507,13 @@ const QList<QAction *> DirectoryViewMenu::constructCreateTemplateActions()
|
|||
while (l) {
|
||||
auto app_info = static_cast<GAppInfo*>(l->data);
|
||||
if (!isOnlyUnref) {
|
||||
GThemedIcon *icon = G_THEMED_ICON(g_app_info_get_icon(app_info));
|
||||
const char * const * icon_names = g_themed_icon_get_names(icon);
|
||||
if (icon_names)
|
||||
tmpIcon = QIcon::fromTheme(*icon_names);
|
||||
GIcon *icon = g_app_info_get_icon(app_info);
|
||||
QString iconName = FileUtils::getIconStringFromGIcon(icon);
|
||||
if (iconName.startsWith("/")) {
|
||||
tmpIcon.addFile(iconName);
|
||||
} else {
|
||||
tmpIcon = QIcon::fromTheme(iconName);
|
||||
}
|
||||
if(!tmpIcon.isNull())
|
||||
isOnlyUnref = true;
|
||||
}
|
||||
|
|
|
@ -328,7 +328,7 @@ void FileInfoJob::refreshInfoContents(GFileInfo *new_info)
|
|||
info->m_unix_device_file = g_file_info_get_attribute_string(new_info,G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE_FILE);
|
||||
|
||||
GIcon *g_icon = g_file_info_get_icon (new_info);
|
||||
if (G_IS_ICON(g_icon)) {
|
||||
if (G_IS_THEMED_ICON(g_icon)) {
|
||||
const gchar* const* icon_names = g_themed_icon_get_names(G_THEMED_ICON (g_icon));
|
||||
if (icon_names) {
|
||||
auto p = icon_names;
|
||||
|
@ -347,7 +347,7 @@ void FileInfoJob::refreshInfoContents(GFileInfo *new_info)
|
|||
|
||||
//qDebug()<<m_display_name<<m_icon_name;
|
||||
GIcon *g_symbolic_icon = g_file_info_get_symbolic_icon (new_info);
|
||||
if (G_IS_ICON(g_symbolic_icon)) {
|
||||
if (G_IS_THEMED_ICON(g_symbolic_icon)) {
|
||||
const gchar* const* symbolic_icon_names = g_themed_icon_get_names(G_THEMED_ICON (g_symbolic_icon));
|
||||
if (symbolic_icon_names)
|
||||
info->m_symbolic_icon_name = QString (*symbolic_icon_names);
|
||||
|
|
|
@ -54,14 +54,11 @@ FileLaunchAction::FileLaunchAction(const QString &uri, GAppInfo *app_info, bool
|
|||
return;
|
||||
|
||||
GIcon *icon = g_app_info_get_icon(m_app_info);
|
||||
const char * const * icon_names = g_themed_icon_get_names(G_THEMED_ICON (icon));
|
||||
|
||||
if (icon_names) {
|
||||
m_icon = QIcon::fromTheme(*icon_names);
|
||||
auto iconName = FileUtils::getIconStringFromGIcon(icon);
|
||||
if (iconName.startsWith("/")) {
|
||||
m_icon.addFile(iconName);
|
||||
} else {
|
||||
// fix #68592
|
||||
g_autofree gchar *icon_path = g_icon_to_string(icon);
|
||||
m_icon.addFile(icon_path);
|
||||
m_icon = QIcon::fromTheme(iconName);
|
||||
}
|
||||
setIcon(m_icon);
|
||||
m_info_name = g_app_info_get_name(m_app_info);
|
||||
|
|
|
@ -331,14 +331,7 @@ QString Drive::iconName()
|
|||
if (!m_drive)
|
||||
return nullptr;
|
||||
GIcon *g_icon = g_drive_get_icon(m_drive);
|
||||
const gchar* const* icon_names = g_themed_icon_get_names(G_THEMED_ICON (g_icon));
|
||||
QString iconName;
|
||||
if(icon_names) {
|
||||
iconName= *icon_names;
|
||||
} else {
|
||||
g_autofree gchar *icon_name = g_icon_to_string(g_icon);
|
||||
iconName = icon_name;
|
||||
}
|
||||
QString iconName = FileUtils::getIconStringFromGIcon(g_icon);
|
||||
g_object_unref(g_icon);
|
||||
if (iconName.isEmpty())
|
||||
return "drive-harddisk";
|
||||
|
@ -349,12 +342,12 @@ QString Drive::symbolicIconName()
|
|||
{
|
||||
if (!m_drive)
|
||||
return nullptr;
|
||||
GThemedIcon *g_icon = G_THEMED_ICON(g_drive_get_symbolic_icon(m_drive));
|
||||
const gchar* const* icon_names = g_themed_icon_get_names(G_THEMED_ICON (g_icon));
|
||||
GIcon *g_icon = g_drive_get_symbolic_icon(m_drive);
|
||||
QString iconName = FileUtils::getIconStringFromGIcon(g_icon);
|
||||
g_object_unref(g_icon);
|
||||
if (! icon_names)
|
||||
if (iconName.isEmpty())
|
||||
return "drive-harddisk";
|
||||
return *icon_names;
|
||||
return iconName;
|
||||
}
|
||||
|
||||
QString Volume::name()
|
||||
|
@ -377,12 +370,12 @@ QString Volume::iconName()
|
|||
|
||||
QString Volume::symbolicIconName()
|
||||
{
|
||||
GThemedIcon *g_icon = G_THEMED_ICON(g_volume_get_symbolic_icon(m_volume));
|
||||
const gchar* const* icon_names = g_themed_icon_get_names(G_THEMED_ICON (g_icon));
|
||||
GIcon *g_icon = g_volume_get_symbolic_icon(m_volume);
|
||||
QString iconName = FileUtils::getIconStringFromGIcon(g_icon);
|
||||
g_object_unref(g_icon);
|
||||
if (! icon_names)
|
||||
if (iconName.isEmpty())
|
||||
return "drive-harddisk";
|
||||
return *icon_names;
|
||||
return iconName;
|
||||
}
|
||||
|
||||
QString Mount::name()
|
||||
|
@ -405,10 +398,10 @@ QString Mount::iconName()
|
|||
|
||||
QString Mount::symbolicIconName()
|
||||
{
|
||||
GThemedIcon *g_icon = G_THEMED_ICON(g_mount_get_symbolic_icon(m_mount));
|
||||
const gchar* const* icon_names = g_themed_icon_get_names(G_THEMED_ICON (g_icon));
|
||||
GIcon *g_icon = g_mount_get_symbolic_icon(m_mount);
|
||||
QString iconName = FileUtils::getIconStringFromGIcon(g_icon);
|
||||
g_object_unref(g_icon);
|
||||
if (! icon_names)
|
||||
if (iconName.isEmpty())
|
||||
return "drive-harddisk";
|
||||
return *icon_names;
|
||||
return iconName;
|
||||
}
|
||||
|
|
|
@ -857,25 +857,19 @@ void Volume::initVolumeInfo()
|
|||
m_uuid = guuid;
|
||||
m_device = gdevice;
|
||||
GIcon* gicon = g_volume_get_icon(m_volume);
|
||||
const char * const * icon_names = g_themed_icon_get_names((GThemedIcon *)gicon);
|
||||
if(icon_names) {
|
||||
m_icon= *icon_names;
|
||||
|
||||
// fix #81852, refer to #57660, #70014, #96652, task #25343
|
||||
if (QString(m_icon) == "drive-harddisk-usb") {
|
||||
double size = 0.0;
|
||||
if(!tmpDevice.isEmpty()){
|
||||
size = Peony::FileUtils::getDeviceSize(tmpDevice.toUtf8().constData());
|
||||
}else{
|
||||
size = Peony::FileUtils::getDeviceSize(m_device.toUtf8().constData());
|
||||
}
|
||||
|
||||
if (size < 128) {
|
||||
m_icon = "drive-removable-media-usb";
|
||||
}
|
||||
m_icon = Peony::FileUtils::getIconStringFromGIcon(gicon, tmpDevice);
|
||||
// fix #81852, refer to #57660, #70014, #96652, task #25343
|
||||
if (QString(m_icon) == "drive-harddisk-usb") {
|
||||
double size = 0.0;
|
||||
if(!tmpDevice.isEmpty()){
|
||||
size = Peony::FileUtils::getDeviceSize(tmpDevice.toUtf8().constData());
|
||||
}else{
|
||||
size = Peony::FileUtils::getDeviceSize(m_device.toUtf8().constData());
|
||||
}
|
||||
|
||||
if (size < 128) {
|
||||
m_icon = "drive-removable-media-usb";
|
||||
}
|
||||
} else {
|
||||
m_icon = Peony::FileUtils::getIconStringFromGIcon(gicon, tmpDevice);
|
||||
}
|
||||
|
||||
if(m_volume)
|
||||
|
@ -1085,20 +1079,15 @@ void Drive::initDriveInfo(){
|
|||
m_canStop = g_drive_can_stop(m_drive);
|
||||
m_name=g_drive_get_name(m_drive);
|
||||
GIcon* gicon = g_drive_get_icon(m_drive);
|
||||
const char * const * icon_names = g_themed_icon_get_names((GThemedIcon *)gicon);
|
||||
if(icon_names) {
|
||||
m_icon= *icon_names;
|
||||
|
||||
// fix #81852, refer to #57660, #70014, #96652, task #25343
|
||||
if (QString(m_icon) == "drive-harddisk-usb") {
|
||||
double size = Peony::FileUtils::getDeviceSize(m_device.toUtf8().constData());
|
||||
if (size < 128) {
|
||||
m_icon = "drive-removable-media-usb";
|
||||
}
|
||||
m_icon = Peony::FileUtils::getIconStringFromGIcon(gicon, m_device);
|
||||
// fix #81852, refer to #57660, #70014, #96652, task #25343
|
||||
if (QString(m_icon) == "drive-harddisk-usb") {
|
||||
double size = Peony::FileUtils::getDeviceSize(m_device.toUtf8().constData());
|
||||
if (size < 128) {
|
||||
m_icon = "drive-removable-media-usb";
|
||||
}
|
||||
} else {
|
||||
m_icon = Peony::FileUtils::getIconStringFromGIcon(gicon, m_device);
|
||||
}
|
||||
|
||||
g_object_unref(gicon);
|
||||
}
|
||||
|
||||
|
@ -1292,25 +1281,20 @@ void Mount::initMountInfo(){
|
|||
m_canUnmount = g_mount_can_unmount(m_mount);
|
||||
/* 获取图标 */
|
||||
GIcon* gicon = g_mount_get_icon(m_mount);
|
||||
const char * const * icon_names = g_themed_icon_get_names((GThemedIcon *)gicon);
|
||||
if(icon_names) {
|
||||
m_icon= *icon_names;
|
||||
|
||||
// fix #81852, refer to #57660, #70014, #96652, task #25343
|
||||
if (QString(m_icon) == "drive-harddisk-usb") {
|
||||
double size = 0.0;
|
||||
if(!tmpDevice.isEmpty()){
|
||||
size = Peony::FileUtils::getDeviceSize(tmpDevice.toUtf8().constData());
|
||||
}else{
|
||||
size = Peony::FileUtils::getDeviceSize(m_device.toUtf8().constData());
|
||||
}
|
||||
if (size < 128) {
|
||||
m_icon = "drive-removable-media-usb";
|
||||
}
|
||||
m_icon = Peony::FileUtils::getIconStringFromGIcon(gicon, tmpDevice);
|
||||
// fix #81852, refer to #57660, #70014, #96652, task #25343
|
||||
if (QString(m_icon) == "drive-harddisk-usb") {
|
||||
double size = 0.0;
|
||||
if(!tmpDevice.isEmpty()){
|
||||
size = Peony::FileUtils::getDeviceSize(tmpDevice.toUtf8().constData());
|
||||
}else{
|
||||
size = Peony::FileUtils::getDeviceSize(m_device.toUtf8().constData());
|
||||
}
|
||||
if (size < 128) {
|
||||
m_icon = "drive-removable-media-usb";
|
||||
}
|
||||
} else {
|
||||
m_icon = Peony::FileUtils::getIconStringFromGIcon(gicon, tmpDevice);
|
||||
}
|
||||
|
||||
g_object_unref (gicon);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue