mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Check library: Fix popup about check being performed not being rendered
The vacuum locks the db and there are various events on the GUI thread that can cause db access which causes the GUI thread to hang. Find and fix the most common of these. It isnt a complete solution, but its better than nothing.
This commit is contained in:
parent
1b1715b8fe
commit
96d9f39ad0
@ -142,6 +142,7 @@ class Cache:
|
|||||||
|
|
||||||
def __init__(self, backend, library_database_instance=None):
|
def __init__(self, backend, library_database_instance=None):
|
||||||
self.shutting_down = False
|
self.shutting_down = False
|
||||||
|
self.is_doing_rebuild_or_vacuum = False
|
||||||
self.backend = backend
|
self.backend = backend
|
||||||
self.library_database_instance = (None if library_database_instance is None else
|
self.library_database_instance = (None if library_database_instance is None else
|
||||||
weakref.ref(library_database_instance))
|
weakref.ref(library_database_instance))
|
||||||
@ -2429,7 +2430,11 @@ class Cache:
|
|||||||
|
|
||||||
@write_api
|
@write_api
|
||||||
def vacuum(self):
|
def vacuum(self):
|
||||||
|
self.is_doing_rebuild_or_vacuum = True
|
||||||
|
try:
|
||||||
self.backend.vacuum()
|
self.backend.vacuum()
|
||||||
|
finally:
|
||||||
|
self.is_doing_rebuild_or_vacuum = False
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
self.close()
|
self.close()
|
||||||
|
@ -659,6 +659,8 @@ class ChooseLibraryAction(InterfaceAction):
|
|||||||
d = DBCheck(self.gui, db)
|
d = DBCheck(self.gui, db)
|
||||||
try:
|
try:
|
||||||
d.start()
|
d.start()
|
||||||
|
from calibre.gui2.widgets import BusyCursor
|
||||||
|
with BusyCursor():
|
||||||
d.exec()
|
d.exec()
|
||||||
try:
|
try:
|
||||||
m.close()
|
m.close()
|
||||||
|
@ -612,7 +612,9 @@ class Scheduler(QObject):
|
|||||||
from calibre.gui2.ui import get_gui
|
from calibre.gui2.ui import get_gui
|
||||||
gui = get_gui()
|
gui = get_gui()
|
||||||
if gui is not None:
|
if gui is not None:
|
||||||
return gui.current_db
|
ans = gui.current_db
|
||||||
|
if not ans.new_api.is_doing_rebuild_or_vacuum:
|
||||||
|
return ans
|
||||||
|
|
||||||
def oldest_check(self):
|
def oldest_check(self):
|
||||||
if self.oldest > 0:
|
if self.oldest > 0:
|
||||||
|
@ -966,6 +966,8 @@ class BooksModel(QAbstractTableModel): # {{{
|
|||||||
self.column_to_dc_decorator_map = [self.dc_decorator.get(col, None) for col in self.column_map]
|
self.column_to_dc_decorator_map = [self.dc_decorator.get(col, None) for col in self.column_map]
|
||||||
|
|
||||||
def data(self, index, role):
|
def data(self, index, role):
|
||||||
|
if self.db.new_api.is_doing_rebuild_or_vacuum:
|
||||||
|
return None
|
||||||
col = index.column()
|
col = index.column()
|
||||||
# in obscure cases where custom columns are both edited and added, for a time
|
# in obscure cases where custom columns are both edited and added, for a time
|
||||||
# the column map does not accurately represent the screen. In these cases,
|
# the column map does not accurately represent the screen. In these cases,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user