Read the G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT attribute (unix::is-mountpoint) to
determine if a volume is a mount that udisks2 has detected. Ignoring these
prevents network mounts from showing up as devices.
GioLister::UnmountDevice calls g_object_unref on the GVolume object held by a
DeviceInfo. This appears to be left over from a time before DeviceInfo held
onto the volume.
The extends two functions:
- Recognize iPods as iPods, check for them in MakeDeviceUrls
- Give them a nice Icon in DeviceIcons (code taken from devicekitlister)
Since the SimpleTreeItem constructor variant used from LoadAllDevices adds the
object to the parent's children list, use the parent's Delete method to destroy
it.
QUrl interprets a single number as an ip address, so the track URL cdda://1
would become cdda://0.0.0.1. A previous fix addresses this issue by adding an
extra character "a" to the affected URLs then removing the last instance of the
character upon usage. However, this didn't apply when a path was present
(cdda:///dev/sr0/1), but would still attempt to reverse the change later
(cdd:///dev/sr0/1).
This change applies the fix-up to all cdda urls and moves the conversion
utilities to a single location.
See: 335bc89c9 ("Workaround for broken CD playback in Qt5 (#6021)")
When a directory is removed from the library during a scan, the scan continues
until complete. This change cancels the scan immediately, unblocking the watcher
thread, then signals the watcher to remove the directory.
A second issue occurs when a previously scanned device is removed during a
scan. All remaining files will be marked as deleted. This change mitigates
this issue, but a timing hole still remains here.
On Linux systems, failure to watch a path may be caused by the limit set in
/proc/sys/fs/inotify/max_user_watches. This can be demonstrated by creating
a directory with a large number of empty subdirectories and adding that test
directory as a library.
Check that a file is readable before adding a watch. If adding the watch fails,
report the error to the user only once. Only add the path to subdir_mapping_
if watch succeeds.
Using libmtp or libgphoto2 to access a device that gvfs has mounted causes the
connection to fail. libmtp is calling libusb_claim_interface which, according to
libusb documentation, will return LIBUSB_ERROR_BUSY if claimed by a different
program. For mtp and gphoto2 devices discovered by the GioLister, use the file
scheme and access the device through the gvfs mount.
The uri returned from g_file_get_uri is percent encoded. This causes the regex
in GioLister::MakeDeviceUrls to fail and causes the URL to be invalid. In this
case, it falls back to the file scheme. Newer versions of gvfs obtain the serial
id from udev instead of using the bus and device IDs.
Note that this bug covers a different issue where mtp is failing to connect. The
result is actually desired behavior. The follow-up change will address this.
A LibraryBackend may be deleted while an associated LibraryModel object is using
it. An example is an async query running while a connected device is removed.
To prevent this, use a share pointer for the LibraryBackend.
This fixes one case where LibraryBackend is used after deletion. However, the
raw pointer is still passed around in several other places. These should be
evaluated on a case-by-case basis to insure that circular depencencies aren't
introduced.
A commit in qt 5.7 changes a qWarning to a qFatal if a QThread is still running
when it's deleted. When we get the LoadFinished signal in MtpDevice, stop
the loader thread's event loop to avoid this situation.
See qtbase commit c8277b6e532
There is a small chance that a device lister is able to discover and add a
previously known device before it is added by the database loader thread.
In this case, copy the data that is user-settable to the existing DeviceInfo
object and destroy the object created from the database query.
This adds and utilizes a new FindEquivalentDevice method that compares the
device unique IDs. This could probably be made more robust as the unique
IDs for some listers may change. However, this is a problem with the database
storage implementation in general.
When DeviceManager initializes, it creates a thread to load device information
from the database. Part of this process includes use of QPixMap for icons which
produced a warning message:
22:32:53.763 WARN unknown QPixmap: It is not safe to use pixmaps outside the GUI thread
In addition, the device is added to the view using beginInsertRows and
endInsertRows. This could contend with a device added by a lister signaling
PhysicalDeviceAdded.
To solve these problems, this change moves the icon loading and insertion to the
main thread. LoadAllDevices reads the data from the database and creates the
DeviceInfo object, then sends a signal to the main thread. In the signal
handler, the icon is loaded and the device is added to the master list and view.
When unmounting a device, the ConnectedDevice object is destroyed. The
FileSystemDevice destructor waits on its worker thread. If a scan is in
progress, this will block until completion.
There is an existing Stop method in the LibraryWatcher class that is intended to
stop long running operations. To fix, or at least significantly shorten this
hang, we'll call this before waiting for the thread to exit. Also add a
stop_requested check in the cover art scan.
In addition, add a call to Stop in the Library destructor, which has a similar
usage.
Currently, the failure to connect to an MTP device results in the UI displaying
an open device that appears empty. This change introduces a method
ConnectedDevice::ConnectAsync() that is expected to handle any connecting tasks
that could block asynchronously. Upon completion, this emits a ConnectFinished
signal that indicates success or failure. The row in the UI is only updated
after the successful response is received. Upon failure, DeviceManager will
clean up and the row in UI is left in the pre-connect state.
Currently, only the MtpDevice utilizes this mechanism. All other devices use a
default implementation that immediately reports success.
In 1.37.2, gvfs switched to URIs that remain consistent across USB device
re-enumerations. This removed the usb bus and device numbers from the URI. In
the case that these values aren't found in the URI, try to parse Unix device
name property and pass results as query params on the URL. Pay attention to
these params in MtpConnection.
See gvfs commits 3a7bb06b and efc76d0c for reference.
GError messages contain non-ascii characters. This normally just produces some garbage when we use the default QString contructor that assumes ASCII for logging. However, when a message includes the right double quote, UTF-8 sequence 0xE2 0x80 0x9D, the final byte is OSC. VT100 expects a command sequence to follow and stops echoing output until it sees ST or BEL character, which may never come. Thus, the console output is halted.
This change uses QString::fromLocal8Bit instead of depending on the default constructor. About half of the sites in the codebase had already been converted.
One side effect is that log messages are quoted. There are additional options to control this, but those were only introduced in Qt 5.4.
GPodLoader and MtpLoader Error signals were connected to Error signals in their repective device classes, but the actual signal definition in ConnectedDevice was removed in a refactor several years ago. This change adds LoaderError slots to these device classes and reports the error in the manner of the refactored code.