help wanted: strange / unknown behaviour of gui.create_job
まだ誰も着手していません。
評価
調査の方向性
示されている登録済みアクションから始め、dt.control.sleep がある場合とない場合の両方で dt.gui.create_job のキャンセルを再現します。Lua API の実装または issue で言及されている既存のスクリプトを使って、stop_job と最終的な代入の前後における job.valid のライフサイクルを追跡します。キャンセルの挙動と安全な job ライフサイクルの使用方法が明確化または修正され、報告されたクラッシュが発生しなければ完了です。
索引モデルが issue の本文から書いたものです。
説明
I'm currently writing (or, trying to write 🙄) a lua script that will generate the preview cache for selected images (without leaving dt to start the external program...). Basically, it seems to work but I see two strange things that I don't understand right now.
First, the essential parts of my script:
local function stop_job( job )
job.valid = false
end
local function create_previews()
job = dt.gui.create_job( "generating previews", true, stop_job )
local images = dt.gui.action_images
for i,image in pairs(images) do
if job.valid then
image:generate_cache( true, 0, 8 )
job.percent = i / #images
dt.control.sleep( 1 ) -- without this, the job cannot be aborted
else
break
end
end
if job.valid then -- without this, dt crashes with an exception in dt_pthread_mutex_destroy() after aborting the job
job.valid = false
end
end
the create_previews function will be called from a registered action.
My two questions:
-
Without the sleep() I cannot stop the running job. After starting the job, the progress bar is shown and when I hit the 'X' nothing happens until the for loop processed all images. Then the stop_job() is called. With the sleep the stop_job is called after processing the current image and the job terminates as desired.
-
When I set the job.valid to false after the loop it only works as long as the job is not terminated via the stop_job function. As this already sets the job to invalid I guess it is already destroyed and in the second job.valid=false dt crashes with an exception in dt_pthread_mutex_destroy.
Both phenomena are completely understandable, but: I see a lot of scripts that execute job.valid=false twice (when aborted) and seem to rely on stopping without a call to sleep(). Hmmm. What I'm missing here?
I hope you can clarify this,
thanks a lot!
Christian
- 主要言語
- Lua
- スター
- 219
- フォーク
- 142
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
darktable-org/lua-scripts のほかの issue
-
dtutils.string: build_substitute_list errors when a metadata field (e.g. rights) has been removed オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
darktable-org/lua-scripts#716 · コメント 2 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
darktable-org/lua-scripts#706 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
darktable-org/lua-scripts#627 · コメント 2 件 ·
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 65/100
darktable-org/lua-scripts#618 · コメント 3 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 52/100
darktable-org/lua-scripts#710 · コメント 3 件 ·
darktable-org/lua-scripts の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
HenrikBengtsson/CBI-software#134 ·
-
Nmap
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
secondlife/slua#96 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100